# nc --help
Ncat 7.50 ( https://nmap.org/ncat )
Usage: ncat [options] [hostname] [port]
Options taking a time assume seconds. Append 'ms' for milliseconds,
's' for seconds, 'm' for minutes, or 'h' for hours (e.g. 500ms).
-4 Use IPv4 only
-6 Use IPv6 only
-U, --unixsock Use Unix domain sockets only
-C, --crlf Use CRLF for EOL sequence
-c, --sh-exec Executes the given command via /bin/sh
-e, --exec Executes the given command
--lua-exec Executes the given Lua script
-g hop1[,hop2,...] Loose source routing hop points (8 max)
-G Loose source routing hop pointer (4, 8, 12, ...)
-m, --max-conns Maximum simultaneous connections
-h, --help Display this help screen
-d, --delay
登入後複製
nc常用案例
TCP監聽測試
nc可作為server端192.168.10.11啟動一個tcp的監聽
nc -l 80
登入後複製
客戶端測試方法:直接telnet該機器ip 埠
telnet 192.168.10.11 80
或:nmap 192.168.10.11 -p 80
UDP監聽測試
#nc作為server端啟動一個udp的監聽
nc -lu 80
登入後複製
透過netstat可以看到udp協定已經監聽:
> # netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:80 0.0.0.0:* 15401/nc