Skip to content

Instantly share code, notes, and snippets.

@nopslider
Created April 26, 2017 17:20
Show Gist options
  • Save nopslider/f9ba790dc2f4a0050e2e430a2de081fd to your computer and use it in GitHub Desktop.
Save nopslider/f9ba790dc2f4a0050e2e430a2de081fd to your computer and use it in GitHub Desktop.
Replace a beacon in a Word file (.doc)
#python3 wordmagicmarker.py test.doc [email protected] > test1.doc
import sys
import hashlib
marker = "A"*32
marker8 = bytes(marker,'utf-8')
marker16 = bytes(marker,'utf-16-be')
email = sys.argv[2].encode('utf-8')
ehash = hashlib.md5(email).hexdigest()
ehash8 = bytes(ehash,'utf-8')
ehash16 = bytes(ehash,'utf-16-be')
file = open(sys.argv[1], 'rb').read()
file = file.replace(marker8,ehash8)
file = file.replace(marker16,ehash16)
sys.stdout.buffer.write(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment