nc命令官方的几个Demo实例

int32位 posted @ Mar 22, 2016 03:58:54 PM in linux , 2355 阅读
转载请注明:http://krystism.is-programmer.com/若有错误,请多多指正,谢谢!

 

nc命令可用于发送任务tcp/udp连接和监听.

官方描述的主要功能包括:

  • simple TCP proxies
  • shell-script based HTTP clients and servers
  • network daemon testing
  • a SOCKS or HTTP ProxyCommand for ssh(1)
  • and much, much more

下面看看官方的几个例子:

1. p2p简单聊天工具

在A机器运行(假设A机器主机名为node1:

nc -l 1234 # -l表示监听

在B机器运行:

nc node1 1234

此时从A或者B机器输入任何信息,都会在对方的机器中回显,实现了简单的即时聊天工具.

2. 文件传输

假设B机器有一个文件data.txt,需要传输到A机器:

在A机器:

nc -l 1234 >data.txt # data.txt需要保存的目标文件名

在B机器:

nc node1 1234 <data.txt # data.txt需要传输的文件

3.远程操作(类似ssh)

假设B需要远程操作A,又没有安装ssh:

在A机器:

rm -f /tmp/f; mkfifo /tmp/f
cat /tmp/f | /bin/sh -i 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f

在B机器:

nc node1 1234

4.发送HTTP请求

echo "GET / HTTP/1.0\r\n\r\n" | nc localhost 80

5.端口扫描

# 查看主机名为node1的80端口是否开放
nc -zv node1 80
# 扫描主机名为node1的1~1024哪些端口是开放的
nc -zc node1 1-1024

 

转载请注明:http://krystism.is-programmer.com/若有错误,请多多指正,谢谢!
  • 无匹配
  • 无匹配
Alyssa 说:
2023年2月01日 19:27

The nc command is a powerful tool for networking, and with several official Demo instances available, users can explore the capabilities of this command with buy cheap diamond rings ease. This makes it easier for users to understand the various options and take advantage of its full potential. Whether you are a novice or an experienced user, these Demo instances offer an invaluable resource for gaining a greater knowledge of this command.

Bushra batool 说:
2023年9月22日 23:24

Subjects: Photography encompasses a vast array of subjects, including but not limited to christmas mini session


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter