Skip to content
Skillpedia
Misc35k · #6182

recovering-deleted-files-with-photorec

Lets your agent recover deleted files from disks and media. It searches for file signatures, even if the file system is damaged. It's useful for recovering lost data in investigations.

What it does

This tool helps recover files that were deleted or lost from your computer or storage devices. It works even if the file system is damaged.

When to use it

  • ✓When you accidentally delete a file.
  • ✓If your storage device (USB drive, SD card) stops working.
  • ✓To recover important documents, photos, or videos that have disappeared.

Example of what to ask your AI

“Recover the photo files I deleted from my USB drive.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/recovering-deleted-files-with-photorec/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/recovering-deleted-files-with-photorec/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool searches for file fragments using 'signatures' (like a fingerprint for each file type). It pieces these fragments together to try and reconstruct lost files, even if the system that organizes files is broken.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill recovering-deleted-files-with-photorec

Or download just the file:

curl -L https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/main/skills/recovering-deleted-files-with-photorec/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Recovering Deleted Files with PhotoRec

When to Use

  • When recovering deleted files from a forensic disk image or storage device
  • When the file system is corrupted, formatted, or overwritten
  • During investigations requiring recovery of documents, images, videos, or databases
  • When file system metadata is unavailable but raw data sectors remain intact
  • For recovering files from memory cards, USB drives, and hard drives

Prerequisites

  • PhotoRec installed (part of TestDisk suite)
  • Forensic disk image or direct device access (read-only)
  • Sufficient output storage space (potentially larger than source)
  • Write-blocker if working with original media
  • Root/sudo privileges for device access
  • Knowledge of target file types for focused recovery

Workflow

Step 1: Install PhotoRec and Prepare the Environment

# 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

Step 2: Run PhotoRec in Interactive Mode

# 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

Step 3: Run PhotoRec with Command-Line Options for Targeted Recovery

# 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

Step 4: Organize and Catalog Recovered Files

# 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

Step 5: Validate and Filter Recovered Files

# 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)

…
FAQ

Do I need to install anything first?

Yes, you need to install PhotoRec, which is part of a package called TestDisk.

What is a 'forensic disk image'?

It's an exact copy of an entire disk, used in investigations to avoid altering the original.

Can I recover any file?

The tool is good at recovering many common file types (documents, images, videos), but there's no 100% guarantee for all files.

Details

Original description by the author

Recovers deleted files from disk images and storage media using PhotoRec's file signature-based carving engine, which works regardless of file system damage or corruption. Use when recovering deleted or lost files from a forensic disk image, damaged storage device, or corrupted file system during evidence recovery.

repo: mukul975/Anthropic-Cybersecurity-Skills

Popularity

GitHub stars
35k
Ranking position
#6182
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills