hping wiki

hping getfield layer field ?skip? packet

hping getfield returns the value of the given field in the given layer, for packet. For example:
hping3> hping getfield ip ttl "ip(saddr=,daddr=,ttl=64)"

If the layer does not exist, an empty string is returned.

In complex packets the same layer can be present more times, for example an ICMP error message can have its own IP header and the IP header of the quoted packet. In order to specify what is the right layer the skip argument of hping getfield, hping hasfield, hping setfield is used. This argument specify how many layers of the specified type to skip before to get the field value, so to specify a skip value of 1 means to get the field from the second IP layer and so on. Example:
hping3.0.0-alpha> set p [hping recv eth0]

Remember that hping recv returns a Tcl list, for default this list is composed of only one element, but anyway we need to get extract this element from the list:
hping3.0.0-alpha> set packet [lindex $p 0]

Now packet is set to an ICMP error obtained using netcat to send an UDP packet to a non-bound port. We can ask for the checksum of the first ip layer:
hping3.0.0-alpha> hping getfield ip cksum $packet

If we want the second, we add a skip argument of 1:
hping3.0.0-alpha> hping getfield ip cksum 1 $packet

A skip value of 0 is valid, and is equivalent to the form without the skip argument.
Attached files
F:\downtxt\perlnetpcap.txt15316 bytesTue Jan 26 13:16:44 GMT 2010remove file
Edit this page Upload file Page history - Page last update: Thu Jun 30 13:47:15 GMT 2005 by | Your address: | Admin