【工具】hping安装与使用(01)——安装

hping官网介绍:http://www.hping.org/

hping is a command-line oriented TCP/IP packet assembler/analyzer. The interface is inspired to the ping(8) unix command, but hping isn't only able to send ICMP echo requests. It supports TCP, UDP, ICMP and RAW-IP protocols, has a traceroute mode, the ability to send files between a covered channel, and many other features.

While hping was mainly used as a security tool in the past, it can be used in many ways by people that don't care about security to test networks and hosts. A subset of the stuff you can do using hping:

  • Firewall testing
  • Advanced port scanning
  • Network testing, using different protocols, TOS, fragmentation
  • Manual path MTU discovery
  • Advanced traceroute, under all the supported protocols
  • Remote OS fingerprinting
  • Remote uptime guessing
  • TCP/IP stacks auditing
  • hping can also be useful to students that are learning TCP/IP.

Hping works on the following unix-like systems: Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOs X, Windows.

GitHub地址:https://github.com/antirez/hping

下载zip文件

先阅读INSTALL 和 README ,检查安装是否有依赖,发现有以下内容:

REQUIREMENTS

A supported unix-like OS, gcc, root access.

Libpcap.

Tcl/Tk is optional but strongly suggested.

由此可见,依赖项有 gcc、libpcap、tcl,以及需要root权限

如果没有安装依赖包,编译时会有以下错误:

# 缺少 libpcap、libpcap-devel
错误:

main.c:29:18: fatal error: pcap.h: No such file or directory
#include <pcap.h>
                  ^
compilation terminated.
make: *** [main.o] Error 1

解决方法: yum install -y  libpcap libpcap-devel

#  缺少 /usr/include/net/bpf.h

错误:

libpcap_stuff.c:19:21: fatal error: net/bpf.h: No such file or directory
#include <net/bpf.h>
                     ^
compilation terminated.
make: *** [libpcap_stuff.o] Error 1

解决方法:ln -sf /usr/include/pcap-bpf.h /usr/include/net/bpf.h

# 缺少 tcl、tcl-devel

错误:

/usr/bin/ld: cannot find -ltcl
collect2: error: ld returned 1 exit status
make: *** [hping3] Error 1

解决方法:yum install -y  tcl tcl-devel

安装过程

1、先安装依赖项

yum install -y gcc libpcap libpcap-devel tcl tcl-devel
ln -sf /usr/include/pcap-bpf.h /usr/include/net/bpf.h

2、安装

unzip hping-master.zip
cd hping-master/
./configure
make
make install

使用说明

hping -h 可以查看使用方法

后续有时间继续研究,并写一些使用说明。

原文地址:https://www.cnblogs.com/fwonfo/p/7735756.html