root@10.1.1.43:~# nc -h
[v1.10-38]
connect to somewhere: nc [-options] hostname port[s] [ports] ...
listen for inbound: nc -l -p port [-options] [hostname] [port]
options:
-c shell commands as `-e'; use /bin/sh to exec [dangerous!!]
-e filename program to exec after connect [dangerous!!]
-b allow broadcasts
-g gateway source-routing hop point[s], up to 8      设置路由器跃程通信网关,最高可设置8个。
-G num source-routing pointer: 4, 8, 12, ...        设置来源路由指向器,其数值为4的倍数。
-h this cruft
-i secs delay interval for lines sent, ports sca       延时的间隔
-k set keepalive option on socket
-l listen mode, for inbound connects           监听模式,入站连接
-n numeric-only IP addresses, no DNS          直接使用ip地址,而不用域名服务器
-o file hex dump of traffic                   指定文件名称,把往来传输的数据以16进制字码倾倒成该文件保存。
-p port local port number                   本地端口
-r randomize local and remote ports               随机本地和远程端口
-q secs quit after EOF on stdin and delay of secs
-s addr local source address
-T tos set Type Of Service
-t answer TELNET negotiation
-u UDP mode udp                      模式
-v verbose [use twice to be more verbose]            显示过程,vv 更多
-w secs timeout for connects and final net reads       等待连接超时
-z zero-I/O mode [used for scanning]            使用输入/输出模式,只在扫描通信端口时使用。

1.监听本地端口

root@10.1.1.43:~# nc -l -p 1234
root@10.1.1.43:~# netstat -tunlp | grep 1234
tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN 15543/nc

2.端口扫描

root@10.1.1.43:~# nc -v -w 10 10.1.1.180 80
(UNKNOWN) [10.1.1.180] 80 (www) open

root@10.1.1.43:~# nc -v -w 10 10.1.1.180 -z 80-30000
(UNKNOWN) [10.1.1.180] 22000 (?) open
(UNKNOWN) [10.1.1.180] 80 (www) open

3.文件传出

源10.1.1.43 text.txt

目的 10.1.1.180

root@10:~# nc -l -p 1234 > test.txt           #开10.1.1.180:1234端口监听,并将socket传输过来的数据重定向到test.txt文件 test 43 nc
root@10.1.1.43:~#cat test.txt

root@10.1.1.43:~# nc 10.1.1.180 1234 < test.txt      #连接远程的10.1.1.180,从test.txt的路径从定向到socket,从而将文件传输到远方。
root@10:~# cat test.txt

4.目录传输

源10.1.1.43 python_program

目的 10.1.1.180

root@10:~# nc -l -p 1234 | tar xzvf -

root@10.1.1.43:~# tar czvf - python_program | nc 10.1.1.180 1234
python_program/
python_program/1.py
python_program/4.py
python_program/3.py

5.测试UDP端口

root@172.16.211.34:web# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1111/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 887/dhclient

root@172.16.211.35:~# nc -vuz 172.16.211.34 68
Connection to 172.16.211.34 68 port [udp/bootpc] succeeded!

最新文章

  1. Codeforces Round #382(div 2)
  2. VWmare workstation12.5中出现的问题
  3. MySQL入门(一)
  4. VIM的姿势
  5. Linux之Shell的算术运算
  6. Java 多线程submit和execute
  7. windows 访问 ubuntu虚拟机 django服务器 失败
  8. FZU 2092 收集水晶 bfs+记忆化搜索 or 暴力
  9. Spring IOC 方式结合TESTGN测试用例,测试简单java的命令模式
  10. 【Unity3D自我记录】解决NGUI通过问题触发事件点
  11. vb.net窗口继承(房重建知识汇总)
  12. jquery源码 Callback
  13. Xamarin使用ListView开启分组视图Cell数据展示bug处理
  14. ACM中常见错误对应表
  15. Spring Cloud学习笔记-010
  16. Spring Boot集成MyBatis的2种方式
  17. pycharm 配置svn
  18. shell脚本中if的“-e,-d,-f”
  19. Python基础教程之udp和tcp协议介绍
  20. Oracle 账户锁定问题解决办法

热门文章

  1. systemd管理进程
  2. H5 打开App
  3. SpringBoot使用Thymeleaf模板
  4. Atitit.跨语言&#160;java&#160;c#.net&#160;php&#160;js常用的codec&#160;encode算法api&#160;兼容性&#160;&#160;应该内置到语言里面
  5. Junit 内部解密之一: Test + TestCase + TestSuite
  6. NPOI 添加下拉列表
  7. CentOS: Make Command not Found and linux xinetd 服务不能启动
  8. saltstack之软件管理
  9. 写shader注意的一些报错
  10. Laravel开发:Laravel初始化简述