Athena Wiki
ForensicsDisk Forensics

Deleted File Recovery

forensicsintermediate

Recover deleted files from disk images and filesystems in CTF forensics challenges.

forensicsdeleted-filesrecoveryphotorectestdiskforemostext4ntfs

Deleted File Recovery

When a file is deleted, the data doesn't disappear. The filesystem marks the space as available, but the actual bytes remain on disk until they're overwritten. Recovery tools scan for these orphaned bytes and reconstruct the files.

In CTF challenges, the disk image is a forensic snapshot — nothing gets overwritten, so recovery almost always works.


How Deletion Works

FilesystemWhat Happens on Delete
ext4Inode unlinked, data blocks freed but not zeroed
NTFSMFT entry marked unused, data may persist
FAT32Directory entry first byte set to 0xE5, clusters freed

The data is recoverable until the disk space is reused by new files.


Recovery Workflow

Mermaid diagram

Recovery Steps

Quick automated recovery with PhotoRec

sudo apt install testdisk
photorec disk.img
# Interactive: select disk → partition → filesystem → output dir → start

Output goes into numbered subdirectories — check for .txt, .pdf, .jpg with flags.

List deleted files with Sleuth Kit

sudo apt install sleuthkit
fls -rd disk.img | grep "deleted"
# Output: d/d * 45: secretfile.txt  (asterisk = deleted)

Recover file by inode

icat disk.img 45 > recovered_secretfile.txt
cat recovered_secretfile.txt

Search unallocated space

blkls disk.img > unallocated.bin
strings unallocated.bin | grep -i "flag{"
grep -a "flag{" unallocated.bin

Tool Guide

Most comprehensive free file recovery — works on any filesystem:

sudo apt install testdisk   # photorec included
photorec disk.img
# 1. Select disk (disk.img)
# 2. Select partition / whole disk
# 3. Choose filesystem type
# 4. Select output directory
# 5. Start recovery

Recovered files go into recup_dir.1/, recup_dir.2/, etc.


Special Cases


Checklist

  • photorec disk.img → recover all files automatically
  • testdisk → recover partition tables and deleted files interactively
  • fls -rd disk.img → list deleted files with inodes
  • icat disk.img <inode> → recover specific deleted file
  • strings disk.img | grep flag → raw string search
  • blkls + strings for unallocated space
  • ntfsundelete for Windows NTFS disk images
  • debugfs + lsdel for ext4 inode inspection
  • Check for deleted .git directories and SQLite databases

Last updated on

On this page