工具介紹
Netcat是一款非常出名的網絡工具(它只有49KB),簡稱“NC”,有滲透測試中的“瑞士軍刀”之稱。它可以用作端口監聽、端口掃描、遠程文件傳輸、還可以實現遠程shell等功能。
工具參數
connect to somewhere: nc [-options] hostname port[s] [ports] ...
listen for inbound: nc -l -p port [options] [hostname] [port]
options:
-d detach from console, background mode
-g gateway source-routing hop point[s], up to 8
-G num source-routing pointer: 4, 8, 12, ...
-h this cruft
-i secs delay interval for lines sent, ports scanned
-l listen mode, for inbound connects
-L listen harder, re-listen on socket close
-n numeric-only IP addresses, no DNS # 直接使用IP地址,而不通過域名服務器
-o file hex dump of traffic
-p port local port number
-r randomize local and remote ports
-s addr local source address
-u UDP mode # UDP模式
-v verbose [use twice to be more verbose] # 詳細信息
-w secs timeout for connects and final net reads # 掃描超時時間
-z zero-I/O mode [used for scanning] # 不發送數據
port numbers can be individual or ranges: m-n [inclusive]
常見用法
1. TCP端口測試
# 測試單一端口
nc -vz 192.168.2.200 80
# 測試連續端口
nc -vz 192.168.2.200 80-8080
2. UDP端口測試
# 核心參數 -u
nc.exe -u -v -v 182.92.12.11 123
3. 測試連通性
# 服務器端開啓TCP監聽端口
nc -l -p 80
# 服務器端開啓UDP監聽端口
nc -u -l -p 123
寫在最後
NETCAT還有許多不可描述的功能,請大家自行研究。
我曾經寫一個腳本批量定時關閉無線信號,避免在非工作時間被非法枚舉攻擊。