hping is a network tool in order to create or generate network packets in order to test network, service, or system performance. hping is an old tool developed by different entities and named with new versions like hping2 or hping3. In most cases, you can use the command which is provided by your operating system which can be hping or hping2 or hping3. The hping name is derived from the ping command name. The hping3 is developed by the SalvatoreSanflippo and licensed with the GPL3.
hping supports protocols like TCP, UDP, ICMP, raw IP, etc. for different use cases. By using it we can create different protocol packets with different options.
- Create raw IP packets
- Specify generated packet count
- Set packet sending interval
- Specify the transmitting network interface
- Create and generate TCP packets
- Create and generate UDP packets
- Create and generate IP packets
- Create and generate ICMP packets
- Set MTU value
- Set fragmentation and create fragmented or unfragmented packets
- Set payload or data size for the packets
Why Use hping Command?
With its advanced features and common protocol support, the hping command can be used for different cases like below.
- DOS (Denial of Service) and DDOS (Distributed Denial of Service) attack simulation
- Testing firewall and the firewall configuration for protocols like TCP, UDP, IP
- Detailed and advanced TCP and UDP port scanning
- Testing network devices for different configurations like fragmentation, MTU, etc.
- Advanced traceroute for listing intermediate hosts
- Remote OS (Operating System) fingerprinting and detection
- Remote uptime decision
- TCP/IP protocol implementation and stack testing and auditing
Install hping3 For Ubuntu, Kali, Debian, Mint
The hping is provided by Ubuntu, Kali, Debian, Mint but with a different name. The package is named hping3 for these deb-based distributions. So we will install the hping3 package with the following command.
$ sudo apt install hping3
After the installation is completed we can check the hping3 command like below by using the -v option. The -v option is used to display version information.
$ hping3 -v
If we try to use the hping command we will get the following error.
$ hping Command 'hping' not found, but there are 14 similar ones.
Install hping3 For CentOS, Fedora, RHEL
The rpm-based distributions like CentOS, Fedora, RHEL provide the hping with the name of hping3. The hping3 package can be installed with the following command for these distributions.
$ sudo yum install hping3
Install hping For Windows
The hping command is also provided for the Windows operating systems. But as the hping is mainly created for the Linux operating systems with low-level source code the windows version is generally not updated regularly. The latest version of the hping is version 2 which is also called hping2 and can be downloaded from the following link.
Display hping3 Command Help Information and Supported Protocols
hping3 is a very advanced command with a lot of features, options, and parameters, etc. All this help information can be listed with the -h parameter like below.
$ hping3 -h
Traceroute hping3 Command
The hping3 command provides the traceroute feature which is used to identify the intermediate hosts between source and destination. The –traceroute option will be provided. Also the -V -1 options provided to print detailed information about traceroute. After the traceroute is complete the target will be pinged continuously.
$ hping3 --traceroute -v -1 www.wisetut.com
DOS and Flood with hping3 Command
The hping3 command is popular for the emulation of DDOS attacks. The flood operation will generate packets and flood the target with packets as much as they can. The –flood option is provided to create flood and also the -p option is used to set the remote port number for the flood. The -S option is used to set the flood type for the TCP protocol which is the sync flood.
$ sudo hping3 -S --flood -p 80 www.wisetut.com
Set Data Size
While sending packets to the destination the hping command sends some data as packet payload. The size of this data can be specified with the
--data option. In the following example, we set the data size as 128 bytes.
$ sudo hping3 -p 80 -d 128 www.wisetut.com
Set SYN Flag
By default, the hping command tries to make a connection to the specified port and send some data. But the hping also provides some low-level features like sending TCP-SYN packets to the destination. The
--syn option is used to send SYN packets.
$ sudo hping3 -p 80 -s www.wisetut.com