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)**의 유형과 시스템에서 사용 가능한 서비스에 대한 세부 정보가 포함됩니다. 또한 PortmapperNFS (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

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 지원하기