Untitled
unknown
plain_text
a year ago
2.5 kB
8
Indexable
from Crypto.Cipher import AES, Blowfish
from Crypto.Util.Padding import unpad
from Crypto.Random import get_random_bytes
# Fonction de mélange inverse (si applicable)
def non_linear_mixer_reverse(data):
mixed_data = bytearray()
for i in range(len(data)):
mixed_data.append((data[i] ^ 0x5A) // (i + 1) % 256)
return mixed_data
# Fonction pour extraire la clé dynamique (basée sur le contenu du fichier)
def generate_dynamic_key(file_data):
# Dérivation de la clé à partir du hachage SHA-256 du fichier avec un sel
salt = get_random_bytes(16)
dynamic_key = scrypt(file_data, salt, dklen=32, N=2**14, r=8, p=1)
return dynamic_key
# Fonction pour déchiffrer les données
def decrypt_data(encrypted_data, key):
# Extraction des IVs
blowfish_iv = encrypted_data[:8]
aes_iv = encrypted_data[8 + len(encrypted_data)//2 : 8 + len(encrypted_data)//2 + AES.block_size]
# Séparation des données chiffrées
encrypted_part1 = encrypted_data[8 : 8 + len(encrypted_data)//2]
encrypted_part2 = encrypted_data[8 + len(encrypted_data)//2 + AES.block_size :]
# Décryptage Blowfish de la première moitié
cipher_blowfish = Blowfish.new(key, Blowfish.MODE_CBC, blowfish_iv)
decrypted_part1 = unpad(cipher_blowfish.decrypt(encrypted_part1), Blowfish.block_size)
# Décryptage AES de la deuxième moitié
cipher_aes = AES.new(key, AES.MODE_CBC, aes_iv)
decrypted_part2 = unpad(cipher_aes.decrypt(encrypted_part2), AES.block_size)
# Combiner les deux parties décryptées
decrypted_data = decrypted_part1 + decrypted_part2
return decrypted_data
# Fonction pour déchiffrer le fichier
def decrypt_exe(input_file, output_file):
# Lire le fichier crypté
with open(input_file, 'rb') as f:
encrypted_data = f.read()
# Générer la clé dynamique à partir du fichier crypté
dynamic_key = generate_dynamic_key(encrypted_data)
# Décryptage des données
decrypted_data = decrypt_data(encrypted_data, dynamic_key)
# Préparation des données à exécuter (c'est-à-dire le fichier décrypté)
with open(output_file, 'wb') as f:
f.write(decrypted_data)
print(f"Fichier '{input_file}' décrypté avec succès sous '{output_file}'.")
# Exemple d'utilisation
input_encrypted_exe = 'mon_application_encrypted.exe' # Le fichier crypté à déchiffrer
output_decrypted_exe = 'mon_application_decrypted.exe' # Nom du fichier décrypté
decrypt_exe(input_encrypted_exe, output_decrypted_exe)Editor is loading...
Leave a Comment