# 111/TCP/UDP - Pentesting Portmapper {{#include ../banners/hacktricks-training.md}} ## Podstawowe informacje **Portmapper** to usługa, która jest wykorzystywana do mapowania portów usług sieciowych na numery programów **RPC** (Remote Procedure Call). Działa jako kluczowy komponent w **systemach opartych na Unix**, ułatwiając wymianę informacji między tymi systemami. **Port** związany z **Portmapper** jest często skanowany przez atakujących, ponieważ może ujawniać cenne informacje. Informacje te obejmują typ działającego **systemu operacyjnego Unix (OS)** oraz szczegóły dotyczące dostępnych usług w systemie. Dodatkowo, **Portmapper** jest powszechnie używany w połączeniu z **NFS (Network File System)**, **NIS (Network Information Service)** i innymi **usługami opartymi na RPC**, aby skutecznie zarządzać usługami sieciowymi. **Domyślny port:** 111/TCP/UDP, 32771 w Oracle Solaris ``` PORT STATE SERVICE 111/tcp open rpcbind ``` ## Enumeracja ``` rpcinfo irked.htb nmap -sSUC -p111 192.168.10.1 ``` Czasami nie daje to żadnych informacji, w innych przypadkach otrzymasz coś takiego: ![](<../images/image (553).png>) ### Shodan - `port:111 portmap` ## RPCBind + NFS Jeśli znajdziesz usługę NFS, to prawdopodobnie będziesz mógł wylistować i pobrać (a może nawet przesłać) pliki: ![](<../images/image (872).png>) Przeczytaj [2049 - Pentesting NFS service](nfs-service-pentesting.md), aby dowiedzieć się więcej o testowaniu tego protokołu. ## NIS Eksploracja **NIS** podatności obejmuje proces dwustopniowy, zaczynając od identyfikacji usługi `ypbind`. Kamieniem węgielnym tej eksploracji jest odkrycie **nazwa domeny NIS**, bez której postęp jest wstrzymany. ![](<../images/image (859).png>) Podróż eksploracyjna zaczyna się od zainstalowania niezbędnych pakietów (`apt-get install nis`). Kolejny krok wymaga użycia `ypwhich`, aby potwierdzić obecność serwera NIS, pingując go za pomocą nazwy domeny i adresu IP serwera, zapewniając, że te elementy są zanonimizowane dla bezpieczeństwa. Ostatni i kluczowy krok obejmuje polecenie `ypcat`, aby wydobyć wrażliwe dane, szczególnie zaszyfrowane hasła użytkowników. Te hashe, po złamaniu za pomocą narzędzi takich jak **John the Ripper**, ujawniają informacje o dostępie do systemu i uprawnieniach. ```bash # Install NIS tools apt-get install nis # Ping the NIS server to confirm its presence ypwhich -d # Extract user credentials ypcat –d –h passwd.byname ``` ### NIF files | **Master file** | **Map(s)** | **Notes** | | ---------------- | --------------------------- | --------------------------------- | | /etc/hosts | hosts.byname, hosts.byaddr | Zawiera nazwy hostów i szczegóły IP | | /etc/passwd | passwd.byname, passwd.byuid | Plik haseł użytkowników NIS | | /etc/group | group.byname, group.bygid | Plik grup NIS | | /usr/lib/aliases | mail.aliases | Szczegóły aliasów mailowych | ## RPC Users If you find the **rusersd** service listed like this: ![](<../images/image (1041).png>) You could enumerate users of the box. To learn how read [1026 - Pentesting Rsusersd](1026-pentesting-rusersd.md). ## Bypass Filtered Portmapper port When conducting a **nmap scan** and discovering open NFS ports with port 111 being filtered, direct exploitation of these ports is not feasible. However, by **simulating a portmapper service locally and creating a tunnel from your machine** to the target, exploitation becomes possible using standard tools. This technique allows for bypassing the filtered state of port 111, thus enabling access to NFS services. For detailed guidance on this method, refer to the article available at [this link](https://medium.com/@sebnemK/how-to-bypass-filtered-portmapper-port-111-27cee52416bc). ## Shodan - `Portmap` ## Labs to practice - Practice these techniques in the [**Irked HTB machine**](https://app.hackthebox.com/machines/Irked). ## 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} ``` {{#include ../banners/hacktricks-training.md}}