赞
踩
nc是netcat工具的命令,是一个很好用的网络工具。比如,可以用来端口扫描,文件传输等网络功能。实际命令是ncat。
参数说明:
A服务器上安装nc工具yum -y install nc
B客户端上安装nc工具yum -y install nc
- nc -v -z -w2 127.0.0.1 1-100
- localhost@408560 ~ % nc -v -z -w2 127.0.0.1 1-100
- nc: connectx to 127.0.0.1 port 1 (tcp) failed: Connection refused
- nc: connectx to 127.0.0.1 port 2 (tcp) failed: Connection refused
- nc: connectx to 127.0.0.1 port 3 (tcp) failed: Connection refused
- nc: connectx to 127.0.0.1 port 4 (tcp) failed: Connection refused
- Connection to 127.0.0.1 22 port [tcp/ssh] succeeded!
- Connection to 127.0.0.1 8866 port [tcp/*] succeeded!
- nc -v -z -w2 -u 127.0.0.1 1-100
-
- localhost@408560 ~ % nc -v -z -w2 -u 127.0.0.1 1-100
- Connection to 127.0.0.1 port 1 [udp/tcpmux] succeeded!
- Connection to 127.0.0.1 port 2 [udp/compressnet] succeeded!
- Connection to 127.0.0.1 port 3 [udp/compressnet] succeeded!
- Connection to 127.0.0.1 port 4 [udp/*] succeeded!
- server: nc -l 5555< test.txt
-
- client: nc -n 127.0.0.1 >test.txt
- 文件可以发送,目录也同样可以传输,利用管道传输起来。
-
- server: tar -czvf- faith/ |nc -l 5555
-
- client: nc -n 127.0.0.1 5555 | tar -zxvf -
- server:nc -lvp 5555 bash -i >& /dev/tcp/127.0.0.1/5555 0 >&1
-
- client: nc -lvp 5555
-
- 发送消息聊天
- server: nc -l 5555
-
- client: nc 127.0.0.1 5555
-
- l参数使用监听模式,管控传入的资料
- nc -vz 127.0.0.1 8080
- Ncat: Version 7.50 ( https://nmap.org/ncat )
- Ncat: Connected to 127.0.0.1:8080.
- Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
- # client bs单位块大小 count块数量,bs不要太大不然内存不够
- dd if=/dev/zero bs=2 count=1 | nc 192.168.0.95 8080
- 1+0 records in
- 1+0 records out
- 2 bytes (2 B) copied, 1.8711e-05 s, 107 kB/s
- nc -zvu 127.0.0.1 8888
- Hello, UDP client. index: 3689178
- Ncat: UDP packet sent successfully
- Ncat: 1 bytes sent, 33 bytes received in 2.01 seconds.
- echo "Hello from PC" | nc -w14 -u -v 127.0.0.1 8888
- Ncat: Version 7.50 ( https://nmap.org/ncat )
- Ncat: Connected to 127.0.0.1:8888.
- Ncat: 14 bytes sent, 0 bytes received in 0.01 seconds.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。