Nmap提供–scanflags选项,用户能够对须要发送的TCP探测包的标志位进行彻底的控制。能够使用数字或符号指定TCP标志位:URG, ACK, PSH,RST, SYN,and FIN。sql
例如,安全
nmap -sX -T4 –scanflags URGACKPSHRSTSYNFINtargetip网络
此命令设置所有的TCP标志位为1,能够用于某些特殊场景的探测。tcp
另外使用–ip-options能够定制IP包的options字段。ide
使用-S指定虚假的IP地址,-D指定一组诱骗IP地址(ME表明真实地址)。-e指定发送探测包的网络接口,-g(–source- port)指定源端口,-f指定使用IP分片方式发送探测包,–spoof-mac指定使用欺骗的MAC地址。–ttl指定生存时间。spa
防火墙在今天网络安全中扮演着重要的角色,若是能对防火墙系统进行详细的探测,那么绕开防火墙或***防火墙就更加容易。因此,此处讲解利用Nmap获取防火墙基本信息典型的用法。命令行
为了获取防火墙全面的信息,需尽量多地结合不一样扫描方式来探测其状态。在设计命令行参数时,能够综合网络环境来微调时序参数,以便加快扫描速度。设计
SYN扫描code
首先能够利用基本的SYN扫描方式探测其端口开放状态。接口
nmap -sS -T4 www.91ri.org
扫描输出为:
Default
All 997 ports are filtered PORT STATE SERVICE 80/tcp open http 113/tcp closed auth 507/tcp open crs
1 2 3 4 5 6 7 8 9 |
All 997 ports are filtered
PORT STATE SERVICE
80/tcp open http
113/tcp closed auth
507/tcp open crs |
咱们能够看到SYN方式探测到3个端口开放,而有997个端口被过滤。Nmap默认扫描只扫描1000个最可能开放的端口,若是想扫描所有的端口.
使用命令nmap -sS -T4-p- www.91ri.org
FIN扫描
而后能够利用FIN扫描方式探测防火墙状态。FIN扫描方式用于识别端口是否关闭,收到RST回复说明该端口关闭,不然说明是open或filtered状态。
nmap -sF -T4 www.91ri.org
Default
PORT STATE SERVICE 7/tcp open|filtered echo 9/tcp open|filtered discard 11/tcp open|filtered systat 13/tcp open|filtered daytime 23/tcp open|filtered telnet 25/tcp open|filtered smtp 37/tcp open|filtered time 79/tcp open|filtered finger 80/tcp open|filtered http 更多端口,此处省略
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
PORT STATE SERVICE
7/tcp open|filtered echo
9/tcp open|filtered discard
11/tcp open|filtered systat
13/tcp open|filtered daytime
23/tcp open|filtered telnet
25/tcp open|filtered smtp
37/tcp open|filtered time
79/tcp open|filtered finger
80/tcp open|filtered http
更多端口,此处省略 |
ACK扫描
而后利用ACK扫描判断端口是否被过滤。针对ACK探测包,未被过滤的端口(不管打开、关闭)会回复RST包。
nmap -sA -T4 www.91ri.org
扫描输出为:
Default
Not shown: 997 unfiltered ports PORT STATE SERVICE 135/tcp filtered msrpc 1434/tcp filtered ms-sql-m 32777/tcp filtered sometimes-rpc17
1 2 3 4 5 6 7 8 9 |
Not shown: 997 unfiltered ports
PORT STATE SERVICE
135/tcp filtered msrpc
1434/tcp filtered ms-sql-m
32777/tcp filtered sometimes-rpc17 |
从结果能够997个端口是未被过滤的(unfiltered),而3个(135/1434/32777)被过滤了。因此,将ACK与FIN扫描 的结果结合分析,咱们能够找到不少开放的端口。例如7号端口,FIN中得出的状态是:open或filtered,从ACK中得出的状态是 unfiltered,那么该端口只能是open的。