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-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

๊ฐ€๋” ์•„๋ฌด ์ •๋ณด๋„ ์ œ๊ณตํ•˜์ง€ ์•Š์„ ๋•Œ๊ฐ€ ์žˆ๊ณ , ๋‹ค๋ฅธ ๊ฒฝ์šฐ์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

๊ณ ๊ธ‰ 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๋กœ ํ™•์ธ๋˜๋ฉด ํŒŒ์ผ์„ ๋‚˜์—ดํ•˜๊ณ  ๋‹ค์šด๋กœ๋“œ(๊ทธ๋ฆฌ๊ณ  ๊ฒฝ์šฐ์— ๋”ฐ๋ผ ์—…๋กœ๋“œ)ํ•  ์ˆ˜ ์žˆ์„ ๊ฐ€๋Šฅ์„ฑ์ด ํฝ๋‹ˆ๋‹ค:

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.

ํƒ์ƒ‰์€ ํ•„์š”ํ•œ ํŒจํ‚ค์ง€ ์„ค์น˜(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/hostshosts.byname, hosts.byaddrํ˜ธ์ŠคํŠธ๋ช…๊ณผ IP ์„ธ๋ถ€ ์ •๋ณด ํฌํ•จ
/etc/passwdpasswd.byname, passwd.byuidNIS ์‚ฌ์šฉ์ž ์•”ํ˜ธ ํŒŒ์ผ
/etc/groupgroup.byname, group.bygidNIS ๊ทธ๋ฃน ํŒŒ์ผ
/usr/lib/aliasesmail.aliases๋ฉ”์ผ ๋ณ„์นญ ์ •๋ณด

RPC Users

๋‹ค์Œ๊ณผ ๊ฐ™์ด rusersd ์„œ๋น„์Šค๊ฐ€ ๋‚˜์—ด๋˜์–ด ์žˆ๋‹ค๋ฉด:

๋ฐ•์Šค์˜ ์‚ฌ์šฉ์ž๋ฅผ ์—ด๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐฉ๋ฒ•์€ 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 ์ง€์›ํ•˜๊ธฐ