--tcp-connect Unprivileged TCP connect probe mode.
--tcp TCP probe mode.
--udp UDP probe mode.
--icmp ICMP probe mode.
--arp ARP/RARP probe mode.
--tr, --traceroute Traceroute mode (can only be used with TCP/ UDP/ ICMP modes).
1) 最简单的使用方式:
- [root@centos ~]# nping scanme.nmap.org
- Starting Nping 0.5.51 ( http://nmap.org/nping ) at 2011-10-14 17:48 CST
- SENT (0.3372s) ICMP 172.16.16.32 > 74.207.244.221 Echo request (type=8/code=0) ttl=64 id=52152 iplen=28
- RCVD (0.5527s) ICMP 74.207.244.221 > 172.16.16.32 Echo reply (type=0/code=0) ttl=46 id=27226 iplen=28
- SENT (1.3380s) ICMP 172.16.16.32 > 74.207.244.221 Echo request (type=8/code=0) ttl=64 id=52152 iplen=28
- RCVD (1.5502s) ICMP 74.207.244.221 > 172.16.16.32 Echo reply (type=0/code=0) ttl=46 id=27227 iplen=28
- SENT (2.3396s) ICMP 172.16.16.32 > 74.207.244.221 Echo request (type=8/code=0) ttl=64 id=52152 iplen=28
- RCVD (2.5517s) ICMP 74.207.244.221 > 172.16.16.32 Echo reply (type=0/code=0) ttl=46 id=27228 iplen=28
- SENT (3.3407s) ICMP 172.16.16.32 > 74.207.244.221 Echo request (type=8/code=0) ttl=64 id=52152 iplen=28
- RCVD (3.5531s) ICMP 74.207.244.221 > 172.16.16.32 Echo reply (type=0/code=0) ttl=46 id=27229 iplen=28
- SENT (4.3423s) ICMP 172.16.16.32 > 74.207.244.221 Echo request (type=8/code=0) ttl=64 id=52152 iplen=28
- RCVD (4.5612s) ICMP 74.207.244.221 > 172.16.16.32 Echo reply (type=0/code=0) ttl=46 id=27230 iplen=28
- Max rtt: 218.368ms | Min rtt: 211.530ms | Avg rtt: 213.680ms
- Raw packets sent: 5 (140B) | Rcvd: 5 (230B) | Lost: 0 (0.00%)
- Tx time: 4.00576s | Tx bytes/s: 34.95 | Tx pkts/s: 1.25
- Rx time: 5.00626s | Rx bytes/s: 45.94 | Rx pkts/s: 1.00
- Nping done: 1 IP address pinged in 5.36 seconds
- [root@centos ~]#
2) nping推荐的一个典型的例子(也很有趣 ! )
- [root@centos ~]# nping -c 1 --tcp -p 80,433 scanme.nmap.org www.baidu.com
- Starting Nping 0.5.51 ( http://nmap.org/nping ) at 2011-10-14 18:03 CST
- SENT (5.0542s) TCP 172.16.16.32:41300 > 74.207.244.221:80 S ttl=64 id=17109 iplen=40 seq=2938784718 win=1480
- RCVD (5.2703s) TCP 74.207.244.221:80 > 172.16.16.32:41300 SA ttl=46 id=0 iplen=44 seq=385149730 win=14600 <mss 1420>
- SENT (6.0550s) TCP 172.16.16.32:41300 > 61.135.169.125:80 S ttl=64 id=17109 iplen=40 seq=2938784718 win=1480
- SENT (7.0569s) TCP 172.16.16.32:41300 > 74.207.244.221:433 S ttl=64 id=17109 iplen=40 seq=2938784718 win=1480
- RCVD (7.2698s) TCP 74.207.244.221:433 > 172.16.16.32:41300 RA ttl=46 id=0 iplen=40 seq=0 win=0
- SENT (8.0580s) TCP 172.16.16.32:41300 > 61.135.169.125:433 S ttl=64 id=17109 iplen=40 seq=2938784718 win=1480
- Statistics for host scanme.nmap.org (74.207.244.221):
- | Probes Sent: 2 | Rcvd: 2 | Lost: 0 (0.00%)
- |_ Max rtt: 215.424ms | Min rtt: 212.379ms | Avg rtt: 213.901ms
- Statistics for host www.baidu.com (61.135.169.125):
- | Probes Sent: 2 | Rcvd: 0 | Lost: 2 (100.00%)
- |_ Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
- Raw packets sent: 4 (160B) | Rcvd: 2 (92B) | Lost: 2 (50.00%)
- Tx time: 3.00463s | Tx bytes/s: 53.25 | Tx pkts/s: 1.33
- Rx time: 4.00604s | Rx bytes/s: 22.97 | Rx pkts/s: 0.50
- Nping done: 2 IP addresses pinged in 9.07 seconds
- [root@centos ~]#
这个例子的有趣之处在于,测试完毕之后,我发现所有对www.baidu.com的测试数据包均未收到回应。这很奇怪,因为按道理,像百度这么大的网站不应该不回应我的测试包的。因此,我仔细查看了前面的数据流,终于发现了其中的蹊跷之处:所有的数据包均是通过41300这个相同的端口发送出去的。由于我们上网的NAT设备不支持EIM (Endpoint Independent Mapping,也称作Full-cone NAT),因此,所有发往www.baidu.com的数据包都被这台NAT设备给丢弃了。具体的原因我们到后面再为大家进行详细的分析。或者,有兴趣的朋友可以自己去翻阅一下RFC5382。
3) 简单的攻击测试
- [root@centos ~]# nping --tcp -p 80 --flag syn,ack,rst -c 5 --rate 10 scanme.nmap.org
- Starting Nping 0.5.51 ( http://nmap.org/nping ) at 2011-10-14 18:27 CST
- SENT (0.8205s) TCP 172.16.16.32:3167 > 74.207.244.221:80 SRA ttl=64 id=31756 iplen=40 seq=2249461123 win=1480
- SENT (0.9215s) TCP 172.16.16.32:3167 > 74.207.244.221:80 SRA ttl=64 id=31756 iplen=40 seq=2249461123 win=1480
- SENT (1.0221s) TCP 172.16.16.32:3167 > 74.207.244.221:80 SRA ttl=64 id=31756 iplen=40 seq=2249461123 win=1480
- SENT (1.1227s) TCP 172.16.16.32:3167 > 74.207.244.221:80 SRA ttl=64 id=31756 iplen=40 seq=2249461123 win=1480
- SENT (1.2233s) TCP 172.16.16.32:3167 > 74.207.244.221:80 SRA ttl=64 id=31756 iplen=40 seq=2249461123 win=1480
- Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
- Raw packets sent: 5 (200B) | Rcvd: 0 (0B) | Lost: 5 (100.00%)
- Tx time: 0.40352s | Tx bytes/s: 495.64 | Tx pkts/s: 12.39
- Rx time: 1.40498s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00
- Nping done: 1 IP address pinged in 2.24 seconds
- [root@centos ~]#
http://nmap.org/book/nping-man.html