Created
September 21, 2015 01:04
-
-
Save sukhodolin/8d01e31ef8aff74ba45c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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