#!/usr/bin/python3

import argparse

key = 0x31, 0x62, 0x93, 0x64, 0x96, 0xc8, 0xf0, 0x40, 0x90, 0x28, 0x72, 0xbc, 0x49, 0xbe, 0x33, 0xdc, 0x56, 0xd0, 0x5e, 0x90, 0xc2, 0x10, 0x72, 0xd4, 0x14, 0x88, 0xfc, 0x94, 0xd6, 0x18, 0xd3, 0x2c, 0x85, 0x94, 0xb, 0x82, 0x9b, 0xe2, 0x29, 0xe2, 0x29, 0x70, 0x18, 0x80, 0xe8, 0x40, 0x84, 0xc8, 0xd7, 0x3e, 0xa5, 0x72, 0xa3, 0xd4, 0xa5, 0xc, 0x73, 0xe0, 0x38, 0x90, 0x49, 0xae, 0x13, 0x5c, 0xa6, 0xf0, 0xee, 0x30, 0x72, 0xc0, 0x28, 0x90, 0x8, 0x50, 0x98, 0xa, 0x63, 0xbc, 0x71, 0xd4, 0x37, 0x4, 0x3b, 0x72, 0x4a, 0x9c, 0xee, 0x5c, 0xce, 0x40, 0xe6, 0x40, 0x9a, 0x0, 0x50, 0xa0, 0xf6, 0x2c, 0x62, 0xf0, 0x68, 0xe0, 0x31, 0x62, 0x93, 0x64, 0x96, 0xc8, 0xf0, 0x40, 0x90, 0x28, 0x72, 0xbc, 0x49, 0xbe, 0x33, 0xdc, 0x56, 0xd0, 0x5e, 0x90, 0xc2, 0x10, 0x72, 0xd4, 0x14, 0x88, 0xfc, 0x94, 0xd6, 0x18, 0xd3, 0x2c, 0x85, 0x94, 0xb, 0x82, 0x9b, 0xe2, 0x29, 0xe2, 0x29, 0x70, 0x18, 0x80, 0xe8, 0x40, 0x84, 0xc8, 0xd7, 0x3e, 0xa5, 0x72, 0xa3, 0xd4, 0xa5, 0xc, 0x73, 0xe0, 0x38, 0x90, 0x49, 0xae, 0x13, 0x5c, 0xa6, 0xf0, 0xee, 0x30, 0x72, 0xc0, 0x28, 0x90, 0x8, 0x50, 0x98, 0xa, 0x63, 0xbc, 0x71, 0xd4, 0x37, 0x4, 0x3b, 0x72, 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, 0x88, 0xfc, 0x94, 0xd6, 0x18, 0xd3, 0x2c, 0x85, 0x94, 0xb, 0x82, 0x9b, 0xe2, 0x29, 0xe2, 0x29, 0x70, 0x18, 0x80, 0xe8, 0x40, 0x84, 0xc8, 0xd7, 0x3e, 0xa5, 0x72, 0xa3, 0xd4, 0xa5, 0xc, 0x73, 0xe0, 0x38, 0x90, 0x49, 0xae, 0x13, 0x5c, 0xa6, 0xf0, 0xee, 0x30, 0x72, 0xc0, 0x28, 0x90, 0x8, 0x50, 0x98, 0xa, 0x63, 0xbc, 0x71, 0xd4, 0x37, 0x4, 0x3b, 0x72, 0x4a, 0x9c, 0xee, 0x5c, 0xce, 0x40, 0xe6, 0x40, 0x9a, 0x0, 0x50, 0xa0, 0xf6, 0x2c, 0x62, 0xf0, 0x68, 0xe0, 0x31, 0x62, 0x93, 0x64

parser = argparse.ArgumentParser(description='Decrypt .crypted files by ransomware')

parser.add_argument('-s', '--source_file', action='store', nargs="+", required=True, help="Crypted files (source files list)")
args = parser.parse_args()

for source_file in args.source_file:
	bf = open(source_file, "rb")
	nf = open(source_file + ".recovered", "wb")

	i = 0
	print("byte# bad key new str(new)")
	read_bytes = 0
	while read_bytes < 1024:
		bad_byte = bf.read(1)
		new_byte = (key[i] ^ ord(bad_byte))
		print(str(read_bytes) + " " + hex(ord(bad_byte)) + " " + hex(key[i]) + " " + hex(new_byte) + " " + str(new_byte) + " ")
		nf.write(bytes([new_byte]))
		i = i + 1
		if i > 1024:
			i = 0
		read_bytes = read_bytes + 1

	while bad_byte:
		bad_byte = bf.read(1)
		nf.write(bad_byte)

nf.close()
bf.close()