Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Recover deleted files from disk images and storage media using PhotoRec's file signature-based carving engine regardless of file system damage.
.claude/skills/recovering-deleted-files-with-photorec/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | — | — |
| case-12 | ✗→✓ | ▲ Improved | — | — |
| case-07 | ✗→✓ | ▲ Improved | — | — |
| case-02 | ✗→✓ | ▲ Improved | — | — |
| case-20 | ✗→✓ | ▲ Improved | — | — |
bash# Install TestDisk (includes PhotoRec) on Debian/Ubuntu sudo apt-get install testdisk # On RHEL/CentOS sudo yum install testdisk # On macOS brew install testdisk # Verify installation photorec --version # Create output directory structure mkdir -p /cases/case-2024-001/recovered/{all,documents,images,databases} # Verify the forensic image file /cases/case-2024-001/images/evidence.dd ls -lh /cases/case-2024-001/images/evidence.dd
bash# Launch PhotoRec against a forensic image photorec /cases/case-2024-001/images/evidence.dd # Interactive menu steps: # 1. Select the disk image: evidence.dd # 2. Select partition table type: [Intel] for MBR, [EFI GPT] for GPT # 3. Select partition to scan (or "No partition" for whole disk) # 4. Select filesystem type: [ext2/ext3/ext4] or [Other] for NTFS/FAT # 5. Choose scan scope: [Free] (unallocated only) or [Whole] (entire partition) # 6. Select output directory: /cases/case-2024-001/recovered/all/ # 7. Press C to confirm and begin recovery # For direct device scanning (with write-blocker) sudo photorec /dev/sdb
bash# Non-interactive mode with specific file types photorec /d /cases/case-2024-001/recovered/documents/ \ /cmd /cases/case-2024-001/images/evidence.dd \ partition_table,options,mode,fileopt,search # Recover only specific file types using photorec command mode photorec /d /cases/case-2024-001/recovered/documents/ \ /cmd /cases/case-2024-001/images/evidence.dd \ options,keep_corrupted_file,enable \ fileopt,everything,disable \ fileopt,doc,enable \ fileopt,docx,enable \ fileopt,pdf,enable \ fileopt,xlsx,enable \ search # Recover only image files photorec /d /cases/case-2024-001/recovered/images/ \ /cmd /cases/case-2024-001/images/evidence.dd \ fileopt,everything,disable \ fileopt,jpg,enable \ fileopt,png,enable \ fileopt,gif,enable \ fileopt,bmp,enable \ fileopt,tif,enable \ search # Recover database files photorec /d /cases/case-2024-001/recovered/databases/ \ /cmd /cases/case-2024-001/images/evidence.dd \ fileopt,everything,disable \ fileopt,sqlite,enable \ fileopt,dbf,enable \ search
bash# PhotoRec outputs files into recup_dir.1, recup_dir.2, etc. ls /cases/case-2024-001/recovered/all/ # Count recovered files by type find /cases/case-2024-001/recovered/all/ -type f | \ sed 's/.*\.//' | sort | uniq -c | sort -rn > /cases/case-2024-001/recovered/file_type_summary.txt # Sort recovered files into directories by extension cd /cases/case-2024-001/recovered/all/ for ext in jpg png pdf docx xlsx pptx zip sqlite; do mkdir -p /cases/case-2024-001/recovered/sorted/$ext find . -name "*.$ext" -exec cp {} /cases/case-2024-001/recovered/sorted/$ext/ \; done # Generate SHA-256 hashes for all recovered files find /cases/case-2024-001/recovered/all/ -type f -exec sha256sum {} \; \ > /cases/case-2024-001/recovered/recovered_hashes.txt # Generate file listing with metadata find /cases/case-2024-001/recovered/all/ -type f \ -printf "%f\t%s\t%T+\t%p\n" | sort > /cases/case-2024-001/recovered/file_listing.txt
bash# Verify file integrity using file signatures find /cases/case-2024-001/recovered/all/ -type f -exec file {} \; \ > /cases/case-2024-001/recovered/file_signatures.txt # Find files with mismatched extension/signature while IFS= read -r line; do filepath=$(echo "$line" | cut -d: -f1) filetype=$(echo "$line" | cut -d: -f2-) ext="${filepath##*.}" if [[ "$ext" == "jpg" ]] && ! echo "$filetype" | grep -qi "JPEG"; then echo "MISMATCH: $filepath -> $filetype" fi done < /cases/case-2024-001/recovered/file_signatures.txt > /cases/case-2024-001/recovered/mismatches.txt # Filter out known-good files using NSRL hash comparison hashdeep -r -c sha256 /cases/case-2024-001/recovered/all/ | \ grep -vFf /opt/nsrl/nsrl_sha256.txt > /cases/case-2024-001/recovered/unknown_files.txt # Remove zero-byte and corrupted files find /cases/case-2024-001/recovered/all/ -type f -empty -delete find /cases/case-2024-001/recovered/all/ -name "*.jpg" -exec jpeginfo -c {} \; 2>&1 | \ grep "ERROR" > /cases/case-2024-001/recovered/corrupted_images.txt
| Concept | Description | |---------|-------------| | File carving | Recovering files from raw data using file header/footer signatures | | File signatures | Magic bytes at the start of files identifying their type (e.g., FF D8 FF for JPEG) | | Unallocated space | Disk sectors not assigned to any active file; may contain deleted data | | Fragmented files | Files stored in non-contiguous sectors; harder to carve completely | | Cluster/Block size | Minimum allocation unit on a file system; affects carving granularity | | File footer | Byte sequence marking the end of a file (not all formats have footers) | | Data remanence | Residual data remaining after deletion until sectors are overwritten | | False positives | Carved artifacts that match signatures but contain corrupted or partial data |
| Tool | Purpose | |------|---------| | PhotoRec | Open-source file carving tool supporting 300+ file formats | | TestDisk | Companion tool for partition recovery and repair | | Foremost | Alternative file carver originally developed by US Air Force OSI | | Scalpel | High-performance file carver based on Foremost | | hashdeep | Recursive hash computation and audit tool | | jpeginfo | JPEG file integrity verification | | file | Unix utility identifying file types by magic bytes | | exiftool | Extract metadata from recovered image and document files |
Scenario 1: Recovering Deleted Evidence from a Suspect's USB Drive Image the USB drive with dcfldd, run PhotoRec targeting document and image formats, organize by file type, hash all recovered files, compare against known-bad hash sets, extract metadata from images for GPS and timestamp information.
Scenario 2: Formatted Hard Drive Recovery Run PhotoRec in "Whole" mode against the entire formatted partition, recover all file types, expect higher false positive rate due to file fragmentation, validate recovered files with signature checking, catalog and hash for evidence chain.
Scenario 3: Memory Card from a Surveillance Camera Recover deleted video files (AVI, MP4, MOV) from the memory card image, use targeted file type selection to speed recovery, verify video files are playable, extract frame timestamps, document recovery in case notes.
Scenario 4: Corrupted File System on Evidence Drive When file system metadata is destroyed, PhotoRec bypasses the file system entirely and carves from raw sectors, recover maximum possible data, accept that file names and directory structure will be lost, rename files based on content during review.
PhotoRec Recovery Summary:
Source Image: evidence.dd (500 GB)
Partition: NTFS (Partition 2)
Scan Mode: Free space only
Files Recovered: 4,523
Documents: 234 (doc: 45, docx: 89, pdf: 67, xlsx: 33)
Images: 2,145 (jpg: 1,890, png: 198, gif: 57)
Videos: 34 (mp4: 22, avi: 12)
Archives: 67 (zip: 45, rar: 22)
Databases: 12 (sqlite: 8, dbf: 4)
Other: 2,031
Data Recovered: 12.4 GB
Corrupted Files: 312 (flagged for review)
Output Directory: /cases/case-2024-001/recovered/all/
Hash Manifest: /cases/case-2024-001/recovered/recovered_hashes.txt| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +45 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.