> For the complete documentation index, see [llms.txt](https://hacktricks.xsx.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacktricks.xsx.tw/network-services-pentesting/pentesting-smb/rpcclient-enumeration.md).

# rpcclient enumeration

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

* 您在**网络安全公司**工作吗？ 想要看到您的**公司在HackTricks中宣传**吗？ 或者想要访问**PEASS的最新版本或下载HackTricks的PDF**吗？ 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们独家的[NFT收藏品](https://opensea.io/collection/the-peass-family)
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
* **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* **通过向**[**hacktricks repo**](https://github.com/carlospolop/hacktricks)**和**[**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud)**提交PR来分享您的黑客技巧**。

</details>

**Try Hard Security Group**

<figure><img src="https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-dae1ef8c660e0243188462f22f417bbb1a2719d3%2Ftelegram-cloud-document-1-5159108904864449420.jpg?alt=media" alt=""><figcaption></figcaption></figure>

{% embed url="<https://discord.gg/tryhardsecurity>" %}

***

### 相对标识符（RID）和安全标识符（SID）概述

\*\*相对标识符（RID）**和**安全标识符（SID）\*\*是Windows操作系统中用于唯一标识和管理网络域内对象（如用户和组）的关键组件。

* **SIDs** 用作域的唯一标识符，确保每个域都是可区分的。
* **RIDs** 附加到SIDs以创建这些域内对象的唯一标识符。此组合允许对对象权限和访问控制进行精确跟踪和管理。

例如，名为`pepe`的用户可能具有将域的SID与其特定RID结合在一起的唯一标识符，以十六进制（`0x457`）和十进制（`1111`）格式表示。这导致在域内pepe的完整且唯一标识符如下：`S-1-5-21-1074507654-1937615267-42093643874-1111`。

### 使用rpcclient进行枚举

来自Samba的\*\*`rpcclient`**实用程序用于通过命名管道与**RPC端点进行交互\*\*。在**建立SMB会话**后，通常需要凭据才能发出以下命令到SAMR、LSARPC和LSARPC-DS接口。

#### 服务器信息

* 要获取**服务器信息**：使用`srvinfo`命令。

#### 用户枚举

* 使用以下命令可以**列出用户**：`querydispinfo`和`enumdomusers`。
* 通过以下方式获取**用户的详细信息**：`queryuser <0xrid>`。
* 使用以下命令获取**用户的组**：`queryusergroups <0xrid>`。
* 通过以下方式检索**用户的SID**：`lookupnames <username>`。
* 使用以下命令获取**用户的别名**：`queryuseraliases [builtin|domain] <sid>`。

```bash
# Users' RIDs-forced
for i in $(seq 500 1100); do
rpcclient -N -U "" [IP_ADDRESS] -c "queryuser 0x$(printf '%x\n' $i)" | grep "User Name\|user_rid\|group_rid" && echo "";
done

# samrdump.py can also serve this purpose
```

#### 枚举组

* 使用`enumdomgroups`来枚举**组**。
* 使用`querygroup <0xrid>`来获取**组的详细信息**。
* 通过`querygroupmem <0xrid>`来查看**组的成员**。

#### 枚举别名组

* 使用`enumalsgroups <builtin|domain>`来枚举**别名组**。
* 使用`queryaliasmem builtin|domain <0xrid>`来查看**别名组的成员**。

#### 枚举域

* 使用`enumdomains`来枚举**域**。
* 通过`lsaquery`来检索**域的SID**。
* 使用`querydominfo`来获取**域信息**。

#### 枚举共享

* 使用`netshareenumall`来列出**所有可用的共享**。
* 使用`netsharegetinfo <share>`来获取特定共享的**信息**。

#### 使用SID的附加操作

* 使用`lookupnames <username>`来根据名称查找**SID**。
* 通过`lsaenumsid`来获取更多**SID**。
* 使用`lookupsids <sid>`来执行**RID循环**以检查更多**SID**。

#### **额外命令**

| **命令**              | **接口**           | **描述**      |
| ------------------- | ---------------- | ----------- |
| queryuser           | SAMR             | 检索用户信息      |
| querygroup          | 检索组信息            |             |
| querydominfo        | 检索域信息            |             |
| enumdomusers        | 枚举域用户            |             |
| enumdomgroups       | 枚举域组             |             |
| createdomuser       | 创建域用户            |             |
| deletedomuser       | 删除域用户            |             |
| lookupnames         | LSARPC           | 查找用户名到SID的值 |
| lookupsids          | 查找SID到用户名（RID循环） |             |
| lsaaddacctrights    | 为用户帐户添加权限        |             |
| lsaremoveacctrights | 从用户帐户中删除权限       |             |
| dsroledominfo       | LSARPC-DS        | 获取主域信息      |
| dsenumdomtrusts     | 枚举AD森林中的受信任域     |             |

要更好地了解工具**samrdump**和**rpcdump**的工作原理，请阅读[**Pentesting MSRPC**](/network-services-pentesting/135-pentesting-msrpc.md)。

**Try Hard Security Group**

<figure><img src="https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-dae1ef8c660e0243188462f22f417bbb1a2719d3%2Ftelegram-cloud-document-1-5159108904864449420.jpg?alt=media" alt=""><figcaption></figcaption></figure>

{% embed url="<https://discord.gg/tryhardsecurity>" %}

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS Red Team Expert）</strong></a><strong>！</strong></summary>

* 您在**网络安全公司**工作吗？ 您想在HackTricks中看到您的**公司广告**吗？ 或者您想访问**PEASS的最新版本或下载PDF格式的HackTricks**吗？ 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 发现我们的独家[NFTs收藏品**The PEASS Family**](https://opensea.io/collection/the-peass-family)
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
* **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter** 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**上关注**我。
* 通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享您的黑客技巧。

</details>
