zoukankan      html  css  js  c++  java
  • hping原理、安装、使用详解介绍

    hping原理、安装、使用详解介绍

    已有 20974 次阅读  2012-06-12 17:23   标签:  安装  color  style 

    【原理基础】 
      Hping是一个命令行下使用的TCP/IP数据包组装/分析工具,其命令模式很像Unix下的ping命令,但是它不是只能发送ICMP回应请求,它还可以支持TCP、UDP、ICMP和RAW-IP协议,它有一个路由跟踪模式,能够在两个相互包含的通道之间传送文件。Hping常被用于检测网络和主机,其功能非常强大,可在多种操作系统下运行,如Linux,FreeBSD,NetBSD,OpenBSD,Solaris,MacOs X,Windows。

    Hping的主要功能有: 

      防火墙测试 

      实用的端口扫描 

      网络检测,可以用不同的协议、服务类型(TOS)、IP分片 

      手工探测MTU(最大传输单元)路径 

      先进的路由跟踪,支持所有的协议 

      远程操作系统探测 

      远程的运行时间探测 

      TCP/IP堆栈审计 

     Hping的详细参数 


       -h --help 显示帮助信息 

       -v --version 显示Hping的版本信息 

       -c --count 指定数据包的次数 

       -i --interval 指定发包间隔为多少毫秒,如-i m10:表示发包间隔为10毫秒 

    附秒、毫秒、微秒进率

    1s=1000ms(毫秒)=1000000(微秒)
           1s=10^3ms(毫秒)=10^6μs(微秒)

       --fast 与 -i m100等同,即每秒钟发送10个数据包 

       -n --numeric 指定以数字形式输出 

       -q --quiet 退出Hping 

       -I --interface 指定IP,如本机有两块网卡,可通过此参数指定发送数据包的IP地址。如果不指定则默认使用网关IP 

       -V --verbose 冗余模式 

       -D --debug 调试信息 

       -z --bind 将ctrl+z 绑定到ttl,默认使用DST端口 

       -Z --unbind 解除ctrl+z的绑定 

      指定所用的模式: 

       默认模式 TCP模式 

       -0 --rawip RAW IP 模式 

       -1 --icmp ICMP 模式 

       -2 --udp UDP 模式 

       -8 --scan 扫描模式. 

       例: hping --scan 1-30,70-90 -S www.target.host 

       -9 --listen 监听模式 

      IP选项: 

       -a --spoof 源地址欺骗 

       --rand-dest 随机目的地址模式 

       --rand-source 随机源目的地址模式 

       -t --ttl ttl值,默认为64 

       -N --id 指定id,默认是随机的 

       -W --winid 使用win*的id 字节顺序 

       -r --rel 相对的id区域 

       -f --frag 将数据包分片后传输(可以通过薄弱的acl(访问控制 

       列表)) 

       -x --morefrag 设置更多的分片标记 

       -y --dontfrag 设置不加分片标记 

       -g --fragoff 设置分片偏移 

       -m --mtu 设置虚拟MTU, 当数据包>MTU时要使用--frag 进行分片 

       -o --tos 指定服务类型,默认是0x00,,可以使用--tos help查看帮助 

       -G --rroute 包含RECORD_ROUTE选项并且显示路由缓存 

       --lsrr 释放源路记录 

       --ssrr 严格的源路由记录 

       -H --ipproto 设置协议范围,仅在RAW IP模式下使用 

      ICMP选项 

       -C --icmptype 指定icmp类型(默认类型为回显请求) 

       -K --icmpcode 指定icmp编码(默认为0) 

       --force-icmp 发送所有ICMP数据包类型(默认只发送可以支持的类型) --icmp-gw 针对ICMP数据包重定向设定网关地址(默认是0.0.0.0) 

       --icmp-ts 相当于--icmp --icmptype 13(ICMP时间戳) 

       --icmp-addr 相当于--icmp --icmptype 17(ICMP地址掩码) 

       --icmp-help 显示ICMP的其它帮助选项 

    UDP/TCP选项 

       -s --baseport 基本源端口(默认是随机的) 

       -p --destport 目的端口(默认为0),可同时指定多个端口 

       -k --keep 仍然保持源端口 

       -w --win 指定数据包大小,默认为64 

       -O --tcpoff 设置假的TCP数据偏移 

       -Q --seqnum 仅显示TCP序列号 

       -b --badcksum 尝试发送不正确IP校验和的数据包 

      许多系统在发送数据包时使用固定的IP校验和,因此你会得到不正确的UDP/TCP校验和. 

       -M --setseq 设置TCP序列号 

       -L --setack 使用TCP的ACK(访问控制列表) 

       -F --fin 使用FIN标记set FIN flag 

       -S --syn 使用SNY标记 

       -R --rst 使用RST标记 

       -P --push 使用PUSH标记 

       -A --ack 使用 ACK 标记 

       -U --urg 使用URG标记 

       -X --xmas 使用 X 未用标记 (0x40) 

       -Y --ymas 使用 Y 未用标记 (0x80) 

       --tcpexitcode 最后使用 tcp->th_flags 作为退出代码 

       --tcp-timestamp 启动TCP时间戳选项来猜测运行时间 

      常规选项 

       -d --data 数据大小,默认为0 

       -E --file 从指定文件中读取数据 

       -e --sign 增加签名 

       -j --dump 以十六进行形式转存数据包 

       -J --print 转存可输出的字符 

       -B --safe 启用安全协议 

       -u --end 当通过- -file指定的文件结束时停止并显示,防止文件再从头开始 

       -T --traceroute 路由跟踪模式 

       --tr-stop 在路由跟踪模式下当收到第一个非ICMP数据包时退出 

       --tr-keep-ttl 保持源TTL,对监测一个hop有用 

       --tr-no-rtt 使用路由跟踪模式时不计算或显示RTT信息 

      ARS 数据包描述(新增加的内容,暂时还不稳定) 

       --apd-send 发送用描述APD的数据包 

    =============================================================

    HPING 使用方法

    一、HPING和ping的区别:

    典型ping程序使用的是ICMP回显请求来测试,而HPING可以使用任何IP报文,包括ICMP、TCP、UDP、RAWSOCKET。

    二、下载:

    HTTP://WWW.HPING.ORG/

    三、安装(CentOS 5.5 64)  

    安装过程没有想象中的顺利,测试了好长时间才成功!!!

    1、安装基础库

    [root@localhost ~]# yum -y install gcc libpcap-devel   tcl-devel

    注意:此环境必须安装tcl-devel包才可以,不然一直出错,所表现的错误在下面已一一列出,请参阅下面提示

    2、下载源码包

    [root@localhost ~]# wget http://www.hping.org/hping3-20051105.tar.gz

    3、编译安装

    [root@localhost ~]# tar -zxvf hping3-20051105.tar.gz 

    [root@localhost ~]# cd hping3-20051105

    [root@localhost hping3-20051105]# ./configure

    。。。。。。。。。。。。

    creating Makefile...

    creating dependences...

    In file included from ars.h:20,

                     from apd.c:19:

    bytesex.h:22:3: error: #error can not find the byte order for this architecture, fix bytesex.h

    In file included from apd.c:19:

    ars.h:190:2: error: #error "Please, edit Makefile and add -DBYTE_ORDER_(BIG|LITTLE)_ENDIAN"

    ars.h:254:2: error: #error "Please, edit Makefile and add -DBYTE_ORDER_(BIG|LITTLE)_ENDIAN"

    ars.h:323:2: error: #error "Please, edit Makefile and add -DBYTE_ORDER_(BIG|LITTLE)_ENDIAN"

    。。。。。。。。。。。。。。。。。。。

    解决方法:

    从错误提示上看,又是什么高位前低位后到问题,打开Makefile,找了好久也找不到去哪儿添加这个环境变量,遂Google之,原来是因为64位机到缘故,遂修改上面说到的 bytesex.h (添加红色区域部分)

    [root@localhost hping3-20051105]# vi bytesex.h

    /* Original code from the Linux C library */

    /* Copyright (C) 2000,2001 Salvatore Sanfilippo <antirez@invece.org>

     * This code is under the original GNU C library license (GPL) */

    /* $Id: bytesex.h,v 1.1.1.1 2003/08/31 17:23:48 antirez Exp $ */

    #ifndef ARS_BYTESEX_H

    #define ARS_BYTESEX_H

    #if     defined(__i386__)

    || defined(__x86_64__)

            || defined(__alpha__)

            || (defined(__mips__) && (defined(MIPSEL) || defined (__MIPSEL__)))

    #define BYTE_ORDER_LITTLE_ENDIAN

    #elif   defined(__mc68000__)

            || defined (__sparc__)

            || defined (__sparc)

            || defined (__PPC__)

            || defined (__BIG_ENDIAN__)

            || (defined(__mips__) && (defined(MIPSEB) || defined (__MIPSEB__)))

    #define BYTE_ORDER_BIG_ENDIAN

    #else

    # error can not find the byte order for this architecture, fix bytesex.h

    #endif

    #endif /* ARS_BYTESEX_H */

    继续安装。。。

    [root@localhost hping3-20051105]# make                                             

    gcc -c -O2 -Wall    -g  main.c

    gcc -c -O2 -Wall    -g  getifname.c

    getifname.c: In function ‘get_output_if’:

    getifname.c:343: warning: pointer targets in passing argument 3 of ‘getsockname’ differ in signedness

    。。。。。。。。。。

    gcc -c -O2 -Wall    -g  libpcap_stuff.c

    libpcap_stuff.c:20:21: error: net/bpf.h: No such file or directory

    libpcap_stuff.c: In function ‘pcap_recv’:

    libpcap_stuff.c:61: warning: pointer targets in assignment differ in signedness

    make: *** [libpcap_stuff.o] Error 1   

    提示我bpf.h文件未找到,印象中这个文件应该是libpcap的一部分才是阿~~~

    按如下提示作个链接

    [root@localhost hping3-20051105]# ln -s /usr/include/pcap.h  /usr/include/net/bpf.h

    继续make

    [root@localhost hping3-20051105]# make

    又出现了如下错误

    。。。。。。。。。。

    /usr/bin/ld: cannot find -ltcl

    collect2: ld returned 1 exit status

    make: *** [hping3] Error 1

    这个错误排除了链接原因外就是没有安装tcp-devel包(上面第一步使用yum搭建基础环境中的红色字体部分是我后添加上去的,走了很多弯路测试了好多次才找到原因啊~~)

    安装tcl-devel包(如果第一步已安装,此外不用再重提安装!!)

    [root@localhost yum.repos.d]# yum install tcl-devel

    再次make 

    [root@localhost hping3-20051105]# make

    gcc -o hping3 -O2 -Wall    -g main.o getifname.o getlhs.o parseoptions.o datafiller.o datahandler.o gethostname.o binding.o getusec.o opensockraw.o logicmp.o waitpacket.o resolve.o sendip.o sendicmp.o sendudp.o sendtcp.o cksum.o statistics.o usage.o version.o antigetopt.o sockopt.o listen.o sendhcmp.o memstr.o rtt.o relid.o sendip_handler.o libpcap_stuff.o memlockall.o memunlockall.o memlock.o memunlock.o ip_opt_build.o display_ipopt.o sendrawip.o signal.o send.o strlcpy.o arsglue.o random.o scan.o hstring.o script.o interface.o adbuf.o hex.o apdutils.o sbignum.o sbignum-tables.o ars.o apd.o split.o rapd.o -L/usr/local/lib -lpcap  -ltcl -lm -lpthread

    ./hping3 -v

    hping version 3.0.0-alpha-1 ($Id: release.h,v 1.4 2004/04/09 23:38:56 antirez Exp $)

    NO TCL scripting support compiled in

    use `make strip' to strip hping3 binary

    use `make install' to install hping3

    又出错。。。晕了。。

    按上面红色字体提示部分进行安装

    [root@localhost hping3-20051105]# make strip

    -rwxr-xr-x 1 root root 436351 Jun 13 11:03 ./hping3

    strip hping3

    -rwxr-xr-x 1 root root 117368 Jun 13 11:03 ./hping3

    [root@localhost hping3-20051105]# make strip

    -rwxr-xr-x 1 root root 436351 Jun 13 11:03 ./hping3

    strip hping3

    -rwxr-xr-x 1 root root 117368 Jun 13 11:03 ./hping3

    [root@localhost hping3-20051105]# make install

    cp -f hping3 /usr/sbin/

    chmod 755 /usr/sbin/hping3

    ln -s /usr/sbin/hping3 /usr/sbin/hping

    ln -s /usr/sbin/hping3 /usr/sbin/hping2

    @@@@@@ WARNING @@@@@@

    Can't install the man page: /usr/local/man/man8 does not exist

    这应试安装成功了吧。。。。。

    测试是否可用

    [root@localhost hping3-20051105]# hping2 -c 4 -n -i 2 192.168.18.118

    HPING 192.168.18.118 (eth0 192.168.18.118): NO FLAGS are set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.118 ttl=64 DF id=4638 sport=0 flags=RA seq=0 win=0 rtt=1.7 ms

    len=46 ip=192.168.18.118 ttl=64 DF id=4796 sport=0 flags=RA seq=1 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.118 ttl=64 DF id=4966 sport=0 flags=RA seq=2 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.118 ttl=64 DF id=5069 sport=0 flags=RA seq=3 win=0 rtt=0.3 ms

    --- 192.168.18.118 hping statistic ---

    4 packets tramitted, 4 packets received, 0% packet loss

    round-trip min/avg/max = 0.3/0.6/1.7 ms

    [root@localhost hping3-20051105]# 

    附此类问题解决思路:http://blog.itechol.com/space.php?uid=33&do=blog&id=5773             

    四、命令注释:

    tsinghua@tsinghua-desktop:~$ hping2 --help

    usage: hping host [options]

    -h --help show this help //help

    -v --version show version //版本

    -c --count packet count //hping的包数量 和ping相同。

    -i --interval wait (uX for X microseconds, for example -i u1000) //hping的间隔 u表示微妙,--fast表示快速模式,一秒10个包。

    --fast alias for -i u10000 (10 packets for second)

    -n --numeric numeric output //表示不进行名称解析。

    -q --quiet quiet //安静模式 只输出开始结束信息。

    -I --interface interface name (otherwise default routing interface) //-使用网卡端口,缺省按路由表进行。

    -V --verbose verbose mode //详细模式 一般显示很多包信息。

    -D --debug debugging info //debug模式,定义hping2使用模式。

    -z --bind bind ctrl+z to ttl (default to dst port)//帮定快捷键

    -Z --unbind unbind ctrl+z //撤销快捷键。

    Mode //模式选择。

    default mode TCP (缺省使用TCP进行PING处理)

    -0 --rawip RAW IP mode //裸IP方式。使用RAWSOCKET方式。

    -1 --icmp ICMP mode //ICMP模式。

    -2 --udp UDP mode //UDP模式

    -8 --scan SCAN mode. //扫描模式 指定扫描对应的端口。

    Example: hping --scan 1-30,70-90 -S http://www.target.host

    -9 --listen listen mode //侦听模式,会接受指定的信息。侦听指定的信息内容。

    IP //IP模式选择。

    -a --spoof spoof source address //源地址欺骗。

    --rand-dest random destionation address mode. see the man.随机目的地址模式。

    --rand-source random source address mode. see the man. 随机源地址模式,具体信息看MAN。

    -t --ttl ttl (default 64) //修改TTL值。

    -N --id id (default random) --hping中的ID值,缺省为随机值。

    -W --winid use win* id byte ordering 使用winid的模式,针对不同的操作系统。

    -r --rel relativize id field (to estimate host traffic) //递减id区域模式。

    -f --frag split packets in more frag. (may pass weak acl)//分段,可以测试对方或者交换机碎片处理能力,缺省16字节。

    -x --morefrag set more fragments flag //大量碎片,泪滴攻击。

    -y --dontfrag set dont fragment flag //不可恢复的IP碎片。

    -g --fragoff set the fragment offset //设置断偏移。

    -m --mtu set virtual mtu, implies --frag if packet size > mtu //设置虚拟MTU值,当大于mtu的时候分段。

    -o --tos type of service (default 0x00), try --tos help //tos字段,缺省0x00,尽力而为?

    -G --rroute includes RECORD_ROUTE option and display the route buffer //记录IP路由,并显示路由缓冲。

    --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 //设置ip协议域,仅在RAW ip模式使用。

    ICMP //ICMP模式。

    -C --icmptype icmp type (default echo request) //ICMP类型,缺省回显请求。

    -K --icmpcode icmp code (default 0) //ICMP代码。

    --force-icmp send all icmp types (default send only supported types) //强制ICMP类型。

    --icmp-gw set gateway address for ICMP redirect (default 0.0.0.0) //ICMP重定向

    --icmp-ts Alias for --icmp --icmptype 13 (ICMP timestamp) //icmp时间戳

    --icmp-addr Alias for --icmp --icmptype 17 (ICMP address subnet mask) //icmp子网地址。

    --icmp-help display help for others icmp options //ICMP帮助。

    UDP/TCP //UDP/TCP模式。

    -s --baseport base source port (default random) //缺省随机源端口

    -p --destport [+][+]<port> destination port(default 0) ctrl+z inc/dec //缺省目的端口为0,连接后端口+1。

    -k --keep keep still source port //保持源端口

    -w --win winsize (default 64) //win的滑动窗口。

    -O --tcpoff set fake tcp data offset (instead of tcphdrlen / 4)//设置伪造的数据偏移。

    -Q --seqnum shows only tcp sequence number //tcp 连接序列号

    -b --badcksum (try to) send packets with a bad IP checksum //IP包校验。

    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 //设置TCP序列号

    -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 //一大堆IP抱头的设置。

    -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 //tcp的时间戳。

    Common //通用设置

    -d --data data size (default is 0) 发送数据包大小,缺省是0。

    -E --file data from file //从文件中发送

    -e --sign add 'signature' //标注签名

    -j --dump dump packets in hex //以16进制显示包格式

    -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)

    五、具体应用:

    1、PING失效后的主机检测:

    [root@localhost hping3-20051105]# hping2 192.168.18.188

    HPING 192.168.18.188 (eth0 192.168.18.188): NO FLAGS are set, 40 headers + 0 data bytes

    --- 192.168.18.188 hping statistic ---

    9 packets tramitted, 0 packets received, 100% packet loss

    round-trip min/avg/max = 0.0/0.0/0.0 ms

    [root@localhost hping3-20051105]# hping2 -c 4 -n -i 2 192.168.18.251

    HPING 192.168.18.251 (eth0 192.168.18.251): NO FLAGS are set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.251 ttl=64 DF id=0 sport=0 flags=RA seq=0 win=0 rtt=0.7 ms

    len=46 ip=192.168.18.251 ttl=64 DF id=0 sport=0 flags=RA seq=1 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.251 ttl=64 DF id=0 sport=0 flags=RA seq=2 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.251 ttl=64 DF id=0 sport=0 flags=RA seq=3 win=0 rtt=0.2 ms

    --- 192.168.18.251 hping statistic ---

    4 packets tramitted, 4 packets received, 0% packet loss

    round-trip min/avg/max = 0.2/0.4/0.7 ms

    -c 发送4个报文 -n 不进行名称解析 -i 包发送时间间隔。

    显示信息解释:len,返 回ip报文大小;ttl; id,IP的ID域;sport,源端口,flags,返回的IP报设置的TCP标志 (R:RESET,A:ACK;S:SYN;F:FIN;P:PUSH;U:URGENT);seq:序列号;win:tcp窗口大小;rtt:往返 时,EIGRP似乎有这个设置。

    好处:

    即使主机阻塞了ICMP报文,也可以显示主机是否在运行的信息,在关掉ICMP的探测有效!

    如下示:

    主机192.168.18.117上我设置了 iptables阻止icmp包响应。

    [root@localhost ~]# iptables -L

    Chain INPUT (policy ACCEPT)

    target     prot opt source               destination         

    DROP       icmp --  anywhere             anywhere            

    Chain FORWARD (policy ACCEPT)

    target     prot opt source               destination         

    Chain OUTPUT (policy ACCEPT)

    target     prot opt source               destination    

    使用ping测试是否能通

    [root@localhost hping3-20051105]# ping 192.168.18.117

    PING 192.168.18.117 (192.168.18.117) 56(84) bytes of data.

    --- 192.168.18.117 ping statistics ---

    3 packets transmitted, 0 received, 100% packet loss, time 2000ms

    [root@localhost hping3-20051105]# 

    使用hping2测试是否有响应包

    [root@localhost hping3-20051105]# hping2 192.168.18.117

    HPING 192.168.18.117 (eth0 192.168.18.117): NO FLAGS are set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=0 flags=RA seq=0 win=0 rtt=0.4 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=0 flags=RA seq=1 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=0 flags=RA seq=2 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=0 flags=RA seq=3 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=0 flags=RA seq=4 win=0 rtt=0.3 ms

    --- 192.168.18.117 hping statistic ---

    5 packets tramitted, 5 packets received, 0% packet loss

    round-trip min/avg/max = 0.3/0.3/0.4 ms

    [root@localhost hping3-20051105]# 

    2、防火墙规则测试:

    hping有类似NMAP的方法来检测并收集关于潜在的防火墙的规则和能力的信息。

    如果一个主机对ping没有任何相应,而对hping有响应,假定目标的主机为192.168.2.234.

    一旦主机对hping作出了响应,那么下一步我们先用nmap先进行一个端口扫描,

    当然这个hping2也可以作扫描

    如下示:

    [root@localhost hping3-20051105]# hping2 --scan 1-100 -S 192.168.18.251

    Scanning 192.168.18.251 (192.168.18.251), port 1-100

    100 ports to scan, use -V to see all the replies

    +----+-----------+---------+---+-----+-----+-----+

    |port| serv name |  flags  |ttl| id  | win | len |

    +----+-----------+---------+---+-----+-----+-----+

       21 ftp        : .S..A...  64     0  5840    46

       22 ssh        : .S..A...  64     0  5840    46

       23 telnet     : .S..A...  64     0  5840    46

       80 http       : .S..A...  64     0  5840    46

    All replies received. Done.

    Not responding ports: 

    [root@localhost hping3-20051105]# nmap -sT -P0 -p 21-25 192.168.18.251

    Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-06-13 15:44 CST

    Interesting ports on bogon (192.168.18.251):

    PORT   STATE  SERVICE

    21/tcp open   ftp

    22/tcp open   ssh

    23/tcp open   telnet

    24/tcp closed priv-mail

    25/tcp closed smtp

    Nmap finished: 1 IP address (1 host up) scanned in 1.110 seconds

    请看下面一个示例分析:

    [root@localhost hping3-20051105]# nmap -sT -P0 -p 21-25 192.168.18.117

    Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-06-13 15:55 CST

    Interesting ports on bogon (192.168.18.117):

    PORT   STATE  SERVICE

    21/tcp closed ftp

    22/tcp open   ssh

    23/tcp closed telnet

    24/tcp closed priv-mail

    25/tcp closed smtp

    Nmap finished: 1 IP address (1 host up) scanned in 0.008 seconds

    以上信息显示除了ssh端口外,其他端口被阻塞.

    然后可以试试用hping向各个被阻塞的端口发送空的报文.用-p的开关,可以对指定的目的端口进行hping.

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -p 21 192.168.18.117 

    HPING 192.168.18.117 (eth0 192.168.18.117): NO FLAGS are set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=21 flags=RA seq=0 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=21 flags=RA seq=1 win=0 rtt=0.3 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.3/0.3/0.3 ms

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -p 23 192.168.18.117 

    HPING 192.168.18.117 (eth0 192.168.18.117): NO FLAGS are set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=23 flags=RA seq=0 win=0 rtt=0.4 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=23 flags=RA seq=1 win=0 rtt=0.2 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.2/0.3/0.4 ms

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -p 24 192.168.18.117 

    HPING 192.168.18.117 (eth0 192.168.18.117): NO FLAGS are set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=24 flags=RA seq=0 win=0 rtt=0.5 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=24 flags=RA seq=1 win=0 rtt=0.4 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.4/0.4/0.5 ms

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -p 25 192.168.18.117 

    HPING 192.168.18.117 (eth0 192.168.18.117): NO FLAGS are set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=25 flags=RA seq=0 win=0 rtt=0.6 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=25 flags=RA seq=1 win=0 rtt=0.2 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.2/0.4/0.6 ms

    端口21 23 24 25 获得了RST/ACK响应.这说明,虽然这些端口被禁止PING,但没有工具在该端口上监听.

    然而为什么NMAP没有得到响应,因为NMAP虽然使用 TCP连接,但它在TCP报头中设置了TCP SYN标记位,而HPING 使用了空标记的报文,这就告诉我们说,在主机192.168.18.117上只阻塞进入的TCP连接.

    接下来使用hping创建一个SYN报文然后将其发送到5个端口再测试.

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -S -p 21 192.168.18.117

    HPING 192.168.18.117 (eth0 192.168.18.117): S set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=21 flags=RA seq=0 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=21 flags=RA seq=1 win=0 rtt=0.3 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.3/0.3/0.3 ms

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -S -p 22 192.168.18.117

    HPING 192.168.18.117 (eth0 192.168.18.117): S set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=22 flags=SA seq=0 win=5840 rtt=0.4 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=22 flags=SA seq=1 win=5840 rtt=0.3 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.3/0.3/0.4 ms

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -S -p 23 192.168.18.117

    HPING 192.168.18.117 (eth0 192.168.18.117): S set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=23 flags=RA seq=0 win=0 rtt=0.2 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=23 flags=RA seq=1 win=0 rtt=0.3 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.2/0.3/0.3 ms

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -S -p 24 192.168.18.117

    HPING 192.168.18.117 (eth0 192.168.18.117): S set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=24 flags=RA seq=0 win=0 rtt=0.3 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=24 flags=RA seq=1 win=0 rtt=0.3 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.3/0.3/0.3 ms

    [root@localhost hping3-20051105]# hping2 -c 2 -n -i 2 -S -p 25 192.168.18.117

    HPING 192.168.18.117 (eth0 192.168.18.117): S set, 40 headers + 0 data bytes

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=25 flags=RA seq=0 win=0 rtt=0.4 ms

    len=46 ip=192.168.18.117 ttl=64 DF id=0 sport=25 flags=RA seq=1 win=0 rtt=0.3 ms

    --- 192.168.18.117 hping statistic ---

    2 packets tramitted, 2 packets received, 0% packet loss

    round-trip min/avg/max = 0.3/0.4/0.4 ms

    这次只有22端口响应,说明SSH端口是开放的,但有工具在上面监听,该端口没有进行过滤.

  • 相关阅读:
    WinRAR5.01注册码附注册机
    PS不能存储,因为程序错误
    mysql中 date datetime time timestamp 的区别
    sublime text 3 3126 注册码+中文包
    IIS7.5 用 IIS AppPool应用程序池名 做账号 将各站点权限分开
    linux vi 报错 E37: No write since last change (add ! to override)
    Linux 安装 apache2.4.23
    三级分类及名称及列表
    二级栏目名称及列表
    每隔N行输出不同样式
  • 原文地址:https://www.cnblogs.com/archoncap/p/5448667.html
Copyright © 2011-2022 走看看