111/TCP/UDP - Pentesting Portmapper

Tip

学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE) 学习和实践 Azure 黑客技术:HackTricks Training Azure Red Team Expert (AzRTE)

支持 HackTricks

基本信息

Portmapper 是一个用于将网络服务端口映射到 RPC (Remote Procedure Call) 程序编号的服务。它在基于 Unix 的系统中充当关键组件,促进这些系统之间的信息交换。与 Portmapper 相关的端口经常被攻击者扫描,因为它可能泄露有价值的信息。此类信息包括正在运行的 Unix Operating System (OS) 类型以及系统上可用服务的详细信息。此外,Portmapper 常与 NFS (Network File System)NIS (Network Information Service) 以及其他基于 RPC 的服务一起使用,以有效管理网络服务。

默认端口: 111/TCP/UDP,Oracle Solaris 中为 32771

PORT    STATE SERVICE
111/tcp open  rpcbind

枚举

rpcinfo irked.htb
nmap -sSUC -p111 192.168.10.1

有时它不会提供任何信息,在其他情况下你会得到类似下面的内容:

高级 rpcinfo 用法

使用 rpcinfo -T udp -p <target> 获取 UDP 程序列表,即使 TCP/111 被过滤;然后立即运行 showmount -e <target> 来发现通过 rpcbind 注册的对所有人可读的 NFS 导出。

rpcinfo -T udp -p 10.10.10.10
showmount -e 10.10.10.10

使用 Nmap NSE 进行详尽映射

将经典扫描与 nmap --script=rpcinfo,rpc-grind -p111 <target> 结合使用,以暴力枚举 RPC 程序编号。rpc-grind 通过对 portmapper 发起 null 调用遍历 nmap-rpc 数据库,每当远程守护进程返回 “can’t support version” 时就提取被支持的版本,这常常会暴露像 rusersd、rquotad 或自定义守护进程等静默注册的服务。通过 --script-args 'rpc-grind.threads=8' 启用多线程可加快大范围目标的速度,而配套的 rpcinfo 脚本会打印可读性强的表格,便于与主机基线进行差异比对。

Shodan

  • port:111 portmap

RPCBind + NFS

If you find the service NFS then probably you will be able to list and download(and maybe upload) files:

Read 2049 - Pentesting NFS service to learn more about how to test this protocol.

NIS

探索 NIS 漏洞涉及两步流程,首先识别服务 ypbind。这一过程的关键是发现 NIS 域名,没有它就无法继续。

探索过程从安装必要软件包 (apt-get install nis) 开始。随后使用 ypwhich 和 NIS 域名及服务器 IP 来确认 NIS 服务器是否存在(为安全起见,这些信息应做匿名处理)。

最后也是关键的一步是使用 ypcat 提取敏感数据,特别是加密的用户密码。这些哈希一旦用 John the Ripper 等工具破解,就能揭示有关系统访问和权限的情报。

# 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 文件

主文件Map(s)说明
/etc/hostshosts.byname, hosts.byaddr包含主机名和 IP 详细信息
/etc/passwdpasswd.byname, passwd.byuidNIS 用户密码文件
/etc/groupgroup.byname, group.bygidNIS 组文件
/usr/lib/aliasesmail.aliases邮件别名详情

RPC 用户

如果发现像下面这样列出的 rusersd 服务:

你可以枚举该主机的用户。想了解如何操作,请阅读 1026 - Pentesting Rsusersd.

Bypass Filtered Portmapper port

在进行 nmap scan 并发现开放的 NFS 端口但 port 111 被过滤时,无法直接利用这些端口。然而,通过 在本地模拟一个 portmapper 服务并从你的机器到目标创建一个隧道,可以使用常用工具进行利用。该技术允许绕过 port 111 的过滤状态,从而访问 NFS 服务。有关此方法的详细指南,请参考文章:this link.

Labs to practice

HackTricks Automatic Commands

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.wiki/en/network-services-pentesting/pentesting-rpcbind.html

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}

参考资料

Tip

学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE) 学习和实践 Azure 黑客技术:HackTricks Training Azure Red Team Expert (AzRTE)

支持 HackTricks