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 ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ธฐ๋ณธ ์ ๋ณด
Portmapper๋ ๋คํธ์ํฌ ์๋น์ค ํฌํธ๋ฅผ RPC (Remote Procedure Call) ํ๋ก๊ทธ๋จ ๋ฒํธ์ ๋งคํํ๋ ๋ฐ ์ฌ์ฉ๋๋ ์๋น์ค์ ๋๋ค. ์ด๋ Unix-based systems์์ ์ค์ํ ๊ตฌ์ฑ ์์๋ก ์์ฉํ๋ฉฐ, ์ด๋ฌํ ์์คํ ๊ฐ์ ์ ๋ณด ๊ตํ์ ์ฉ์ดํ๊ฒ ํฉ๋๋ค. Portmapper์ ์ฐ๊ฒฐ๋ ํฌํธ๋ ๊ณต๊ฒฉ์๋ค์ด ์์ฃผ ์ค์บํ๋๋ฐ, ์ด๋ ์ ์ฉํ ์ ๋ณด๋ฅผ ๋๋ฌ๋ผ ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค. ์ด ์ ๋ณด์๋ ์คํ ์ค์ธ **Unix Operating System (OS)**์ ์ ํ๊ณผ ์์คํ ์์ ์ฌ์ฉ ๊ฐ๋ฅํ ์๋น์ค์ ๋ํ ์ธ๋ถ ์ ๋ณด๊ฐ ํฌํจ๋ฉ๋๋ค. ๋ํ Portmapper๋ NFS (Network File System), NIS (Network Information Service) ๋ฐ ๊ธฐํ RPC-based services์ ํจ๊ป ๋คํธ์ํฌ ์๋น์ค๋ฅผ ํจ๊ณผ์ ์ผ๋ก ๊ด๋ฆฌํ๋ ๋ฐ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค.
๊ธฐ๋ณธ ํฌํธ: 111/TCP/UDP, 32771 in Oracle Solaris
PORT STATE SERVICE
111/tcp open rpcbind
์ด๊ฑฐ
rpcinfo irked.htb
nmap -sSUC -p111 192.168.10.1
๊ฐ๋ ์๋ฌด ์ ๋ณด๋ ์ ๊ณตํ์ง ์์ ๋๊ฐ ์๊ณ , ๋ค๋ฅธ ๊ฒฝ์ฐ์๋ ๋ค์๊ณผ ๊ฐ์ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ต๋๋ค:
.png)
๊ณ ๊ธ rpcinfo ์ฌ์ฉ๋ฒ
rpcinfo -T udp -p <target>๋ฅผ ์ฌ์ฉํด TCP/111์ด ํํฐ๋ง๋์ด ์์ด๋ UDP ํ๋ก๊ทธ๋จ ๋ชฉ๋ก์ ๊ฐ์ ธ์ค๊ณ , ์ฆ์ showmount -e <target>๋ฅผ ์คํํด rpcbind๋ฅผ ํตํด ๋ฑ๋ก๋ ๋ชจ๋๊ฐ ์ฝ์ ์ ์๋ NFS ๋ด๋ณด๋ด๊ธฐ๋ฅผ ํ์ธํ์ธ์.
rpcinfo -T udp -p 10.10.10.10
showmount -e 10.10.10.10
Exhaustive mapping with Nmap NSE
๊ธฐ๋ณธ ์ค์บ์ nmap --script=rpcinfo,rpc-grind -p111 <target> ๋ฅผ ๋ณํํด RPC ํ๋ก๊ทธ๋จ ๋ฒํธ๋ฅผ brute-forceํ์ธ์. rpc-grind ๋ null ํธ์ถ๋ก portmapper ๋ฅผ ๊ฐํํ๋ฉฐ nmap-rpc ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ํํด ์๊ฒฉ ๋ฐ๋ชฌ์ด โcanโt support versionโ์ผ๋ก ์๋ตํ ๋๋ง๋ค ์ง์๋๋ ๋ฒ์ ์ ์ถ์ถํฉ๋๋ค. ์ด๋ ์ข
์ข
rusersd, rquotad ๋๋ ์ปค์คํ
๋ฐ๋ชฌ์ฒ๋ผ ์๋ฐํ๊ฒ ๋ฑ๋ก๋ ์๋น์ค๋ฅผ ๋๋ฌ๋
๋๋ค. --script-args 'rpc-grind.threads=8' ๋ก ๋ฉํฐ์ค๋ ๋ฉ์ ์ฌ์ฉํ๋ฉด ํฐ ํ๊ฒ์ ๋น ๋ฅด๊ฒ ์ฒ๋ฆฌํ ์ ์๊ณ , ๋๋ฐ ์คํฌ๋ฆฝํธ์ธ rpcinfo ๋ ์ฌ๋์ด ์ฝ์ ์ ์๋ ํ
์ด๋ธ์ ์ถ๋ ฅํด ํธ์คํธ ๊ธฐ์ค์ ๊ณผ ๋น๊ต(diff)ํ๊ธฐ ์ข์ต๋๋ค.
Shodan
port:111 portmap
RPCBind + NFS
์๋น์ค๊ฐ NFS๋ก ํ์ธ๋๋ฉด ํ์ผ์ ๋์ดํ๊ณ ๋ค์ด๋ก๋(๊ทธ๋ฆฌ๊ณ ๊ฒฝ์ฐ์ ๋ฐ๋ผ ์ ๋ก๋)ํ ์ ์์ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค:
.png)
Read 2049 - Pentesting NFS service to learn more about how to test this protocol.
NIS
Exploring NIS vulnerabilities involves a two-step process, starting with the identification of the service ypbind. The cornerstone of this exploration is uncovering the NIS domain name, without which progress is halted.
.png)
ํ์์ ํ์ํ ํจํค์ง ์ค์น(apt-get install nis)๋ก ์์ํฉ๋๋ค. ๋ค์ ๋จ๊ณ๋ ypwhich ๋ฅผ ์ฌ์ฉํด ๋๋ฉ์ธ ์ด๋ฆ๊ณผ ์๋ฒ 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 ํ์ผ
| ๋ง์คํฐ ํ์ผ | ๋งต(s) | ์ค๋ช |
|---|---|---|
| /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 Users
๋ค์๊ณผ ๊ฐ์ด rusersd ์๋น์ค๊ฐ ๋์ด๋์ด ์๋ค๋ฉด:
.png)
๋ฐ์ค์ ์ฌ์ฉ์๋ฅผ ์ด๊ฑฐํ ์ ์์ต๋๋ค. ๋ฐฉ๋ฒ์ 1026 - Pentesting Rsusersd๋ฅผ ์ฝ์ด๋ณด์ธ์.
Bypass Filtered Portmapper port
์๋ฒ์ ๋ํ nmap scan ์ํ ์ NFS ํฌํธ๊ฐ ์ด๋ ค ์๊ณ ํฌํธ 111์ด filtered ์ํ์ธ ๊ฒฝ์ฐ, ์ด๋ฌํ ํฌํธ๋ค์ ์ง์ ์ ์ผ๋ก ์ต์คํ๋ก์ํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํฉ๋๋ค. ํ์ง๋ง ๋ก์ปฌ์์ portmapper ์๋น์ค๋ฅผ ์๋ฎฌ๋ ์ด์ ํ๊ณ ์์ ์ ๋จธ์ ์์ ๋์๊น์ง tunnel์ ์์ฑํ๋ฉด, ํ์ค ๋๊ตฌ๋ค์ ์ฌ์ฉํด ์ต์คํ๋ก์์ด ๊ฐ๋ฅํด์ง๋๋ค. ์ด ๊ธฐ๋ฒ์ ํฌํธ 111์ filtered ์ํ๋ฅผ ์ฐํํ์ฌ NFS ์๋น์ค์ ์ ๊ทผํ ์ ์๊ฒ ํฉ๋๋ค. ์์ธํ ์๋ด๋ this link์ ์ฐธ๊ณ ํ์ธ์.
์ฐ์ต์ฉ Labs
- ์ด ๊ธฐ์ ๋ค์ Irked HTB machine์์ ์ฐ์ตํ์ธ์.
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.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 ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


