NMAP
1.簡介
- NMAP:network mapper是一款開源的網絡發現的工具(network discovery)和安全審計(security auditing)的工具.這也是他的兩大主要的功能.
- 主要功能及流程:
2.命令詳解
2.1主機發現
- 原理及方式:主要向主機發起ICMP請求,TCP連接,然後根據主機返回的報文來確認主機的存活
-
命令:
-
HOST DISCOVERY( PING ):
-iL
:從文件中導入目標主機和網段--exclude
:排除不要的主機-sL
: List Scan - simply list targets to scan使用場景就是在導入主機列表文件時先列出去將要掃描的主機.(scan List)
-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:使用tcp三次握手中的連接來探測主機是否存活
-PE/PP/PM
: ICMP echo, timestamp, and netmask request discovery probes使用ICMP的時間戳,子網掩碼,請求來探測主機
-PO[protocol list]
: IP Protocol Ping使用ip包來探測是否存在
-n/-R
: Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2]
,…>: Specify custom DNS servers:指定dns的解析服務器
--system-dns
: Use OS’s DNS resolver
--traceroute
: Trace hop path to each host
-
2.2端口掃描
- 熟知端口
[外鏈圖片轉存失敗(img-Bmp2YH1L-1568813900487)(C:\Users\frinck\AppData\Roaming\Typora\typora-user-images\1568796598172.png)]
-
原理:遠程主機想服務器某個端口建立起一個連接的請求是,如果有此項服務,就會應答,如果未安裝則無應答.
-
幾種狀態:
-
掃描方式:
- 時序掃描:
T0 非常慢的掃描,通常用於IDS逃避 T1 緩慢的掃描,同樣可以避開一些IDS T2 降低掃描速度,通常不用 T3 默認掃描 T4 快速掃描,可能會被防火牆發現 T5 快速掃描,犧牲準確度 -
SCAN TECHNIQUES (TCP連接):
-sS/sT/sA/sW/sM
: TCP SYN/Connect()/ACK/Window/Maimon scans-p
:制定端口掃描-F
:快速掃描--top-ports
:掃描開放概率最高的端口-sU
: UDP Scan
-sN/sF/sX
: TCP Null, FIN, and Xmas scans
--scanflags
: Customize TCP scan flags:自定義flags
-sI
<zombie host[:probeport]>: Idle scan:空閒掃描,通過冒充另一臺殭屍網絡並觀察殭屍網絡行爲來實現的
-sY/sZ
: SCTP INIT/COOKIE-ECHO scans
-sO
: IP protocol scan
-b
: FTP bounce scan -
FIREWALL/IDS EVASION AND SPOOFING:
-f; --mtu : fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],…>: Cloak a scan with decoys
-S <IP_Address>: Spoof source address
-e : Use specified interface
-g/–source-port : Use given port number
–proxies <url1,[url2],…>: Relay connections through HTTP/SOCKS4 proxies
–data : Append a custom payload to sent packets
–data-string : Append a custom ASCII string to sent packets
–data-length : Append random data to sent packets
–ip-options : Send packets with specified ip options
–ttl : 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
2.3指紋識別
-
TCP指紋識別:根據每種操作系統對數據包的不同類型會做出不同類型的反應.
-
ICMP協議中錯誤信息可以進行指紋識別
-sV
版本探測--allports
:全端口 版本探測-sR
:RPC掃描-O
:操作系統探測2.4 腳本使用
-
nmap的腳本存在於*/nmap/scripts目錄下
- 目錄主要分爲幾大類
-
使用方式:
--script=上述腳本類型
:使用腳本--script-args=key1=value1
:傳遞參數--script-tracce
:追蹤腳本中發送接收的數據--script-updatedb
:更新腳本數據庫 -
實例
- 鑑權掃描
nmap --script=auth 192.168.0.105
- 鑑權掃描
-
2. 爆破
nmap --script=burpt 192.168.1.105
3. nmap --script=external baidu.com