centos7.4 安装netcat工具及测试

netcat是网络工具中的瑞士军刀,它能通过TCPUDP在网卡中读写数据。通过与其他工具结合和重定向,你可以在脚本中以多种方式使用它。使用natcat命令所能完成的事情令人惊讶。

netcat所做的就是在两台电脑之间连接并返回两个数据流,在这之后所能作的事就看你的想法了。你能建立一个服务器,传输文件,与朋友聊天,传输流媒体或者用它作为其他协议的独立客户端。

1.下载

wget https://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz

如果下载不成功,请自行前往此地址下载:http://netcat.sourceforge.net/download.php

2.解压

tar -zxvf netcat-0.7.1.tar.gz -C /usr/local

查看解压后的文件

$ cd /user/local/
$ ls
netcat-0.7.1
$ mv netcat-0.7.1 netcat
$ ls
netcat

netcat-0.7.1就是解压后的目录 将其重命名为netcat

3.切换到解压后的目录,查看编译配置文件

$ cd /use/local/netcat
$ ./configure

4.编译安装

$ make && make install

5.配置

切换到/etc目录

编辑etc/profile;加入

export NETCAT_HOME=/usr/local/netcat
export PATH=$PATH:$NETCAT_HOME/bin
source /etc/profile

6.测试

nc -help   或者  netcat -help
GNU netcat 0.7.1, a rewrite of the famous networking tool.
Basic usages:
connect to somewhere:  nc [options] hostname port [port] ...
listen for inbound:    nc -l -p port [options] [hostname] [port] ...
tunnel to somewhere:   nc -L hostname:port -p port [options]

Mandatory arguments to long options are mandatory for short options too.
Options:
  -c, --close                close connection on EOF from stdin
  -e, --exec=PROGRAM         program to exec after connect
  -g, --gateway=LIST         source-routing hop point[s], up to 8
  -G, --pointer=NUM          source-routing pointer: 4, 8, 12, ...
  -h, --help                 display this help and exit
  -i, --interval=SECS        delay interval for lines sent, ports scanned
  -l, --listen               listen mode, for inbound connects
  -L, --tunnel=ADDRESS:PORT  forward local port to remote address
  -n, --dont-resolve         numeric-only IP addresses, no DNS
  -o, --output=FILE          output hexdump traffic to FILE (implies -x)
  -p, --local-port=NUM       local port number
  -r, --randomize            randomize local and remote ports
  -s, --source=ADDRESS       local source address (ip or hostname)
  -t, --tcp                  TCP mode (default)
  -T, --telnet               answer using TELNET negotiation
  -u, --udp                  UDP mode
  -v, --verbose              verbose (use twice to be more verbose)
  -V, --version              output version information and exit
  -x, --hexdump              hexdump incoming and outgoing traffic
  -w, --wait=SECS            timeout for connects and final net reads
  -z, --zero                 zero-I/O mode (used for scanning)

Remote port number can also be specified as range.  Example: '1-1024'

如上即安装成功;

使用swoole写了一个udp的连接,测试

$ netcat -u 127.0.0.1 5999
hello
Serverhello
$ nc -u 127.0.0.1 5999
hello
Serverhello
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:上身试试 返回首页