# 111/TCP/UDP - Pentesting Portmapper

<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的其他方式：

* 如果您想在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)收藏品
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

<figure><img src="https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-c3347d98363eddbac80c10d95a19c2559b0161d2%2FWebSec_1500x400_10fps_21sn_lightoptimized_v2.gif?alt=media" alt=""><figcaption></figcaption></figure>

{% embed url="<https://websec.nl/>" %}

## 基本信息

**端口映射器**是一种用于将网络服务端口映射到**RPC**（远程过程调用）程序编号的服务。它是**基于Unix系统**中的一个关键组件，促进这些系统之间的信息交换。与**端口映射器**相关联的**端口**经常受到攻击者的扫描，因为它可以揭示有价值的信息。这些信息包括正在运行的**Unix操作系统（OS）的类型以及系统上可用服务的详细信息。此外，端口映射器通常与NFS（网络文件系统）**、**NIS（网络信息服务）和其他基于RPC的服务**一起使用，以有效管理网络服务。

**默认端口：** 111/TCP/UDP，Oracle Solaris中为32771

```
PORT    STATE SERVICE
111/tcp open  rpcbind
```

## 枚举

```
rpcinfo irked.htb
nmap -sSUC -p111 192.168.10.1
```

### Shodan

* `port:111 portmap`

## RPCBind + NFS

如果发现了NFS服务，那么很可能您将能够列出、下载（也许还可以上传）文件：

![](https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-1493a89e0cd75850caba2e734baf9f6fc37f3292%2Fimage%20\(869\).png?alt=media)

阅读[2049 - NFS服务渗透测试](https://hacktricks.xsx.tw/network-services-pentesting/nfs-service-pentesting)以了解如何测试此协议。

## NIS

探索**NIS**漏洞涉及一个两步过程，首先是识别服务`ypbind`。这一探索的基石是揭示**NIS域名**，没有它，进展将停滞不前。

![](https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-bcf6ea73f00ce393ab55f1acd1df7eb84018355a%2Fimage%20\(856\).png?alt=media)

探索之旅始于安装必要的软件包（`apt-get install nis`）。随后的步骤需要使用`ypwhich`通过域名和服务器IP对NIS服务器进行ping测试，确保这些元素经过匿名化以确保安全。

最后、也是至关重要的一步是使用`ypcat`命令提取敏感数据，特别是加密的用户密码。这些哈希值一旦使用**John the Ripper**等工具破解，将揭示有关系统访问和权限的见解。

```bash
# Install NIS tools
apt-get install nis
# Ping the NIS server to confirm its presence
ypwhich -d <domain-name> <server-ip>
# Extract user credentials
ypcat –d <domain-name> –h <server-ip> passwd.byname
```

### NIF 文件

| **主文件**          | **映射**                      | **备注**       |
| ---------------- | --------------------------- | ------------ |
| /etc/hosts       | hosts.byname, hosts.byaddr  | 包含主机名和IP详细信息 |
| /etc/passwd      | passwd.byname, passwd.byuid | NIS用户密码文件    |
| /etc/group       | group.byname, group.bygid   | NIS组文件       |
| /usr/lib/aliases | mail.aliases                | 详细的邮件别名      |

## RPC 用户

如果发现列出了 **rusersd** 服务，如下所示：

![](https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-0c184fa508a057c5b4b34a85846d056b7bf1b9b9%2Fimage%20\(1038\).png?alt=media)

您可以枚举该主机的用户。要了解如何操作，请阅读 [1026 - Pentesting Rsusersd](https://hacktricks.xsx.tw/network-services-pentesting/1026-pentesting-rusersd)。

## 绕过被过滤的 Portmapper 端口

在进行 **nmap 扫描** 时，发现开放的 NFS 端口中的端口 111 被过滤，直接利用这些端口是不可行的。然而，通过**在本地模拟一个 portmapper 服务，并在您的机器和目标之间创建隧道**，使用标准工具就可以进行利用。这种技术允许绕过端口 111 的过滤状态，从而访问 NFS 服务。有关此方法的详细指导，请参考 [此链接](https://medium.com/@sebnemK/how-to-bypass-filtered-portmapper-port-111-27cee52416bc) 上提供的文章。

## Shodan

* `Portmap`

## 实践实验室

* 在 [**Irked HTB 机器**](https://app.hackthebox.com/machines/Irked) 中练习这些技术。

<figure><img src="https://615200056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1DLBZdNLkY4FUHtMnjPr%2Fuploads%2Fgit-blob-c3347d98363eddbac80c10d95a19c2559b0161d2%2FWebSec_1500x400_10fps_21sn_lightoptimized_v2.gif?alt=media" alt=""><figcaption></figcaption></figure>

{% embed url="<https://websec.nl/>" %}

## HackTricks 自动命令

```
Protocol_Name: Portmapper    #Protocol Abbreviation if there is one.
Port_Number:  43     #Comma separated if there is more than one.
Protocol_Description: PM or RPCBind        #Protocol Abbreviation Spelled out

Entry_1:
Name: Notes
Description: Notes for PortMapper
Note: |
Portmapper is a service that is utilized for mapping network service ports to RPC (Remote Procedure Call) program numbers. It acts as a critical component in Unix-based systems, facilitating the exchange of information between these systems. The port associated with Portmapper is frequently scanned by attackers as it can reveal valuable information. This information includes the type of Unix Operating System (OS) running and details about the services that are available on the system. Additionally, Portmapper is commonly used in conjunction with NFS (Network File System), NIS (Network Information Service), and other RPC-based services to manage network services effectively.

https://book.hacktricks.xyz/pentesting/pentesting-rpcbind

Entry_2:
Name: rpc info
Description: May give netstat-type info
Command: whois -h {IP} -p 43 {Domain_Name} && echo {Domain_Name} | nc -vn {IP} 43

Entry_3:
Name: nmap
Description: May give netstat-type info
Command: nmap -sSUC -p 111 {IP}
```

<details>

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

其他支持HackTricks的方式：

* 如果您想看到您的**公司在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)
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>
