Back to Blog
Write-up DFIR Challenge Series / Challenge 04
DFIR Write-up

Two Disk Images.
Five Flags.
Nothing Stays Deleted.

How I mounted a suspect USB image, carved a hidden PNG from raw sectors, recovered deleted credentials, and reconstructed an attacker's data theft plan from a wiped disk.


Challenge 04: Disk Forensics
Category Digital Forensics & IR
Difficulty Medium
Date 30 Mar 2026
Status Completed
Flags 5 / 5 captured

The Scenario

Two disk images were recovered from a suspect workstation after the attack timeline established in Challenges 01–03. The images were handed to forensic analysis to determine what data was stolen, whether anti-forensics were attempted, and what the attacker was planning next.

Endpoint logs tell you what commands ran. Network traffic tells you what left the wire. Disk forensics tells you what the attacker touched, hid, and tried to destroy.

File Size Description
suspicious.dd32 MBUSB drive image recovered from the suspect workstation
deleted-files.img16 MBDisk image containing deliberately deleted files

Tools Used

Tool Purpose
mountMount disk images read-only for filesystem traversal
ls -laRRecursive listing including hidden files and directories
catRead script and file contents from mounted image
foremostFile carving to recover image files from raw disk sectors
base64Encode binary files for transfer from headless lab environment
stringsExtract human-readable content from raw disk images
Flag 4.1 Hidden Stolen Data File

Approach

The first task was to find evidence of data theft on the USB image. Mounting the image read-only and performing a recursive listing was the starting point. A standard ls would miss hidden directories. The -a flag is required to reveal entries prefixed with a dot.

The image was mounted to /mnt and a recursive listing with all flags was run. A hidden directory .secret was discovered inside /mnt/documents/, invisible without the -a flag. Inside it was stolen-data.csv.

Hidden .secret directory revealed by ls -laR Flag 4.1 submitted
sudo mount -o ro,loop suspicious.dd /mnt
ls -laR /mnt
/mnt/documents/.secret:
total 12
drwxr-xr-x  2 root root 4096 Nov 10 03:30 .
drwxr-xr-x  3 root root 4096 Nov 10 03:28 ..
-rw-r--r--  1 root root  512 Nov 10 03:30 stolen-data.csv
Linux hides files and directories prefixed with a dot from standard listings. Forensic examination always requires -a and a recursive flag to ensure nothing is missed.
Flag 4.1 /documents/.secret/stolen-data.csv
Flag 4.2 Cleanup Script Analysis

Approach

The recursive listing from Flag 4.1 also revealed a script at /mnt/tmp/cleanup.sh. Reading it exposed the attacker's anti-forensics technique: a shred command targeting /var/log/* to destroy all log files and eliminate evidence of the intrusion.

shred overwrites a file multiple times before deletion, making recovery significantly harder than a standard rm. The use of a glob pattern * shows the attacker intended to wipe the entire log directory, not individual files.

cleanup.sh contents showing shred command Flag 4.2 submitted
cat /mnt/tmp/cleanup.sh
#!/bin/bash
# Cleanup script - remove evidence
shred -uzn 3 /var/log/*
echo "Cleanup complete"
shred -uzn 3 overwrites each file 3 times with random data, then zeros, then deletes it. The -z flag adds a final zero-overwrite pass to hide the shredding. This is a deliberate anti-forensics step, not an accidental deletion.
Flag 4.2 /var/log/*
Flag 4.3 Flag in Recovered Image

Approach

File carving recovers files from raw disk sectors using known file format headers and footers. It does not rely on the filesystem's directory structure. This makes it effective against deleted files and images stored in unallocated space. foremost was used to carve PNG, JPG, BMP, and GIF files from the USB image.

A PNG was successfully carved at /tmp/carved-sus/png/00012416.png. The lab environment had no GUI or X server, so the image could not be opened directly. The solution was to base64-encode the binary on the remote machine, transfer the output, and decode it locally on the Kali machine to reveal the flag inside the image.

foremost carving output showing recovered PNG Recovered PNG image containing the flag Flag 4.3 submitted
# Carve image files from the disk image
foremost -t png,jpg,bmp,gif -i suspicious.dd -o /tmp/carved-sus

# Check carved output
ls -laR /tmp/carved-sus

# Encode the carved PNG for transfer (no GUI available)
base64 /tmp/carved-sus/png/00012416.png
Processing: suspicious.dd
|------------------------------------------------------------------
File: suspicious.dd
Start: Sun Nov 10 03:45:00 2025
Length: 32 MB (33554432 bytes)

Num      Name (bs=512)         Size      File Offset     Comment
0:       00012416.png          6 KB      6356992
# On local Kali machine: decode without invalid input errors
cat > /tmp/flag.b64 << 'EOF'
<base64 output here>
EOF
base64 -d /tmp/flag.b64 > ~/04-4_3-recovered-img.png
xdg-open ~/04-4_3-recovered-img.png
File carving works by scanning raw bytes for known file signatures (magic bytes). PNG files start with \x89PNG\r\n\x1a\n. Foremost uses these signatures to locate and extract files even when the filesystem metadata has been wiped. Base64 is a reliable way to move binary files out of restricted environments.
Flag 4.3 recovered_evidence_img
Flag 4.4 Deleted Credentials Recovery

Approach

Moving to the second image, deleted-files.img contained files that had been deliberately removed. Deleting a file removes the filesystem entry pointing to it, but the raw data on disk remains intact until the sectors are overwritten by new data. strings reads raw bytes directly from the image and prints sequences of printable characters, bypassing the filesystem entirely.

Filtering the output for credential-related keywords recovered the contents of a deleted creds.txt file, showing admin:FLAG{deleted_but_not_gone}.

strings output recovering deleted credentials Flag 4.4 submitted
strings deleted-files.img | grep -i "pass\|admin\|user\|cred"
creds.txt
admin:FLAG{deleted_but_not_gone}
Password stored for lateral movement
Deleting a file only removes its directory entry and marks the sectors as available. The actual bytes remain on disk until a write operation claims those sectors. This is why strings on a raw image can recover data that the filesystem reports as gone.
Flag 4.4 deleted_but_not_gone
Flag 4.5 Exfiltration Timeline

Approach

The same strings technique recovered a second deleted file: plan.txt, labelled OPERATION NIGHTFALL - CONFIDENTIAL. The plan detailed the attacker's exfiltration schedule: the data theft was set for 2025-11-15 02:00 UTC via a DNS tunnel, targeting the customer database and financial records.

This corroborates the DNS exfiltration technique identified in Challenge 03, where base64-encoded subdomain queries were used to covertly move data out of the network.

strings output recovering deleted exfiltration plan Flag 4.5 submitted
strings deleted-files.img | grep -i -A5 -B5 "exfil\|2025\|midnight\|transfer\|send"
OPERATION NIGHTFALL - CONFIDENTIAL
Exfiltration scheduled: 2025-11-15 02:00 UTC
Method: DNS tunnel via evil-c2.example.com
Targets: customer database, financial records
Status: READY
The DNS tunnel reference here links directly to the evil-c2.example.com domain identified in Challenge 03. Across four challenges, the same attacker infrastructure (C2 IP, domain, and exfiltration technique) has now appeared in endpoint logs, memory, network traffic, and disk artifacts.
Flag 4.5 2025-11-15 02:00 UTC

Challenges Faced

  • No GUI or X server in the lab environment, so direct image viewing was not possible. Base64 encoding was the workaround to transfer the carved PNG to a local machine.
  • Foremost initially appeared to hang during carving. Large image scans take time; the fix was to wait and check the audit log rather than kill the process.
  • Mounting the disk image did not surface deleted files. The filesystem had no record of them. Switching to raw disk analysis with strings bypassed the filesystem entirely.

Key Takeaways

  • Hidden files require -a and recursive listing. A standard ls will miss anything prefixed with a dot.
  • Deleting a file does not erase it. Until sectors are overwritten, the raw data is fully recoverable with strings or a carving tool.
  • File carving works independently of the filesystem. Magic bytes let tools like foremost recover files even after the filesystem metadata has been destroyed.
  • Anti-forensics attempts leave their own evidence. A shred script on disk tells you the attacker knew they were leaving traces and tried to clean up.
  • Base64 is a reliable way to move binary artifacts out of restricted, headless lab environments without corrupting the data.
  • The same attacker infrastructure appears across all four challenges. Disk, memory, network, and log evidence consistently point to the same C2 IP, domain, and exfiltration method.
Previous One PCAP. DNS Exfil. A Reverse Shell Reconstructed. Next One Binary. One Macro. No Execution Required.
Found this useful?

Share it with your network.