您现在的位置是:首页 > 文章详情

centos安装netcat工具及测试

日期:2018-06-10点击:965

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

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

1.下载

  1. $ wget https://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz<span style="font-family:Arial, Helvetica, sans-serif;padding:0px;color:rgb(63,63,63);font-size:14px;text-align:left;background-color:rgb(255,255,255);"></span>

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

2.解压

  1. $ sudo tar -zxvf netcat-0.7.1.tar.gz -C /usr/local

查看解压后的文件

  1. $ cd /user/local/study
  2. $ ls
  3. netcat-0.7.1  php
  4. $ sudo mv netcat-0.7.1 netcat
  5. $ ls
  6. netcat  php

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

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

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

4.编译安装

  1. $ make && make install

5.配置

切换到/etc目录

编辑etc/profile;加入

export NETCAT_HOME=/usr/local/netcat-0.7.1

          export PATH=$PATH:$NETCAT_HOME/bin

6.测试

  1. nc -help   或者  netcat -help
  1. GNU netcat 0.7.1, a rewrite of the famous networking tool.
  2. Basic usages:
  3. connect to somewhere:  nc [options] hostname port [port] ...
  4. listen for inbound:    nc -l -p port [options] [hostname] [port] ...
  5. tunnel to somewhere:   nc -L hostname:port -p port [options]
  6. Mandatory arguments to long options are mandatory for short options too.
  7. Options:
  8.   -c, --close                close connection on EOF from stdin
  9.   -e, --exec=PROGRAM         program to exec after connect
  10.   -g, --gateway=LIST         source-routing hop point[s], up to 8
  11.   -G, --pointer=NUM          source-routing pointer: 4, 8, 12, ...
  12.   -h, --help                 display this help and exit
  13.   -i, --interval=SECS        delay interval for lines sent, ports scanned
  14.   -l, --listen               listen mode, for inbound connects
  15.   -L, --tunnel=ADDRESS:PORT  forward local port to remote address
  16.   -n, --dont-resolve         numeric-only IP addresses, no DNS
  17.   -o, --output=FILE          output hexdump traffic to FILE (implies -x)
  18.   -p, --local-port=NUM       local port number
  19.   -r, --randomize            randomize local and remote ports
  20.   -s, --source=ADDRESS       local source address (ip or hostname)
  21.   -t, --tcp                  TCP mode (default)
  22.   -T, --telnet               answer using TELNET negotiation
  23.   -u, --udp                  UDP mode
  24.   -v, --verbose              verbose (use twice to be more verbose)
  25.   -V, --version              output version information and exit
  26.   -x, --hexdump              hexdump incoming and outgoing traffic
  27.   -w, --wait=SECS            timeout for connects and final net reads
  28.   -z, --zero                 zero-I/O mode (used for scanning)
  29. Remote port number can also be specified as range.  Example: '1-1024'

如上即安装成功;

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

  1. $ netcat -u 127.0.0.1 5999
  2. hello
  3. Serverhello
  1. $ nc -u 127.0.0.1 5999
  2. hello
  3. Serverhello
原文链接:https://www.centoschina.cn/course/install/10825.html
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章