3615 Incident (3)

Catégorie: Forensique

Points: 186

Description: Une victime de plus tombée sous le coup d’un rançongiciel. Le paiement de la rançon n’est pas envisagée vu le montant demandé. Vous êtes appelé pour essayer de restaurer les fichiers chiffrés. Déchiffrez le fichier "flag.docx" ci-joint!

Fichiers: data

TL;DR

On déchiffre le fichier grace à la cle retrouvée à l'étape 2.

Méthodologie

On a un fichier chiffré par le rançongiciel, la cle de déchiffrement et on connais la méthode de chiffrement qui est l'AES_CTR grace au code du rançongiciel.

Agrémenté de quelques Google dorks on trouve facilement un script pour déchiffrer un fichier grace à python.

>_ cat decrypt.py
#!/usr/bin/env python3

import binascii
import os
from Crypto.Cipher import AES
from Crypto.Util import Counter

def int_of_string(s):
    return int(binascii.hexlify(s), 16)

def encrypt_message(key, plaintext):
    iv = os.urandom(16)
    ctr = Counter.new(128, initial_value=int_of_string(iv))
    aes = AES.new(key, AES.MODE_CTR, counter=ctr)
    return iv + aes.encrypt(plaintext)

def decrypt_message(key, ciphertext):
    iv = ciphertext[:16]
    ctr = Counter.new(128, initial_value=int_of_string(iv))
    aes = AES.new(key, AES.MODE_CTR, counter=ctr)
    return aes.decrypt(ciphertext[16:])

if __name__ == "__main__":
    file = open("data", 'rb')
    data = file.read()
    out = decrypt_message("95511870061fb3a2899aa6b2dc9838aa", data)

    o = open("decrypted", 'wb')
    o.write(out)
    o.close()

On lance le script:

>_ ./decrypt.py

>_ file decrypted
decrypted: Microsoft Word 2007+

On a bien un docx !

docx_flag

FLAG_IS:

ECSC{M4ud1t3_C4mp4gn3_2_r4NC0nG1c13L}