Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from loguru import logger
- def Decrypt(key,data):
- dataList = []
- for x in data:
- #
- dataList.append((x) ^ int(key,0))
- dataL = (''.join('{:02x}'.format(x) for x in dataList))
- #print(dataL[521849])
- return bytearray.fromhex(dataL)
- listOfVals = {}
- with open(sys.argv[1],"rb") as f:
- counter = 0
- file1 = f.read()
- while counter < 0x100:
- count = file1.count(counter)
- try:
- if sys.argv[2] == "logging":
- print(f"{count} occurrences found of {hex(counter)}")
- except:
- a = 0
- listOfVals[hex(counter)] = count
- counter += 1
- output = max(listOfVals,key=listOfVals.get)
- print(output)
- logger.info(f"Possible Hex Key: {output}")
- inp = input("Decrypt with hex key? (Y/N) ")
- if inp == "Y":
- outData = Decrypt(output,file1)
- file2 = open("{0}_decrypted".format(sys.argv[1]),"w+b")
- file2.write(outData)
- file2.close()
- elif inp == "N":
- logger.error("Ok. Exiting.")
- sys.exit()
- else:
- logger.error("Incorrect arg supplied.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement