测试中,需要通过 Netcat 发送数据。
配置环境:CentOS 6.8
1、下载安装包到指定目录,例如本博主的是:/opt/software/
wget https://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz
2、解压缩文件到指定目录(注意:要先创建 /opt/module/netcat/ 目录)
tar -zxf /opt/software/netcat-0.7.1.tar.gz -C /opt/module/netcat
3、使用 root 用户,先切换至 /opt/module/netcat/netcat-0.7.1/ 该目录
[root@hadoop102 netcat-0.7.1]# pwd
/opt/module/netcat/netcat-0.7.1
[root@hadoop102 netcat-0.7.1]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
......
......
[root@hadoop102 netcat-0.7.1]# make && make install #进行编译安装
4、配置,打开 /etc/profile
[root@hadoop102 netcat-0.7.1]# vim /etc/profile
添加内容如下:
#NETCAT_HOME
export NETCAT_HOME=/opt/module/netcat/netcat-0.7.1
export PATH=$PATH:$NETCAT_HOME/bin
[root@hadoop102 netcat-0.7.1]# source /etc/profile #生效配置
[root@hadoop102 netcat-0.7.1]# nc -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'
5、启动 netcat
[root@hadoop102 netcat-0.7.1]# nc -l 9999 #监听9999端口