記錄Nmap選項及腳本使用,僅供參考...
除了端口掃描,好像其它腳本都比較雞肋,用途感覺應該沒有專用的小工具好用,不過還是可以看看,選項和腳本還是相當的豐富的。
Nmap 使用幫助
starnight:~ starnight$ nmap
Nmap 7.40 ( https://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
Can pass hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
-iL <inputfilename>: Input from list of hosts/networks
-iR <num hosts>: Choose random targets
--exclude <host1[,host2][,host3],...>: Exclude hosts/networks
--excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
-sL: List Scan - simply list targets to scan
-sn: Ping Scan - disable port scan
-Pn: Treat all hosts as online -- skip host discovery
-PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
-PO[protocol list]: IP Protocol Ping
-n/-R: Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2],...>: Specify custom DNS servers
--system-dns: Use OS's DNS resolver
--traceroute: Trace hop path to each host
SCAN TECHNIQUES:
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
-sU: UDP Scan
-sN/sF/sX: TCP Null, FIN, and Xmas scans
--scanflags <flags>: Customize TCP scan flags
-sI <zombie host[:probeport]>: Idle scan
-sY/sZ: SCTP INIT/COOKIE-ECHO scans
-sO: IP protocol scan
-b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
-p <port ranges>: Only scan specified ports
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
--exclude-ports <port ranges>: Exclude the specified ports from scanning
-F: Fast mode - Scan fewer ports than the default scan
-r: Scan ports consecutively - don't randomize
--top-ports <number>: Scan <number> most common ports
--port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info
--version-intensity <level>: Set from 0 (light) to 9 (try all probes)
--version-light: Limit to most likely probes (intensity 2)
--version-all: Try every single probe (intensity 9)
--version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
-sC: equivalent to --script=default
--script=<Lua scripts>: <Lua scripts> is a comma separated list of
directories, script-files or script-categories
--script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
--script-args-file=filename: provide NSE script args in a file
--script-trace: Show all data sent and received
--script-updatedb: Update the script database.
--script-help=<Lua scripts>: Show help about scripts.
<Lua scripts> is a comma-separated list of script-files or
script-categories.
OS DETECTION:
-O: Enable OS detection
--osscan-limit: Limit OS detection to promising targets
--osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
Options which take <time> are in seconds, or append 'ms' (milliseconds),
's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
-T<0-5>: Set timing template (higher is faster)
--min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
--min-parallelism/max-parallelism <numprobes>: Probe parallelization
--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
probe round trip time.
--max-retries <tries>: Caps number of port scan probe retransmissions.
--host-timeout <time>: Give up on target after this long
--scan-delay/--max-scan-delay <time>: Adjust delay between probes
--min-rate <number>: Send packets no slower than <number> per second
--max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
-f; --mtu <val>: fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
-S <IP_Address>: Spoof source address
-e <iface>: Use specified interface
-g/--source-port <portnum>: Use given port number
--proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
--data <hex string>: Append a custom payload to sent packets
--data-string <string>: Append a custom ASCII string to sent packets
--data-length <num>: Append random data to sent packets
--ip-options <options>: Send packets with specified ip options
--ttl <val>: Set IP time-to-live field
--spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
--badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
-oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
and Grepable format, respectively, to the given filename.
-oA <basename>: Output in the three major formats at once
-v: Increase verbosity level (use -vv or more for greater effect)
-d: Increase debugging level (use -dd or more for greater effect)
--reason: Display the reason a port is in a particular state
--open: Only show open (or possibly open) ports
--packet-trace: Show all packets sent and received
--iflist: Print host interfaces and routes (for debugging)
--append-output: Append to rather than clobber specified output files
--resume <filename>: Resume an aborted scan
--stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
--webxml: Reference stylesheet from Nmap.Org for more portable XML
--no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
-6: Enable IPv6 scanning
-A: Enable OS detection, version detection, script scanning, and traceroute
--datadir <dirname>: Specify custom Nmap data file location
--send-eth/--send-ip: Send using raw ethernet frames or IP packets
--privileged: Assume that the user is fully privileged
--unprivileged: Assume the user lacks raw socket privileges
-V: Print version number
-h: Print this help summary page.
EXAMPLES:
nmap -v -A scanme.nmap.org
nmap -v -sn 192.168.0.0/16 10.0.0.0/8
nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (https://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES
具體使用如下:
1、 -A : 全面掃描/綜合掃描 [-A: Enable OS detection, version detection, script scanning, and traceroute]
2、 Nmap TCP/IP協議棧指紋
| 測試 | 描述 |
| T1 | 發送TCP數據包(Flag = SYN)到開放TCP端口 |
| T2 | 發送一個空的TCP數據包到開放TCP端口 |
| T3 | 發送TCP數據包(Flag=SYN,URG,PSH,FIN)到開放端口 |
| T4 | 發送TCP數據包(Flag=ACK)到開放TCP端口 |
| T5 | 發送TCP數據包(Flag=SYN)到關閉的TCP端口 |
| T6 | 發送TCP數據包(Flag=ACK)到關閉TCP端口 |
| T7 | 發送TCP數據包(Flag=URG,PSH,PSH,FIN)到關閉的TCP端口 |
3、--packet-trace : 查看交互的數據包
| 選項 | 解釋 |
| -sP | ping 掃描 [探測主機存活,不容易被發現] |
| -P0 | 無ping掃描[用於防火牆禁止ping的情況下,可以穿透防火牆,避免被防火牆發現] |
| -PS | TCP SYN Ping掃描[通過SYN/ACK和RST相應來對目標主機是否存活進行判斷] |
| -PA | TCP ACK Ping掃描 |
| -PU | UDP Ping掃描[發送一個空的UDP報文到指定端口,默認40125, 如果目標主機響應則返回一個ICMP端口不可達錯誤,如果目標主機不是存活狀態則會返回各種ICMP錯誤信息] |
| -PE;-PP;-PM | ICMP Ping Type掃描 |
| -PR | ARP Ping掃描[內網使用] |
| -sL | 列表掃描 |
| -n | 禁止DNS反向解析[較少使用] |
| -R | 反向解析域名[] |
| --system-dns | 使用系統域名解析器 |
| -6 | 掃描IPv6地址 |
| --traceroute | 路由跟蹤 |
| -PY | SCTP INIT Ping 掃描 |
4、時序選項 -T (0-5)
-T0(偏執的):非常慢的掃描,用於IDS逃避。
-T1(鬼祟的):緩慢的掃描,用於IDS逃避。
-T2(文雅的):降低速度以降低對帶寬的消耗,此選項一般不常用。
-T3(普通的):默認,根據目標的反應自動調整時間。
-T4(野蠻的):快速掃描,常用掃描方式,需要在很好的網絡環境下進行掃描,請求可能會淹沒目標。【在帶寬允許的情況下,一般可以使用-T4進行掃描】
-T5(瘋狂的):急速掃描,這種掃描方式以犧牲准確度來提升掃描速度。
5、
-sI: 空閑掃描, 允許進行端口完全欺騙掃描 nmap -sI www.0day.co:80 192.168.1.205 [並未成功]
-sO:IP協議掃描
| 選項 | 解釋 |
| -p | -F | 常用的掃描方式[-p指定端口 | -F 執行快速掃描] |
| -sS | TCP SYN掃描[半開放掃描,掃描速度高且隱蔽性好] |
| -sT | TCP 連接掃描[最基礎、最穩定的掃描方式] |
| -sU | UDP端口掃描 |
| -sN;-sF;-sX | 隱蔽掃描 -sN:Null掃描 ,-sF:FIN掃描,穿透效果好,-sX:Xmas掃描 |
| -sA | TCP ACK掃描 |
| -sW | TCP 窗口掃描 |
| -sM | TCP Maimon掃描 |
| --scanflags | 自定義TCP掃描[只要是URG、ACK、PSH、RST、SYN、FIN的任何組合都可以] |
6、指紋識別與探測
| 選項 | 解釋 |
| -sV | 版本探測 |
| --allports | 全端口版本探測,掃描全部端口,除了TCP 9100 |
| --version-intensity | 設置掃描強度 (0~9,默認7) |
| --version-light | 輕量級掃描 |
| --version-all | 重量級掃描 |
| --version-trace | 獲取詳細版本信息 |
| -sR | RPC掃描[用於確認是否是RPC端口] |
| -O | 啟用操作系統探測 |
| --osscan-limit | 對指定的目標系統進行操作系統探測 |
| --osscan-guess; --fuzzy | 推薦系統識別 |
7、定時選項
| 選項 | 解釋 |
| --min-hostgroup | 調整並行掃描組的大小 |
| --min-parallelism --max-parallelism |
調整探測報文的並行度 |
| --min-rtt-timeout --max-rtt-timeout --initial-rtt-timeout |
調整探測報文超時 |
| --host-timeout | 放棄低俗目標機器 |
| --scan-delay --max-scan-delay |
調整探測報文的時間間隔 |
8、防火牆/IDS逃逸
| 選項 | 解釋 |
| -f | 報文分段[一些主機會禁止ICMP請求,可以使用報文分段的方法來逃避目標防火牆的規則] |
| --mtu | 指定偏移大小[偏移量為8的整數倍,用來逃逸防火牆/IDS] |
| -D nmap -D [decoy1, decoy2...|RND:number][destination] |
IP欺騙 nmap -D RND:11 192.168.1.111 [隨機構造11個IP對目標進行掃描] |
| -sI | 源地址欺騙 |
| --source-port | 源端口欺騙 |
| --data-length | 指定發包長度[通常TCP包是40字節,ICMP Echo 28字節,可以指定附加隨機數據來達到規避防火牆的目的] |
| --randomize-hosts | 目標主機隨機排序[ 配合時間選項使用更好 ] |
| --spoof-mac | MAC地址欺騙 [0:隨機生成一個MAC地址、MAC Address:指定一個MAC地址、Vendor Name:從指定廠商生成一個MAC地址] |
9、信息收集: 腳本在 kali : /usr/share/nmap/scripts
| 腳本 | 解釋 |
| --script ip-geolocation-* | IP信息收集 |
| whois-domain / whois-ip | WHOIS查詢 |
| http-email-harvest [not found] | 收集E-mail信息 |
| hostmap-ip2hosts | IP反查 |
| dns-brute | DNS信息收集 [默認五個線程] nmap --script dns-brute dns-brute.threads=10 www.xxx.com |
| membase-http-info | 檢索系統信息 |
| smb-security-mode | 后台打印機服務漏洞 |
| http-stored-xss | 掃描web漏洞 |
| snmp-win32-services | 通過snmp列舉Windows服務/賬戶 |
| dns-brute | 枚舉DNS服務器的主機名 nmap --script dns-brute --script-args dns-brute.domain=baidu.com |
| http-headers/http-sitemap-generator | HTTP信息收集 |
| ssl-enum-ciphers | 枚舉SSL密鑰 |
| ssh-hostkey | SSH服務密鑰信息探測 |
10、 數據庫滲透測試
| 腳本 | 解釋 |
| mysql-databases | MySQL列舉數據庫 nmap -p3306 --script mysql-databases --script-args mysqluser=root,mysqlpass= 192.168.1.110 |
| mysql-variables | 列舉MySQL變量[好像並未成功] |
| mysql-empty-password | 檢查MySQL空密碼 |
| mysql-brute | 審計MySQL密碼 mysql -p3306 --script=mysql-brute 192.168.1.110 nmap -p3306 --script=mysql-brute userdb=/root/user.txt passdb=/root/pass.txt 192.168.1.110 |
| mysql-audit | 設計MySQL安全配置[未成功] |
| oracle-brute | 審計Oracle密碼[未測試] |
| ms-sql-brute | 設計MSSQL密碼[未測試] |
| ms-sql-empty-password | 檢查MSSQL密碼[未測試] |
| ms-sql-tables | 讀取MSSQL數據[未測試] |
| ms-sql-xp-cmdshell | MSSQL執行系統命令[未測試] |
| pgsql-brute | 設計postgresql密碼[未測試] |
11、滲透測試
| 腳本 | 解釋 |
| http-brute | 審計HTTP身份驗證 |
| ftp-brute | 審計FTP服務器 |
| http-wordpress-brute | 審計WordPress程序 |
| http-joomla-brute | 審計Joomla程序 |
| pop3-brute | 設計郵件服務器 |
| smb-brute | 審計SMB口令 |
| vns-brute | 審計VNC服務器 |
| smtp-brute smtp-enum-users |
審計SMTP服務器 |
| stuxnet-detect | 檢測Stuxnet蠕蟲 |
| snmp-netstat snmp-process snmp-win32-services snmp-brute |
SNMP服務安全審計 |
12、--iflist : 列舉接口和路由
13、-oG : 繼續終端掃描
nmap -oG 1.txt -v 192.168.1.110
nmap --resume 1.txt
14、firewalk : 探測防火牆
nmap --script=firewalk --traceroute 192.168.1.110
15、-oN 標准格式保存掃描結果
nmap -oN 1.txt 192.168.1.110
