Skip to content

Instantly share code, notes, and snippets.

@sukhodolin
Created September 21, 2015 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sukhodolin/8d01e31ef8aff74ba45c to your computer and use it in GitHub Desktop.
Save sukhodolin/8d01e31ef8aff74ba45c to your computer and use it in GitHub Desktop.
import sys
fin = open(sys.argv[1], 'rb')
fout = open(sys.argv[1] + '.decrypted', 'wb')
fin.seek(256)
dataEnc = fin.read()
key = -1
for b in range(0, 256):
dataDec = ''
seed = 0
for ch in dataEnc:
dataDec += chr((b ^ ord(ch)) ^ seed)
seed = ord(ch)
if len(dataDec) > 500:
break
if dataDec.find("Trace started") > 0:
key = b
break
if key >= 0:
print "The key is: {}".format(key)
dataDec = bytearray(len(dataEnc))
seed = 0
for ch in range(0, len(dataEnc)):
dataDec[ch] = chr((key ^ ord(dataEnc[ch])) ^ seed)
seed = ord(dataEnc[ch])
fout.write(dataDec)
else:
print "The key can not be found!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment