HPING3(8)
πΈ NAME πΈ
okay so hi bestie π you just opened the manual page for HPING3(8) β like, from the System Manager's Manual β and honestly? you're about to have a good time.
hping3 β send (almost) arbitrary TCP/IP packets to network hosts. yes. almost arbitrary. we're not fully unhinged, we're just mostly unhinged π¦
β¨ SYNOPSIS β¨
hping3 [ -hvnqVDzZ012WrfxykQbFSRPAUXYjJBuTG ] [ -c count ] [ -i wait ] [ --fast ] [ -I interface ] [ -9 signature ] [ -a host ] [ -t ttl ] [ -N ip id ] [ -H ip protocol ] [ -g fragoff ] [ -m mtu ] [ -o tos ] [ -C icmp type ] [ -K icmp code ] [ -s source port ] [ -p[+][+] dest port ] [ -w tcp window ] [ -O tcp offset ] [ -M tcp sequence number ] [ -L tcp ack ] [ -d data size ] [ -E filename ] [ -e signature ] [ --icmp-ipver version ] [ --icmp-iphlen length ] [ --icmp-iplen length ] [ --icmp-ipid id ] [ --icmp-ipproto protocol ] [ --icmp-cksum checksum ] [ --icmp-ts ] [ --icmp-addr ] [ --tcpexitcode ] [ --tcp-mss ] [ --tcp-timestamp ] [ --tr-stop ] [ --tr-keep-ttl ] [ --tr-no-rtt ] [ --rand-dest ] [ --rand-source ] [ --beep ] hostname
like, yeah, that's a lot of letters. she's versatile. she contains multitudes. π
π«Ά DESCRIPTION π«Ά
hping3 is a network tool that's able to send custom TCP/IP packets and then show you the target's replies, kind of the way ping does it with ICMP replies β except hping3 has main character energy and way more options.
She handles fragmentation, arbitrary packet bodies and sizes, and yes, you can use her to transfer files encapsulated under the protocols she supports. iconic
Using hping3 you are able to perform at least the following stuff:
- Test firewall rules
- Advanced port scanning
- Test net performance using different protocols, packet size, TOS (type of service) and fragmentation.
- Path MTU discovery
- Transferring files between even really fascist firewall rules.
- Traceroute-like under different protocols.
- Firewalk-like usage.
- Remote OS fingerprinting.
- TCP/IP stack auditing.
- A lot of others.
It's also, genuinely, a great didactic tool to learn TCP/IP β no cap, this is how you actually internalize how packets work. π
hping3 is developed and maintained by antirez@invece.org and is licensed under GPL version 2. Development is open, so you can send patches, suggestions and affronts without inhibitions. she's not sensitive. she can take it. π
π¦ HPING SITE π¦
primary site at http://www.hping.org. You can find both the stable release and the instruction to download the latest source code at http://www.hping.org/download.html
π BASE OPTIONS π
-h,--helpβ Shows you a help screen on standard output, so yes you can pipe it toless. chef's kiss for long help output.-v,--versionβ Shows version information and the API used to access the data link layer: linux sock packet or libpcap.-c,--countcount β Stop after sending (and receiving) count response packets. After the last packet was sent,hping3waitsCOUNTREACHED_TIMEOUTseconds for the target host to reply. You are able to tuneCOUNTREACHED_TIMEOUTby editinghping2.h. (yes. the header file. go touch it. β¨)-i,--intervalβ Wait the specified number of seconds or micro seconds between sending each packet.--interval Xsets the wait to X seconds,--interval uXsets the wait to X micro seconds. The default is to wait one second between each packet. If you're usinghping3to transfer files, tuning this option is really important in order to increase transfer rate. Even when usinghping3to perform idle/spoofing scanning you should tune this option β seeHPING3-HOWTOfor more information.--fastβ Alias for-i u10000. Hping will send 10 packets for second.--fasterβ Alias for-i u1. Faster then--fast;) (but not as fast as your computer can send packets due to the signal-driven design). she's honest about her limits π₯²--floodβ Sent packets as fast as possible, without taking care to show incoming replies. This is ways faster than to specify the-i u0option.-n,--numericβ Numeric output only, no attempt will be made to lookup symbolic names for host addresses.-q,--quietβ Quiet output. Nothing is displayed except the summary lines at startup time and when finished.-I,--interfaceinterface name β By default on linux and BSD systemshping3uses the default routing interface. In other systems, or when there is no default route,hping3uses the first non-loopback interface. However you are able to forcehping3to use the interface you need using this option. Note: you don't need to specify the whole name β for example-I etwill matcheth0ethernet0myet1etcetera. If no interfaces match,hping3will try to uselo.-V,--verboseβ Enable verbose output. TCP replies will be shown as follows:
len=46 ip=192.168.1.1 flags=RA DF seq=0 ttl=255 id=0 win=0
rtt=0.4 ms tos=0 iplen=40 seq=0 ack=1380893504 sum=2010 urp=0
-D,--debugβ Enable debug mode. It's useful when you experience some problem withhping3. When debug mode is enabled you will get more information about interface detection, data link layer access, interface settings, options parsing, fragmentation, HCMP protocol and other stuff.-z,--bindβ Bind CTRL+Z to time to live (TTL), so you will able to increment/decrement ttl of outgoing packets pressing CTRL+Z once or twice.-Z,--unbindβ Unbind CTRL+Z so you will able to stophping3.--beepβ Beep for every matching received packet (but not for ICMP errors). π
π PROTOCOL SELECTION π
Default protocol is TCP. By default hping3 will send tcp headers to target host's port 0 with a winsize of 64 without any tcp flag on. Often this is the best way to do an 'hide ping' β useful when the target is behind a firewall that drops ICMP. Moreover a tcp null-flag to port 0 has a good probability of not being logged. stealth queen behavior, honestly. π€«
-0,--rawipβ RAW IP mode. In this modehping3will send IP header with data appended with--signatureand/or--file, see also--ipprotothat allows you to set the ip protocol field.-1,--icmpβ ICMP mode. By defaulthping3will send ICMP echo-request, you can set other ICMP type/code using--icmptype--icmpcodeoptions.-2,--udpβ UDP mode. By defaulthping3will send udp to target host's port0. UDP header tunable options are the following:--baseport,--destport,--keep.-8,--scanβ Scan mode. The option expects an argument that describes groups of ports to scan. port groups are comma separated: a number describes just a single port, so1,2,3means port1,2and3. ranges are specified using astart-endnotation, like1-1000, that tell hping to scan ports between1and1000(included). the special wordallis an alias for0-65535, while the special wordknownincludes all the ports listed in/etc/services.
Groups can be combined, so the following command line will scan ports between 1 and 1000 AND port 8888 AND ports listed in /etc/services:
hping --scan 1-1000,8888,known -S target.host.com
Groups can be negated (subtracted) using a ! character as prefix, so the following command line will scan all the ports NOT listed in /etc/services in the range 1-1024:
hping --scan '1-1024,!known' -S target.host.com
Keep in mind that while hping seems much more like a port scanner in this mode, most of the hping switches are still honored, so for example to perform a SYN scan you need to specify the -S option, you can change the TCP windows size, TTL, control the IP fragmentation as usually, and so on. The only real difference is that the standard hping behaviors are encapsulated into a scanning algorithm.
Tech note: The scan mode uses a two-processes design, with shared memory for synchronization. The scanning algorithm is still not optimal, but already quite fast.
Hint: unlike most scanners, hping shows some interesting info about received packets, the IP ID, TCP win, TTL, and so on, don't forget to look at this additional information when you perform a scan! Sometimes they shows interesting details. π
-9,--listensignature β HPING3 listen mode. Using this optionhping3waits for packet that contain signature and dump from signature end to packet's end. For example ifhping3 --listen TESTreads a packet that contain234-09sdflkjs45-TESThello_worldit will displayhello_world.
π¦ IP RELATED OPTIONS π¦
-a--spoofhostname β bestie this is the disguise option π you set a fake IP source address so the target literally never learns your real address, no cap. BUT the replies get sent to that spoofed address instead, so you won't see them π. Want to know how people pull off spoofed/idle scanning anyway? Go read theHPING3-HOWTO.--rand-sourceβ turns on random source mode, so hping throws packets out with a random source address every time. Iconic for stressing out firewall state tables and all those other per-ip dynamic tables living inside TCP/IP stacks and firewall software π₯.--rand-destβ random destination mode, let's go β¨ hping sends packets to random addresses that follow whatever rule you gave as the target host. You need to give a numerical IP address as target host, like10.0.0.x. Everyxgets swapped for a random number in the range 0-255. So to hit Internet IP addresses across the whole IPv4 space you'd do something likehping x.x.x.x --rand-dest. Not sure what addresses your rule is spitting out? Use the--debugswitch and it'll display every new destination address it generates π«Ά. When this is on, matching packets get accepted from all the destinations.
β οΈ Warning: with this option enabled hping can't detect the right outgoing interface for the packets, so you should use the --interface option to pick the outgoing interface you want.
-t--ttltime to live β sets the TTL (time to live) of your outgoing packets. You'll probs be using this with--tracerouteor--bind. If you're in doubt just tryhping3 some.host.com -t 1 --tracerouteπ.-N--idβ sets theip->idfield. Default id is random, but if fragmentation is turned on and no id is specified it'll begetpid() & 0xFFFFβ a better solution is sitting on the TODO list, fr fr.-H--ipprotoβ sets the ip protocol when you're in RAW IP mode.-W--winidβ id from Windows* systems before Win2k has a different byte ordering, so if you enable this option hping3 will properly display id replies from those Windows machines π-r--relβ displays id increments instead of id. TheHPING3-HOWTOhas more tea. Heads up: increments aren't computed asid[N]-id[N-1], they use packet loss compensation. Seerelid.cfor the deets.-f--fragβ splits packets into more fragments π handy for testing IP stacks' fragmentation performance, and for testing whether some packet filter is so weak it can be passed using tiny fragments (anachronistic). Default 'virtual mtu' is 16 bytes. see also the--mtuoption.-x--morefragβ sets the more fragments IP flag. Use this if you want the target host to send an ICMP time-exceeded during reassembly π.-y--dontfragβ sets the don't fragment IP flag. This one's for doing MTU path discovery.-g--fragofffragment offset value β sets the fragment offset.-m--mtumtu value β sets a different 'virtual mtu' than 16 when fragmentation is enabled. If packet size is greater than the 'virtual mtu', fragmentation gets turned on automatically β.-o--toshex_tos β sets Type Of Service (TOS). For more info try--tos help.-G--rrouteβ Record route π includes the RECORD_ROUTE option in every packet sent, and displays the route buffer of returned packets. Note that the IP header is only large enough for nine such routes. Many hosts ignore or discard this option. Also note that with hping you can use record route even if the target host filters ICMP β record route is an IP option, not an ICMP option, so you can use it even in TCP and UDP mode π.
πΈ ICMP RELATED OPTIONS πΈ
-C--icmptypetype β sets icmp type. Default is ICMP echo request (and it implies--icmp).-K--icmpcodecode β sets icmp code. Default is 0 (implies--icmp).--icmp-ipverβ sets the IP version of the IP header contained inside ICMP data. Default is 4.--icmp-iphlenβ sets the IP header length of the IP header contained inside ICMP data. Default is 5 (5 words of 32 bits).--icmp-iplenβ sets the IP packet length of the IP header contained inside ICMP data. Default is the real length.--icmp-ipidβ sets the IP id of the IP header contained inside ICMP data. Default is random.--icmp-ipprotoβ sets the IP protocol of the IP header contained inside ICMP data. Default is TCP.--icmp-cksumβ sets the ICMP checksum. Default is the valid checksum.--icmp-tsβ alias for--icmptype 13(to send ICMP timestamp requests) β°.--icmp-addrβ alias for--icmptype 17(to send ICMP address mask requests) π.
π TCP/UDP RELATED OPTIONS π
-s--baseportsource port β hping3 uses the source port to guess the reply's sequence number. It starts with a base source port number and increases it for every packet sent. When a packet comes back, the sequence number can be computed asreplies.dest.port - base.source.port. Default base source port is random; with this option you can set a different number. If you need the source port to NOT increase for every sent packet, use the-k--keepoption π .-p--destport[+][+]dest port β sets destination port, default is 0. If a+character comes before the dest port number (i.e.+1024), the destination port increases for every reply received. If a double+comes before it (i.e.++1024), the destination port increases for every packet sent. By default the destination port can be modified interactively using CTRL+z π.--keepβ keep still source port, see--baseportfor more info.-w--winβ sets the TCP window size. Default is 64.-O--tcpoffβ sets a fake tcp data offset. Normal data offset istcphdrlen / 4.-M--tcpseqβ sets the TCP sequence number.-L--tcpackβ sets the TCP ack.-Q--seqnumβ use this one to collect sequence numbers generated by the target host π΅οΈ super useful when you need to analyze whether the TCP sequence number is predictable. Output example:
#hping3 win98 --seqnum -p 139 -S -i u1 -I eth0
HPING uaz (eth0 192.168.4.41): S set, 40 headers + 0 data bytes
2361294848 +2361294848
2411626496 +50331648
2545844224 +134217728
2713616384 +167772160
2881388544 +167772160
3049160704 +167772160
3216932864 +167772160
3384705024 +167772160
3552477184 +167772160
3720249344 +167772160
3888021504 +167772160
4055793664 +167772160
4223565824 +167772160
The first column reports the sequence number, the second the difference between the current and last sequence number. As you can see, the target host's sequence numbers are predictable π.
-b--badcksumβ sends packets with a bad UDP/TCP checksum π.--tcp-mssβ enables the TCP MSS option and sets it to the given value.--tcp-timestampβ enables the TCP timestamp option, and tries to guess the timestamp update frequency and the remote system uptime β±οΈ.-F--finβ sets the FIN tcp flag.-S--synβ sets the SYN tcp flag.-R--rstβ sets the RST tcp flag.-P--pushβ sets the PUSH tcp flag.-A--ackβ sets the ACK tcp flag.-U--urgβ sets the URG tcp flag.-X--xmasβ sets the Xmas tcp flag π.-Y--ymasβ sets the Ymas tcp flag.
β¨ COMMON OPTIONS β¨
-d--datadata size β sets the packet body size. β οΈ Warning: with--data 40hping3 will NOT generate a 0 byte packet, it generatesprotocol_header+40bytes. hping3 displays packet size info as the first line of output, like this:HPING www.yahoo.com (ppp0 204.71.200.67): NO FLAGS are set, 40 headers + 40 data bytes-E--filefilename β uses the contents of filename to fill the packet's data.-e--signsignature β fills the first signature length bytes of data with signature. If the signature length is bigger than the data size, an error message gets displayed π. If you don't specify the data size, hping will use the signature size as the data size. This option can be used safely together with the--filefilename option β the remainder of the data space gets filled using filename π.-j--dumpβ dumps received packets in hex.-J--printβ dumps received packets' printable characters.-B--safeβ enables safe protocol; with this option, lost packets in file transfers get resent π. For example, to send the file/etc/passwdfrom host A to host B you could use:
[host_a]
# hping3 host_b --udp -p 53 -d 100 --sign signature --safe --file /etc/passwd
[host_b]
# hping3 host_a --listen signature --safe --icmp
-u--endβ if you're using the--filefilename option, this tells you when EOF has been reached. Plus it prevents the other end from accepting more packets. Please, for more info see theHPING3-HOWTO.-T--tracerouteβ traceroute mode π with this option hping3 increases the ttl for each ICMP time to live 0 during transit that it receives. Tryhping3 host --traceroute. This option implies--bindand--ttl 1. You can override that ttl of 1 using the--ttloption. Since 2.0.0 stable it prints RTT information β.--tr-keep-ttlβ keeps the TTL fixed in traceroute mode, so you can monitor just one hop in the route. For example, to monitor how the 5th hop changes, or how its RTT changes, tryhping3 host --traceroute --ttl 5 --tr-keep-ttlπ¦.--tr-stopβ if this is specified, hping will exit as soon as it receives the first packet that isn't an ICMP time exceeded. This better emulates the traceroute behavior π .--tr-no-rttβ doesn't show RTT information in traceroute mode. The ICMP time exceeded RTT information isn't even calculated if this option is set.--tcpexitcodeβ exits with the last received packet'stcp->th_flagas the exit code. Handy for scripts that need to know, say, whether port 999 of some host replies with SYN/ACK or with RST in response to SYN β i.e. whether the service is up or down π.
π TCP OUTPUT FORMAT π
ok so when hping3 gives you a TCP reply back, this is the standard lil glow-up it shows you:
len=46 ip=192.168.1.1 flags=RA DF seq=0 ttl=255 id=0 win=0 rtt=0.4 ms
let me break it down field by field because every single one matters bestie:
lenβ the size, in bytes, of the data captured from the data link layer, excluding the data link header size. and like, heads up: this might not match the IP datagram size because of low level transport layer padding. it's giving "close enough" energy π«Άipβ the source ip address, obviously πflagsβ the TCP flags!! and the letters are:Rfor RESET,Sfor SYN,Afor ACK,Ffor FIN,Pfor PUSH,Ufor URGENT,Xfor not standard0x40, andYfor not standard0x80. soRAup there means RESET + ACK, iconic honestlyDFβ if the reply contains this, the IP header has the don't fragment bit set πseqβ the sequence number of the packet. it's obtained using the source port for TCP/UDP packets, and the sequence field for ICMP packetsidβ the IP ID fieldwinβ the TCP window sizerttβ the round trip time, in milliseconds β±οΈ
and ok, if you run hping with the -V command line switch it will show you extra info about the packet, like:
len=46 ip=192.168.1.1 flags=RA DF seq=0 ttl=255 id=0 win=0 rtt=0.4 ms
tos=0 iplen=40 seq=0 ack=1223672061 sum=e61d urp=0
and those extra fields are:
tosβ the type of service field of the IP headeriplenβ the IP total len fieldseqandackβ the sequence and acknowledge 32bit numbers in the TCP headersumβ the TCP header checksum valueurpβ the TCP urgent pointer value
π¦ UDP OUTPUT FORMAT π¦
the standard output format is:
len=46 ip=192.168.1.1 seq=0 ttl=64 id=0 rtt=6.0 ms
and the field meaning is just the same as the TCP output meaning of the same fields. no new lore, same lore π
πΈ ICMP OUTPUT FORMAT πΈ
an example of ICMP output is:
ICMP Port Unreachable from ip=192.168.1.1 name=nano.marmoc.net
it's very simple to understand bestie, it starts with the string "ICMP" followed by the description of the ICMP error β Port Unreachable in the example. the ip field is the IP source address of the IP datagram containing the ICMP error, and the name field is just the numerical address resolved to a name (a dns PTR request) or UNKNOWN if the resolution failed π
the ICMP Time exceeded during transit or reassembly format is a bit different:
TTL 0 during transit from ip=192.168.1.1 name=nano.marmoc.net
TTL 0 during reassembly from ip=192.70.106.25 name=UNKNOWN
the only difference is the description of the error β it starts with TTL 0. that's it, that's the whole plot twist β¨
π AUTHOR π
Salvatore Sanfilippo <antirez@invece.org>, with the help of the people mentioned in the AUTHORS file and at http://www.hping.org/authors.html
π BUGS π
ok so listen, the tea:
- Even using the
--endand--safeoptions to transfer files, the final packet will be padded with0x00bytes. yeah. even then. π - Data is read without care about alignment, but alignment is enforced in the data structures. This will not be a problem under
i386but, while usually the TCP/IP headers are naturally aligned, it may create problems with different processors and bogus packets if there is some unaligned access around the code (hopefully none). - On solaris hping does not work on the loopback interface. This seems a solaris problem, as stated in the
tcpdump-workersmailing list, so the libpcap can't do nothing to handle it properly. not our fault, not libpcap's fault, it's a solaris moment fr fr π
π SEE ALSO π
ping(8), traceroute(8), ifconfig(8), nmap(1)
and that's the whole page bestie!! this one's the 2001 Aug 14 edition of HPING3(8) β yes, 2001, she's vintage, she's an elder icon, and she still slays π β¨ go ping something, love u, bye π«Άπ
π¦ where this page comes from
- debian bookworm: hping3 3.a2.ds2-10 Β· GPL-2.0-only
- debian trixie: hping3 3.a2.ds2-10.1 Β· GPL-2.0-only
- ubuntu jammy: hping3 3.a2.ds2-10 Β· GPL-2.0-only
- ubuntu noble: hping3 3.a2.ds2-10build2 Β· GPL-2.0-only
- ubuntu questing: hping3 3.a2.ds2-10.1
- ubuntu resolute: hping3 3.a2.ds2-10.1build1 Β· GPL-2.0-only
- ubuntu stonking: hping3 3.a2.ds2-10.2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms