Overview
Ransomware is a common theme in CTF forensics and reverse‑engineering challenges. This lesson walks you through static and dynamic analysis of a typical ransomware sample, shows how to extract IOCs, and demonstrates basic decryption when weak keys are used. Practice on an isolated REMnux lab and document findings in a write‑up.
Static Analysis Setup
- Snapshot your analysis VM (Ubuntu 22.04 + REMnux).
- Gather file metadata (
file,pecheck). - Extract strings for URLs, mutex names, and API calls (
CreateFile,CryptEncrypt). - Write a YARA rule that matches the sample’s unique strings.
Dynamic Analysis (Sandbox)
- Launch the sample in Cuckoo sandbox.
- Capture traffic with Wireshark; look for HTTP POSTs to a C2 server.
- Monitor file‑system changes – the ransomware creates a new extension (e.g.,
.locked). - Extract the mutex to confirm single‑instance execution.
Identifying Encryption Logic
- Open the PE in IDA or Ghidra.
- Locate calls to
CryptAcquireContext,CryptGenKey,CryptEncrypt. - If the AES key is hard‑coded in the
.datasection, you can often recover it with a hex editor.
Decryption & Recovery
- Hard‑coded AES key: extract the 128‑bit key, then use
openssl aes-128-cbc -d -K <key> -iv <iv> -in encrypted_file -out recovered_file. - Weak RSA key (512‑bit): factor the modulus with RsaCtfTool to obtain the private exponent.
- Document IOCs, C2 domain, and decryption commands in a Markdown report.
Pakistan‑Specific Scenario
A Karachi retailer was hit by ransomware demanding payment via easypaisa, encrypting invoices on a NAS. By analysing a similar sample you can extract the easypaisa wallet ID and report it to NCCIA 1799. Use the workflow to generate a Sigma detection rule and a YARA signature for your team.
Takeaway
Spin up a REMnux VM, run static and dynamic analysis, extract C2 IOCs, and if the key is weak, decrypt a test file today. This skill set applies directly to CTF forensics, incident response, and real‑world ransomware investigations.
