Skip to content

Instantly share code, notes, and snippets.

@albertzsigovits
Created March 22, 2023 16:22
Show Gist options
  • Save albertzsigovits/5c919d0f614dea5c19f6a0d4319be370 to your computer and use it in GitHub Desktop.
Save albertzsigovits/5c919d0f614dea5c19f6a0d4319be370 to your computer and use it in GitHub Desktop.
Python general malware decryptor
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("file_path", help="path to input file")
args = parser.parse_args()
KEY_OFFSET = 0x5000
DATA_OFFSET = 0x15000
KEY_SIZE = 8
DATA_SIZE = 256
# Open the file and extract the key and data
with open(args.file_path, "rb") as f:
f.seek(KEY_OFFSET)
key = f.read(KEY_SIZE)
f.seek(DATA_OFFSET)
data = f.read(DATA_SIZE)
# Decrypt the data using the key
decrypted_data = bytearray(DATA_SIZE)
for i in range(DATA_SIZE):
decrypted_data[i] = data[i] ^ key[i % KEY_SIZE]
# Print the results
print("Decryption key:", key.hex())
print("Original data:", data.hex())
print("Decrypted data:", decrypted_data.hex())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment