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 方式
- 端口掃描
- 傳輸文件
- 測速
常用命令:
➜ 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 命令,可以進行兩主機之間的網速。