# 111/TCP/UDP - Pentesting Portmapper {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** ๐Ÿ’ฌ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ๐Ÿฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
{% embed url="https://websec.nl/" %} ## Basic Information **Portmapper**๋Š” ๋„คํŠธ์›Œํฌ ์„œ๋น„์Šค ํฌํŠธ๋ฅผ **RPC** (์›๊ฒฉ ํ”„๋กœ์‹œ์ € ํ˜ธ์ถœ) ํ”„๋กœ๊ทธ๋žจ ๋ฒˆํ˜ธ์— ๋งคํ•‘ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋Š” ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. ์ด๋Š” **์œ ๋‹‰์Šค ๊ธฐ๋ฐ˜ ์‹œ์Šคํ…œ**์—์„œ ์ค‘์š”ํ•œ ๊ตฌ์„ฑ ์š”์†Œ๋กœ ์ž‘์šฉํ•˜์—ฌ ์ด๋Ÿฌํ•œ ์‹œ์Šคํ…œ ๊ฐ„์˜ ์ •๋ณด ๊ตํ™˜์„ ์šฉ์ดํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. **Portmapper**์™€ ๊ด€๋ จ๋œ **ํฌํŠธ**๋Š” ๊ณต๊ฒฉ์ž์— ์˜ํ•ด ์ž์ฃผ ์Šค์บ”๋˜๋ฉฐ, ์ด๋Š” ๊ท€์ค‘ํ•œ ์ •๋ณด๋ฅผ ๋“œ๋Ÿฌ๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ •๋ณด์—๋Š” ์‹คํ–‰ ์ค‘์ธ **์œ ๋‹‰์Šค ์šด์˜ ์ฒด์ œ (OS)**์˜ ์œ ํ˜•๊ณผ ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋น„์Šค์— ๋Œ€ํ•œ ์„ธ๋ถ€ ์ •๋ณด๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ, **Portmapper**๋Š” **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 ``` ๊ฐ€๋” ์ •๋ณด๊ฐ€ ์ „ํ˜€ ์ œ๊ณต๋˜์ง€ ์•Š์ง€๋งŒ, ๋‹ค๋ฅธ ๊ฒฝ์šฐ์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ •๋ณด๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: ![](<../.gitbook/assets/image (553).png>) ### Shodan * `port:111 portmap` ## RPCBind + NFS ์„œ๋น„์Šค NFS๋ฅผ ์ฐพ์œผ๋ฉด ํŒŒ์ผ์„ ๋‚˜์—ดํ•˜๊ณ  ๋‹ค์šด๋กœ๋“œ(๊ทธ๋ฆฌ๊ณ  ์•„๋งˆ๋„ ์—…๋กœ๋“œ)ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค: ![](<../.gitbook/assets/image (872).png>) ์ด ํ”„๋กœํ† ์ฝœ์„ ํ…Œ์ŠคํŠธํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋” ์•Œ์•„๋ณด๋ ค๋ฉด [2049 - Pentesting NFS service](nfs-service-pentesting.md)๋ฅผ ์ฝ์–ด๋ณด์„ธ์š”. ## NIS **NIS** ์ทจ์•ฝ์ ์„ ํƒ์ƒ‰ํ•˜๋Š” ๊ฒƒ์€ `ypbind` ์„œ๋น„์Šค ์‹๋ณ„๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋‘ ๋‹จ๊ณ„ ํ”„๋กœ์„ธ์Šค๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค. ์ด ํƒ์ƒ‰์˜ ์ดˆ์„์€ **NIS ๋„๋ฉ”์ธ ์ด๋ฆ„**์„ ๋ฐœ๊ฒฌํ•˜๋Š” ๊ฒƒ์ด๋ฉฐ, ์ด ์—†์ด๋Š” ์ง„ํ–‰์ด ์ค‘๋‹จ๋ฉ๋‹ˆ๋‹ค. ![](<../.gitbook/assets/image (859).png>) ํƒ์ƒ‰ ์—ฌ์ •์€ ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ(`apt-get install nis`)์œผ๋กœ ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ๋‹จ๊ณ„๋Š” `ypwhich`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋„๋ฉ”์ธ ์ด๋ฆ„๊ณผ ์„œ๋ฒ„ IP๋กœ NIS ์„œ๋ฒ„์˜ ์กด์žฌ๋ฅผ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ์š”์†Œ๋“ค์€ ๋ณด์•ˆ์„ ์œ„ํ•ด ์ต๋ช…ํ™”๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์ด์ž ์ค‘์š”ํ•œ ๋‹จ๊ณ„๋Š” `ypcat` ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฏผ๊ฐํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”์ถœํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํŠนํžˆ ์•”ํ˜ธํ™”๋œ ์‚ฌ์šฉ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ํ•ด์‹œ๋Š” **John the Ripper**์™€ ๊ฐ™์€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ•ด๋…๋˜๋ฉด ์‹œ์Šคํ…œ ์ ‘๊ทผ ๋ฐ ๊ถŒํ•œ์— ๋Œ€ํ•œ ํ†ต์ฐฐ๋ ฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ```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 ํŒŒ์ผ | **๋งˆ์Šคํ„ฐ ํŒŒ์ผ** | **๋งต** | **๋…ธํŠธ** | | ---------------- | --------------------------- | --------------------------------- | | /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** ์„œ๋น„์Šค๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‚˜์—ด๋œ ๊ฒฝ์šฐ: ![](<../.gitbook/assets/image (1041).png>) ๋ฐ•์Šค์˜ ์‚ฌ์šฉ์ž ๋ชฉ๋ก์„ ์—ด๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐฉ๋ฒ•์„ ๋ฐฐ์šฐ๋ ค๋ฉด [1026 - Pentesting Rsusersd](1026-pentesting-rusersd.md)๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”. ## ํ•„ํ„ฐ๋ง๋œ ํฌํŠธ๋งคํผ ํฌํŠธ ์šฐํšŒ **nmap ์Šค์บ”**์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ํฌํŠธ 111์ด ํ•„ํ„ฐ๋ง๋œ ์—ด๋ฆฐ NFS ํฌํŠธ๋ฅผ ๋ฐœ๊ฒฌํ•  ๊ฒฝ์šฐ, ์ด๋Ÿฌํ•œ ํฌํŠธ๋ฅผ ์ง์ ‘์ ์œผ๋กœ ์•…์šฉํ•˜๋Š” ๊ฒƒ์€ ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ **๋กœ์ปฌ์—์„œ ํฌํŠธ๋งคํผ ์„œ๋น„์Šค๋ฅผ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ํ•˜๊ณ  ๊ท€ํ•˜์˜ ๋จธ์‹ ์—์„œ ๋Œ€์ƒ๊นŒ์ง€ ํ„ฐ๋„์„ ์ƒ์„ฑํ•จ์œผ๋กœ์จ** ํ‘œ์ค€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•…์šฉ์ด ๊ฐ€๋Šฅํ•ด์ง‘๋‹ˆ๋‹ค. ์ด ๊ธฐ์ˆ ์€ ํฌํŠธ 111์˜ ํ•„ํ„ฐ๋ง ์ƒํƒœ๋ฅผ ์šฐํšŒํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜์—ฌ NFS ์„œ๋น„์Šค์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์•ˆ๋‚ด๋Š” [์ด ๋งํฌ](https://medium.com/@sebnemK/how-to-bypass-filtered-portmapper-port-111-27cee52416bc)์—์„œ ํ™•์ธํ•˜์„ธ์š”. ## Shodan * `Portmap` ## ์—ฐ์Šตํ•  ์‹ค์Šต์‹ค * [**Irked HTB ๋จธ์‹ **](https://app.hackthebox.com/machines/Irked)์—์„œ ์ด๋Ÿฌํ•œ ๊ธฐ์ˆ ์„ ์—ฐ์Šตํ•˜์„ธ์š”.
{% 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} ``` {% hint style="success" %} AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
HackTricks ์ง€์›ํ•˜๊ธฐ * [**๊ตฌ๋… ๊ณ„ํš**](https://github.com/sponsors/carlospolop) ํ™•์ธํ•˜๊ธฐ! * **๐Ÿ’ฌ [**Discord ๊ทธ๋ฃน**](https://discord.gg/hRep4RUj7f) ๋˜๋Š” [**ํ…”๋ ˆ๊ทธ๋žจ ๊ทธ๋ฃน**](https://t.me/peass)์— ์ฐธ์—ฌํ•˜๊ฑฐ๋‚˜ **Twitter** ๐Ÿฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**๋ฅผ ํŒ”๋กœ์šฐํ•˜์„ธ์š”.** * **[**HackTricks**](https://github.com/carlospolop/hacktricks) ๋ฐ [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) ๊นƒํ—ˆ๋ธŒ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์— PR์„ ์ œ์ถœํ•˜์—ฌ ํ•ดํ‚น ํŒ์„ ๊ณต์œ ํ•˜์„ธ์š”.**
{% endhint %}