NetCat,在网络工具中有“瑞士军刀”美誉,其有Windows和Linux的版本。由于它短小精悍,功能实用,被设计为一个简单、可靠的网络工具, 可经过TCP或UDP协议传输读写数据。同时,它仍是一个网络应用Debug分析器,由于它能够根据须要建立各类不一样类型的网络链接。 python
[yuechangchang@cp01-rdqa-dev376.cp01.baidu.com ~]$ nc -h [v1.10] connect to somewhere: nc [-options] hostname port[s] [ports] ... listen for inbound: nc -l -p port [-options] [hostname] [port] options: -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 -n numeric-only IP addresses, no DNS -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 -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: lo-hi [inclusive]
1.监听本地端口 web
nc -l -p 1234 #开启监听 netstat -tunlp | grep 1234 #查看2.端口扫描
nc -v -w 10 10.1.1.180 80 nc -v -w 10 10.1.1.180 -z 80-300003.文件传输
源10.1.1.43 text.txt ;目的 10.1.1.180 shell
nc -l -p 1234 > test.txt #开10.1.1.180:1234端口监听,并将socket传输过来的数据重定向到test.txt文件 nc 10.1.1.180 1234 < test.txt #链接远程的10.1.1.180,从test.txt的路径定向到socket,从而将文件传输到远方。
4.目录传输 网络
源10.1.1.43 python_program;目的 10.1.1.180 dom
nc -l -p 1234 | tar xzvf - tar czvf - python_program | nc 10.1.1.180 1234
5.测试UDP端口 socket
root@172.16.211.34:web#netstat -tunlp root@172.16.211.35:~# nc -vuz 172.16.211.34 68