centos7安装netcat

如果yum install -y netcat 失败,可以用下面方式离线安装

安装依赖

yum install glibc*

下载解压netcat

下载不下来去页面下载:https://sourceforge.NET/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz

#如果下载不下来可以在浏览器下载然后传上去
wget https://zenlayer.dl.sourceforge.net/project/netcat/netcat/0.7.1/netcat-0.7.1.tar.gz
tar zxvf netcat-0.7.1.tar.gz

安装

cd netcat-0.7.1
./configure
make
make install

使用

参数说明

[root@vm66 ~]# 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'

常见用法

#监听一个本地端口,等待别人连接
nc -lp 端口

#连接远程
nc ip 端口


#监听本地指定udp端口
nc -lpu 端口

#链接远程udp端口
nc -u ip 端口


#作为代理,把数据转发到到其他主机的指定端口(只能发送数据)
nc -lp  9999 | nc 192.168.100.67 9999
#代理,允许接收返回数据
nc -lp  9999 0<2way | nc 192.168.100.67 9999 1>2way

#把本地端口的数据转发到指定远程主机的指定端口
nc -L 远程ip:端口 -p 本地端口


#传输文件
nc -lp 9999 > 保存的文件名
nv ip 9999 < 发送的文件名


#远程访问
nc -l 9999 -e /bin/bash 
nc ip 9999 
然后可以通过发送常见命令行指令,进行远程操控


#检查端口是否开启
nc -zvw3 ip 端口

posted on 2024-03-03 16:16  zhangyukun  阅读(575)  评论(0编辑  收藏  举报

导航