前言 之前看了 docker-compose 的文档,今天想着用它搭建一个多级内网的环境,顺便动手试一试内网端口转发的各种工具。
环境搭建 用 docker-compose 部署了 4 个 PHP7.3-Apache 环境:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 version: '2.4' services: machineA: image: php:7.3-apache ports: - "0.0.0.0:23333:23333" - "0.0.0.0:12314:22" - "0.0.0.0:12315:80" mem_limit: 200m volumes: - ./index.php:/var/www/html/index.php restart: always networks: out_network: ipv4_address: 10.0 .20 .10 innerA_network: ipv4_address: 10.0 .30 .10 machineB: image: php:7.3-apache mem_limit: 200m volumes: - ./index.php:/var/www/html/index.php restart: always networks: innerA_network: ipv4_address: 10.0 .30 .11 innerB_network: ipv4_address: 10.0 .40 .10 machineC: image: php:7.3-apache mem_limit: 200m volumes: - ./index.php:/var/www/html/index.php restart: always networks: innerB_network: ipv4_address: 10.0 .40 .11 innerC_network: ipv4_address: 10.0 .50 .10 machineD: image: php:7.3-apache mem_limit: 200m volumes: - ./index.php:/var/www/html/index.php restart: always networks: innerC_network: ipv4_address: 10.0 .50 .11 innerD_network: ipv4_address: 10.0 .60 .10 networks: out_network: ipam: driver: default config: - subnet: 10.0 .20 .0 /24 innerA_network: internal: true ipam: driver: default config: - subnet: 10.0 .30 .0 /24 innerB_network: internal: true ipam: driver: default config: - subnet: 10.0 .40 .0 /24 innerC_network: internal: true ipam: driver: default config: - subnet: 10.0 .50 .0 /24 innerD_network: internal: true ipam: driver: default config: - subnet: 10.0 .60 .0 /24
index.php 是个一句话木马。
reGeorg 下载地址:https://github.com/sensepost/reGeorg 、https://sensepost.com/discover/tools/reGeorg/ 。
不怎么好用,总是容易出各种各样的问题。
ssh隧道 这种方式要求我们知道跳板机上的 ssh 账号密码。
首先我们要给 machineA 装一个 openssh-server,然后配置好账号密码:
1 adduser twings --gid 1000 --home /home/twings
然后测试可以从主机上连接到 docker 里面:
1 2 3 4 root@iZwz988rg4xz5mu4e7fyo2Z:~/Docker/learning# ssh twings@localhost -p 12314 twings@localhost's password: ... twings@8ef540bd2b74:~$
然后我们用 ssh 将本地的 2333 端口和 docker 容器连接起来:
1 2 3 4 PS C:\Users\19807> ssh -D 2333 twings@*.*.*.* -p 12314 twings@*.*.*.*'s password: ... twings@8ef540bd2b74:~$
然后修改 FireFox 的代理,就可以看到我们能够访问内网的 Web 服务了:
要注意的是 ssh 只能作为 socks 代理,所以配置浏览器代理的时候要将本地代理配置为 socks 主机:
ssh 还可以做本地和远程的端口转发,本地端口转发:
1 2 3 4 PS C:\Users\19807> ssh -L 2333:10.0.30.11:80 twings@*.*.*.* -p 12314 twings@*.*.*.*'s password: ... twings@8ef540bd2b74:~$
这时候我们通过 ssh,用 machineA 当作跳板,将 machineB 的 80 端口转发到了我们本地的 2333 端口,我们只要访问本地的 2333 端口,就可以访问到 machineB 的 Web 服务,记得关掉浏览器代理:
远程端口转发不怎么用到,不提了。
ew 墙裂推荐!
旧版:http://rootkiter.com/EarthWorm/ 。
新版:http://rootkiter.com/Termite/ 。
我们先把文件放进 machine 里面。
正向代理:
1 2 root@8ef540bd2b74:/tmp# chmod +x ew_linux_x64 root@8ef540bd2b74:/tmp# ./ew_linux_x64 -s ssocksd -l 23333
我们监听 23333 端口,就是 docker-compose 映射出去的那个端口。然后我们配置好代理:
就可以访问到 machineB 的 Web 服务了:
然后是反向代理,我们可以把 machineA 当作一台公网服务器,现在我们要去访问 machineC:
1 ./ew_linux_x64 -s rcsocks -l 23333 -e 2333
在 machineA 上监听 23333 端口,然后用 2333 端口等待下一级代理的回连,在 machineB 上:
1 ./ew_linux_x64 -s rssocks -d 10.0.30.10 -e 2333
反向连接 machineA 的 2333 端口,然后我们访问 machineC:
再加一级代理,我们尝试去访问 machineD,关掉 machineB 上的 ew,重新启动:
1 ./ew_linux_x64 -s rcsocks -l 23333 -e 2333
监听 23333 端口,然后用 2333 端口等待下一级代理的回连,然后在 C 上运行:
1 ./ew_linux_x64 -s rssocks -d 10.0.40.10 -e 2333
反向连接 machineB 的 2333 端口,然后再在 machineB 上执行:
1 ./ew_linux_x64 -s lcx_slave -d 10.0.30.10 -e 2333 -f 127.0.0.1 -g 23333
反向连接 machineA 的 2333 端口,并将流量转发到本地的 23333 端口。
然后我们尝试访问 machineD:
最后再说一遍,ew 我吹爆!
本地代理 Linux Linux 可以使用 proxychains。
Windows Windows 可以使用系统配置的代理(应该可以用?)
墙裂推荐全局代理 Proxifier,简单配置一下让我们的 nmap 和 Chrome 可以连接上代理,像这样,先添加一个代理服务器,然后配置代理规则:
接着我们尝试 nmap:
1 2 3 4 5 6 7 8 9 PS C:\Users\19807> nmap 10.0.50.11 -Pn -sT Starting Nmap 7.70 ( https://nmap.org ) at 2019-05-29 20:37 ?D1ú±ê×?ê±?? Nmap scan report for 10.0.50.11 Host is up (1.0s latency). Not shown: 999 closed ports PORT STATE SERVICE 80/tcp open http Nmap done: 1 IP address (1 host up) scanned in 232.82 seconds
一切正常,墙裂推荐!
MAC 没有 MAC,不懂。
浏览器 浏览器可以直接配置代理,FireFox 就很方便了。
参考文章:
https://www.jianshu.com/p/735e8f1746f0