ncat端口转发使用测试
https://nmap.org/dist/ncat-7.93-1.x86_64.rpm
11: 10.1.0.11 12:10.1.0.12 13:10.1.0.13
[root@11 ~]# yum -y install ncat-7.93-1.x86_64.rpm
[root@11 ~]# yum -y install iproute telnet
#起监听端口
[root@11 ~]# ncat -l 8888 #监听8888 只能创建一个连接,加 -k 创建多个连接
[root@12 ~]# telnet 10.1.0.11 8888
Trying 10.1.0.11...
Connected to 10.1.0.11.
Escape character is '^]'.
[root@13 ~]# telnet 10.1.0.11 8888
Trying 10.1.0.11...
telnet: connect to address 10.1.0.11: Connection refused
#起监听端口,可以多个连接
[root@11 ~]#ncat -lk 8888 & #放后台,监听多个连接,B、C都可以连通
[root@12 ~]# ncat 10.1.0.11 8888 #连接远程服务器A,这与telnet相似,也可以实现与11通信
hello
[root@13 ~]# telnet 10.1.0.11 8888
Trying 10.1.0.11...
Connected to 10.1.0.11.
Escape character is '^]'.
qq
#将 nc 作为代理
[root@12 ~]# ncat -l 8888 #有先后顺序
[root@11 ~]# ncat -l 8888 | ncat 10.1.0.12 8888
[root@13 ~]# telnet 10.1.0.11 8888
qq # 12能够收到消息,但是发的消息只有中转的主机收到,无法转发给13
#将 nc 作为代理 双向
[root@12 ~]# ncat -l 8888
[root@11 ~]# ncat -l 8888 0<2way | ncat 10.1.0.12 8888 1>2way # 先执行 mkfifo 2way,未知
[root@13 ~]# ncat 10.1.0.11 8888
11 #12能收到,telent这里中断,原因暂时不知
#使用 nc 传输文件
[root@11 ~]# ncat -l 8888 > recive.file #先准备接收
[root@12 ~]# ncat 10.1.0.11 8888 < /etc/passwd #再开始发送
[root@11 ~]# ls
recive.file
#压缩传输文件
[root@11 ~]# ncat -l 8888 | tar xfvz -
[root@12 ~]# tar czf - myfile |ncat 10.1.0.11 8888
#通过 nc 创建后门
[root@11 ~]# ncat -l 8888 -e /bin/bash
[root@12 ~]# ncat 10.1.0.11 8888 #然后就可以操作11的服务器了
hostname
11
#连接保持
[root@12 ~]# ncat -w 60 10.1.0.11 8888 #连接 60 秒后终止
#端口转发
[root@11 ~]# yum -y install
[root@11 ~]# systemctl start httpd
[root@12 ~]# ncat -lk 9090 -c "ncat 10.1.0.11 80"
[root@13 ~]# curl -v 10.1.0.12:9090
#测试连接
[root@vm test]# ncat -vz 10.1.0.12 22
Ncat: Version 7.93 ( https://nmap.org/ncat )
Ncat: Connected to 10.1.0.12:22.
Ncat: 0 bytes sent, 0 bytes received in 0.02 seconds.
·