dr0le

Extract Ole from XML

Mar 16th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #SYNTAX: python scriptname.py <xml file>
  2. #OUTPUT: out.bin
  3.  
  4. import xml.dom.minidom
  5. import binascii
  6. import zlib
  7. import sys
  8.  
  9. def get_ole(filepath):
  10.     f = open(filepath,'r')
  11.     data = f.read()
  12.     doc = xml.dom.minidom.parseString(data)
  13.     f.close()
  14.     for u in doc.getElementsByTagName('*'):
  15.         if u.firstChild and u.firstChild.nodeValue:
  16.             try:
  17.                 data = binascii.a2b_base64(u.firstChild.nodeValue)
  18.             except:
  19.                 data = ''
  20.         if data.startswith('ActiveMime'):
  21.             content = zlib.decompress(data[50:])
  22.     return content
  23.    
  24. if __name__ == '__main__':
  25.     if len(sys.argv) > 1:
  26.         print sys.argv[1]
  27.         g = get_ole(sys.argv[1])
  28.        
  29.         fh = file('out.bin','wb')
  30.         fh.write(g)
  31.         fh.close()
Advertisement
Add Comment
Please, Sign In to add comment