Skip to content

Instantly share code, notes, and snippets.

@ksoona
Forked from 9b/pdf2xdp.py
Last active August 29, 2015 14:08
Show Gist options
  • Save ksoona/8c0525bd5a45fa92b3e7 to your computer and use it in GitHub Desktop.
Save ksoona/8c0525bd5a45fa92b3e7 to your computer and use it in GitHub Desktop.
import base64
import sys
def main():
if len(sys.argv) < 3:
sys.exit('Usage (2 arguments): %s "%s" %s' % (sys.argv[0],"malicious file","outfile"))
else:
f = open(sys.argv[1],"rb")
con = f.read()
f.close()
start = '<?xml version="1.0"?><?xfa ?><xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"><pdf xmlns="http://ns.adobe.com/xdp/pdf/"><document><chunk>'
encoded = base64.b64encode(con)
end = "</chunk></document></pdf></xdp:xdp>"
f = open(sys.argv[2],"wb")
f.write(start + encoded + end)
f.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment