nc 命令介紹: Ncat is a feature-packed networking utility which reads and writes data across networks from the command line. Ncat was written for the Nmap ...
nc 命令介紹:
Ncat is a feature-packed networking utility which reads and writes data across networks from the command line. Ncat was written for the Nmap Project and is the culmination of the currently splintered family of Netcat incarnations. It is designed to be a reliable back-end tool to instantly provide network connectivity to other applications and users. Ncat will not only work with IPv4 and IPv6 but provides the user with a virtually limitless number of potential uses.
我們通過 ll 命令查看nc 命令:
➜ benchmarks ll /usr/bin/nc lrwxrwxrwx. 1 root root 4 Feb 19 19:09 /usr/bin/nc -> ncat
nc 命令 是 ncat 的軟鏈接。ncat 與 cat 有著相似的作用, 我們從命名就可以看出來:
NAME cat - concatenate files and print on the standard output
NAME
ncat - Concatenate and redirect sockets
nc 常用:
- 偵聽任意埠,以TCP/UDP 方式
- 埠掃描
- 傳輸文件
- 測速
常用命令:
1) -l 用於指定nc將處於偵聽模式。指定該參數,則意味著nc被當作server,偵聽並接受連接,而非向其它地址發起連接。 2) -p <port> 限制數據發送原埠 3) -s 指定發送數據的源IP地址,適用於多網卡機 4) -u 指定nc使用UDP協議,預設為TCP 5) -v 輸出交互或出錯信息,新手調試時尤為有用 6)-w 超時秒數,後面跟數字 7)-z 表示zero,表示掃描時不發送任何數據 常用舉例: 監聽埠:➜ benchmarks nc -l 8888 -v Ncat: Version 7.60 ( https://nmap.org/ncat ) Ncat: Generating a temporary 1024-bit RSA key. Use --ssl-key and --ssl-cert to use a permanent one. Ncat: SHA-1 fingerprint: 045B 595F 7C98 9C19 8632 46C4 1952 C3CA 6560 E0E6 Ncat: Listening on :::8888 Ncat: Listening on 0.0.0.0:8888
連接埠:
➜ benchmarks nc -vz -w 5 127.0.0.1 8888 Ncat: Version 7.60 ( https://nmap.org/ncat ) Ncat: Connected to 127.0.0.1:8888. Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
如果進行埠掃描: nc -vz -w 5 127.0.0.1 1-100 對 1-100 埠進行掃描
同理,利用兩者之間的連接可以進行文件傳輸。
如果結合 /dev/null 、/dev/zero 和 dstat 命令,可以進行兩主機之間的網速。
保持更新,轉載請註明出處。