本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.
官网
https://nmap.org/
文章 & Reference
zenmap
- 跨平台的 GUI 版 nmap bug 较多,不宜使用
脚本
报告模板
- NMAP 扫描网络资产自动导入到 Elasticstack 进行展示
导图
Nmap 渗透测试思维导图 png
常用 : nmap -T4 -A -v -p- --min-rate=1000 <target ip>
TCP1 : nmap -Pn -sS --stats-every 3m --max-scan-delay 20 -T4 -p1-65535 ip -oN <target ip>
TCP2 : nmap -nvv -Pn -sSV -p <port> --version-intensity 9 -A ip -oN <target ip>
UDP : nmap -Pn --top-ports 1000 -sU --stats-every 3m -T3 ip -oN <target ip>
组合使用(效果一般) :
返回值
Nmap 脚本参数的规则
Nmap 脚本执行格式
nmap 默认发送一个 ARP 的 PING 数据包,来探测目标主机 1-10000 范围内所开放的所有端口
nmap <target ip>
详细的描述输出
namp -vv <target ip>
自定义扫描
nmap -p (range) <target IP>
指定端口扫描
nmap -p (port1,port2,…) <target IP>
ping 扫描
nmap -sP <target ip>
路由跟踪
nmap -traceroute <target IP>
扫描一个段
nmap -sP <network address> </CIDR>
探测操作系统类型
nmap -0 <target IP>
进攻性扫描
nmap -A <target ip>
混合式扫描
nmap -vv -p1-100 -O <target ip>
用一组 IP 地址掩盖真实地址
namp -D <IP地址1,IP地址2... IP地址,ME> <target ip>
伪装 MAC 地址
nmap --spoof-mac <伪造 MAC IP地址> <target ip>
指定网卡进行扫描
nmap -e <iface> <target ip>
指定源端口
nmap -g/--source-port <portnum> <target ip>
扫描速度
nmap -T<1-5> <target ip>
脚本类型
auth : 与用户认证相关的 NSE 脚本
broadcast : 使用广播收集网络信息
brute : 暴力破解
default : 默认,执行脚本(-sC)
discovery : 与主机和服务发现相关的脚本
dos : 与拒绝服务攻击有关的脚本
exploit : 用于利用安全漏洞的脚本
external : 此类别适用于第三方服务的脚本
fuzzer : 专注于模糊测试的 NES 脚本
intrusive : 入侵脚本
malware : 与恶意软件检测相关的脚本类别
safe : 在所有情况下默认为是安全的脚本
vuln : 与检测和利用安全漏洞相关的脚本
version : 高级系统脚本
参考 : https://nmap.org/book/man-bypass-firewalls-ids.html
分割数据包
利用 IP 分片进行端口扫描 : nmap -f 192.168.100.1
设置分片大小 : nmap -f --mtu 8 192.168.100.1
跨网段的扫描存活主机和 TOP1000 端口 : nmap -v -Pn -n -e eth0 --min-hostgroup 1024 --min-parallelism 1024 -f 192.168.100.1/24 -oN /root/1.txt
欺骗 ip 和 mac 地址,不能跨网段
nmap -v -Pn -n -S 192.168.100.101 -e eth0 --spoof-mac 0 --min-hostgroup 1024 --min-parallelism 1024 -f 192.168.100.1/24 -oN /root/1.txt
参考 : https://github.com/al0ne/Nmap_Bypass_IDS
nmap 系统识别绕过 ids 检测
将 static u8 patternbyte = 0x43; /* character 'C' /
,替换为 static u8 patternbyte = 0x46; / character 'F' */
nmap UA 修改
USER_AGENT = stdnse.get_script_args('http.useragent') or "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)""
TCP window 修改tcp window 窗口大小
将 tcp->th_win = htons(1024);
,替换为 tcp->th_win = htons(10240);
修改 3389 cookie
local cookie = "mstshash=nmap"
Zmap识别
smb
枚举 SMB 用户 : nmap --script smb-enum-users.nse -p 445 <target ip>
枚举 SMB 用户 : nmap -sU -sS --script smb-enum-users.nse -p U:137,T:139 <target ip>
http
用于知道自己网站使用了哪些 http 方法 : nmap -p 80 --script http-methods <www.xxx.com>
寻找登录授权页面 : nmap -p 80 --script http-auth-finder <www.xxx.com>
启用所有和授权有关的脚本对目标主机进行探测 : nmap -p-80 --script=auth <www.xxx.com>
rsync
爆破 : nmap -p 873 --script rsync-brute --script-args 'rsync-brute.module=www' <target ip>/24
vnc
信息探测 : nmap -p 5901 -script vnc-info <target ip>
爆破 : nmap --script vnc-brute -p 5900 <target ip>/24
SSH
爆破 : nmap -p22 --script ssh-brute <target ip>
telnet
爆破 : nmap -p 23 --script telnet-brute --script-args userdb=myusers.lst,passdb=mypwds.lst,telnet-brute.timeout=8s -v <target ip>/24
ldap
爆破 : nmap -p 389 --script ldap-brute --script-args ldap.base='cn=users,dc=cqure,dc=net' <target ip>/24
FTP
信息探测 : nmap -p21 --script ftp-syst <target ip>
爆破 : nmap -p21 <target ip> --script ftp-brute --script-args userdb=/root/user.txt,passdb=/root/pass.txt
SNMP
查找 snmp 弱口令 : nmap -sU -p161 -script=snmp-brute <target ip>
获取网络端口状态 : nmap -sU -p161 --script=snmp-netstat <target ip>
获取系统信息 : nmap -sU -p161 -script=snmp-sysdescr <target ip>
获取用户信息 : nmap -sU -p161 --script=snmp-win32-user <target ip>
SMTP
枚举用户名 : nmap -p 25 --script smtp-enum-users.nse <target ip>
截图
dns
域传送 : nmap -p 53 --script dns-zone-transfer.nse -v <target ip>
MySQL
信息收集 : nmap -p3306 --script mysql-enum <target ip>
mysql 扫描 root 空密码 : nmap -p 3306 --script mysql-empty-password.nse -v <target ip>
mysql root 弱口令简单爆破 : nmap -p 3306 --script mysql-brute.nse -v <target ip>
mssql
信息收集 : nmap -p 1433 --script ms-sql-info --script-args mssql.instance-port=1433 <target ip>
扫描 sa 空密码 : nmap -p 1433 --script ms-sql-empty-password.nse -v <target ip>/24
sa 弱口令爆破 : nmap -p 1433 --script ms-sql-brute.nse -v <target ip>/24
利用 xp_cmdshell,远程执行系统命令 : nmap -p 1433 --script ms-sql-xp-cmdshell --script-args mssql.username=sa,mssql.password=sa,ms-sql-xp-cmdshell.cmd=net user test test add <target ip>/24
postgresql
爆破 : nmap -p 5432 --script pgsql-brute -v <target ip>/24
oracle
信息收集 : nmap --script oracle-tns-version -p 1521 <target ip>
爆破 : nmap --script oracle-brute-stealth -p 1521 --script-args oracle-brute-stealth.sid=ORCL -v <target ip>/24
爆破 : nmap --script oracle-brute -p 1521 --script-args oracle-brute.sid=ORCL -v <target ip>/24
mongdb
爆破 : nmap -p 27017 --script mongodb-brute <target ip>/24
redis
爆破 : nmap -p 6379 --script redis-brute.nse <target ip>/24
S7
探测 : nmap -p 102 --script s7-info.nse <target ip>
modbus
探测 : nmap -sV -p 502 --script modbus-discover <target ip>
EthernetIP
探测 : nmap -p 44818 --script enip-info.nse <target ip>
NiagaraFox
探测 : nmap -p 1911 --script fox-info <target ip>
识别和枚举 BACnet 设备 : nmap --script BACnet-discover-enumerate.nse -sU -p 47808 <target ip>
探测 CoDeSyS V2 控制器 : nmap -p 1200,2455 --script codesys-v2-discover <target ip>
探测 EthernetIP 设备 : nmap -p 44818 --script enip-enumerate.nse <target ip>
识别并枚举施耐德电气 Modicon PLC : nmap --script modicon-info -p 502 <target ip>
识别并枚举 Omron PLC
nmap --script ormontcp-info -p 9600 <target ip>
nmap --script ormonudp-info -sU -p 9600 <target ip>
识别并枚举启用 PC Worx 协议的 PLC : nmap --script pcworx-info -p 1962 <target ip>
识别并枚举支持 ProConOS 的 PLC : nmap --script proconos-info -p 20547 <target ip>
探测 S7 : nmap -p 102 --script s7-enumerate.nse <target ip>
Siemens S7 : nmap -sS -Pn -n --min-hostgroup 1024 --min-parallelism 1024 -p 102 --script s7-info -iL 123.txt -oX 123.xml
Modbus : nmap -sS -Pn -p 502 --script modicon-info -iL 123.txt -oX 123.xml
IEC 60870-5-104
nmap -Pn -n -d --script iec-identify.nse --script-args='iec-identify.timeout=500' -p 2404 <host>
nmap -Pn -n --min-hostgroup 1024 --min-parallelism 3000 -d --script iec-identify-2014.nse --script-args='iec-identify.timeout=500' -p 2404 -iL 2404.txt -oX 2404.xml
DNP3
nmap --script dnp3-info -p 20000 <host>
nmap -Pn -n --min-hostgroup 1024 --min-parallelism 3000 --script dnp3-info.nse -p 20000 -iL 20000.txt -oX 20000.xml
EtherNet/IP
nmap --script enip-info -sU -p 44818 <host>
nmap -Pn -n -sU --min-hostgroup 1024 --min-parallelism 3000 --script enip-info.nse -p 44818 -iL 44818.txt -oX 44818.xml
BACnet
nmap --script bacnet-info -sU -p 47808 <host>
nmap -Pn -n --min-hostgroup 1024 --min-parallelism 3000 -sU -p 47808 --script bacnet-info.nse -iL 47808.txt -oX 47808.xml
Tridium Niagara Fox
nmap --script fox-info.nse -p 1911 <host>
nmap -Pn -n --min-hostgroup 1024 --min-parallelism 3000 -p 1911 --script fox-info.nse -iL 1911.txt -oX 1911.xml
Crimson V3
nmap --script cr3-fingerprint -p 789 <host>
nmap -Pn -n --min-hostgroup 1024 --min-parallelism 3000 -p 789 --script cr3-fingerprint.nse -iL 789.txt -oX 789.xml
OMRON FINS
nmap --script omron-info -sU -p 9600 <host>
nmap --script ormontcp-info -p 9600 <host>
nmap --script ormonudp-info -sU -p 9600 <host>
nmap -Pn -n --min-hostgroup 1024 --min-parallelism 3000 -sU -p 9600 --script ormonudp-info.nse -iL 9600.txt -oX 9600.xml
PCWorx
nmap --script pcworx-info -p 1962 <host>
nmap -Pn -n --min-hostgroup 1024 --min-parallelism 3000 -p 1962 --script pcworx-info.nse -iL 1962.txt -oX 1962.xml
ProConOs
nmap --script proconos-info -p 20547 <host>
MELSEC-Q
nmap -script melsecq-discover -sT -p 5007 <host>
nmap -script melsecq-discover-udp.nse -sU -p 5006 <host>
修改
修改
修改
修改
修改
该项目提供大量探测脚本
该项目提供工控常见协议识别脚本