Skip to content

Instantly share code, notes, and snippets.

@MasterAM MasterAM/
Created May 12, 2015

What would you like to do?
This file is meant to unpack Israeli court attachments embedded in signature files. I got one of those files without the original file as the only attachment, while the email message stated there were 2 attachments. I don't know the general structure of those files since I only had this instance to deal with, but I hope someone else finds it use…
import base64
import xml.etree.ElementTree as ET
import sys
def decode(infile, outfile):
tree = ET.parse(infile)
xmlns = '{}'
b64 = tree.find("./SignaturePackage/{0}Signature/{0}Object/DocumentContent".format(xmlns)).text
txt = base64.b64decode(b64)
with open(outfile, 'bw+') as f:
if __name__ == "__main__":
if len(sys.argv) < 2:
print('usage: python <input_filename>')
infile = sys.argv[1]
outfile = 'out.pdf'
decode(infile, outfile)
print('Done. Result saved to {0}'.format(outfile))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.