ForensicsDisk Forensics
File Carving
forensicsbeginner
Recover deleted or embedded files from disk images and raw data streams using file carving.
forensicsfile-carvingforemostscalpelbinwalkdeleted-filesdisk-image
File Carving
File carving recovers files from raw data by recognizing file headers (magic bytes) and footers. It works regardless of the filesystem — even when files are deleted, the filesystem is damaged, or you're working with a memory dump or binary blob. The tools scan for known signatures and extract everything they find.
For a full list of magic bytes, see File Analysis.
Carving Workflow
Carving Tools
Best for embedded files and firmware analysis:
binwalk suspicious_file # scan for embedded files
binwalk -e suspicious_file # extract all found files
binwalk -Me suspicious_file # recursive extraction
binwalk -E suspicious_file # entropy analysis (high = compressed/encrypted)Extracted files appear in _suspicious_file.extracted/ named by hex offset.
Analysis Steps
Identify what's in the file
file suspicious.*
binwalk suspicious.* # list embedded signatures
strings suspicious.* | head -50Extract with binwalk
binwalk -Me suspicious.*
ls -la _suspicious.*/
find _suspicious.*/ -type f | sortDeep carve with foremost
foremost -v -i suspicious.* -o carved/
find carved/ -type f | sortSearch extracted files for flag
find carved/ -type f -exec strings {} \; | grep -i "flag{"
grep -r "flag{" carved/ 2>/dev/nullDisk Image Specifics
Checklist
-
file+binwalkfirst — what's embedded? -
binwalk -Meto extract embedded files recursively -
foremostorscalpelfor thorough file carving -
strings disk.raw | grep flag - Mount and browse if it's a filesystem image
-
photorec/testdiskfor deleted file recovery - Check for SQLite databases, ZIP files, hidden directories
- Check file slack space for hidden data
Last updated on