Skip to content

Instantly share code, notes, and snippets.

@9b
Created June 16, 2012 23:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 9b/2942799 to your computer and use it in GitHub Desktop.
Save 9b/2942799 to your computer and use it in GitHub Desktop.
PDF => XDP
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()
@ksoona
Copy link

ksoona commented Oct 30, 2014

slick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment