Forensik Digital
Pertemuan 09
Teknik Recovery Data dan File Carving
Mata Kuliah: Digital Forensic for Military Purposes | 3 SKS
π― Capaian Pembelajaran
Setelah pertemuan ini, mahasiswa mampu:
- Memahami prinsip penghapusan file dan mekanisme data remnants
- Menjelaskan konsep file carving dan teknik identifikasi file
- Melakukan recovery data terhapus menggunakan berbagai tools
- Menerapkan teknik file carving pada unallocated space
- Mengidentifikasi file berdasarkan header/footer signatures
- Menangani tantangan recovery pada SSD dan damaged media
- Menggunakan hex editor untuk analisis manual file signature
π Agenda Hari Ini
Bagian 1
- Prinsip Penghapusan File
- Data Remnants
- Slack Space
- Unallocated Space
Bagian 2
- File Carving Concepts
- File Signatures
- Recovery Tools
- SSD Challenges
ποΈ Mekanisme Penghapusan File
Ketika file "dihapus", data sebenarnya TIDAK dihapus secara fisik hingga area tersebut ditimpa oleh data baru!
Yang terjadi saat delete:
- Pointer Removal: Entry di MFT/FAT dihapus
- Space Marking: Cluster ditandai "available"
- Data Remains: Data masih ada di disk!
Tipe-Tipe Penghapusan
| Tipe |
Mekanisme |
Recoverable? |
Tingkat |
| Normal Delete |
Pointer dihapus |
β Ya |
Mudah |
| Shift+Delete |
Bypass Recycle Bin |
β Ya |
Mudah |
| Format Quick |
Rebuild file system |
β³ Sebagian |
Sedang |
| Format Full |
Overwrite zeros |
β³ Sebagian |
Sulit |
| Secure Delete |
Multiple overwrites |
β Tidak |
Sangat Sulit |
| TRIM (SSD) |
Garbage collection |
β Tidak |
Hampir Mustahil |
π Lokasi Data Remnants
Unallocated Space
Area tidak dialokasikan, sumber utama deleted files
Slack Space
Ruang tidak terpakai di akhir cluster (RAM slack + File slack)
Free Space
Area previously allocated, masih ada metadata
Bad Sectors
Sektor "bad" tapi masih bisa dibaca dengan tools khusus
Slack Space: Contoh
Skenario: File 2,100 bytes pada cluster 4 KB (8 sektor Γ 512 bytes)
Cluster (4 KB = 8 sektor @ 512 bytes):
ββ Sektor 1-4: Data file (2,048 bytes)
ββ Sektor 5: 52 bytes data
β ββ RAM Slack: 460 bytes β Data sensitif!
ββ Sektor 6-8: File Slack (1,536 bytes)
β ββ Data dari file sebelumnya!
Total Slack: 1,996 bytes (~49% cluster)
β οΈ Slack space dapat berisi remnants data sensitif!
Recovery Potential: Sistem File
| File System |
Recovery Rate |
Faktor Kunci |
| FAT32 |
90% |
Simple structure, minimal metadata deletion |
| exFAT |
85% |
Similar to FAT, no journaling |
| NTFS |
80% |
MFT records, journaling, compression |
| ext4 |
65% |
Deleted entries zeroed |
| APFS |
45% |
Encryption by default, snapshot management |
π‘ FAT32 paling "forensics-friendly"
πͺ File Carving: Definisi
File Carving adalah teknik untuk mengekstrak file dari unallocated space atau image forensik tanpa menggunakan metadata sistem file, melainkan berdasarkan struktur internal file (signatures, headers, footers).
Diperlukan ketika:
- File system metadata rusak atau tidak tersedia
- File telah dihapus sepenuhnya
- Disk di-format atau di-corrupt
- Investigasi pada raw binary data
π File Signatures (Magic Bytes)
Setiap tipe file memiliki signature unik di header/footer:
| File Type |
Extension |
Header (Hex) |
Footer (Hex) |
| JPEG |
.jpg |
FF D8 FF |
FF D9 |
| PNG |
.png |
89 50 4E 47 0D 0A 1A 0A |
49 45 4E 44 AE 42 60 82 |
| PDF |
.pdf |
25 50 44 46 (%PDF) |
25 25 45 4F 46 (%%EOF) |
| ZIP |
.zip |
50 4B 03 04 (PK..) |
50 4B 05 06 |
| EXE |
.exe |
4D 5A (MZ) |
- |
Contoh: Analisis Header JPEG
Offset Hex ASCII
00000000 FF D8 FF E0 00 10 4A 46 49 46 ΓΏΓΓΏΓ ..JFIF
00000010 00 01 01 01 00 48 00 48 00 00 .....H.H..
β β β β β β β
β β β β βββββββββ JFIF identifier
β β ββββββββββββββββββββββ APP0 marker
βββββββββββββββββββββββββββββ JPEG SOI
FF D8 FF E0 = JPEG Start of Image (SOI)
4A 46 49 46 = "JFIF" dalam ASCII
β Confirmed: Valid JPEG file
Mengapa Signature, Bukan Extension?
β Extension-based
- Mudah dimanipulasi
- File tanpa extension
- Extension mismatch
- Malware menyamar
β Signature-based
- Verifikasi struktur internal
- Bekerja tanpa metadata
- Deteksi file mismatch
- Ground truth
Contoh: File bernama document.pdf dengan header FF D8 FF E0
β Extension: PDF | Signature: JPEG | Reality: JPEG dengan nama salah!
Teknik File Carving
Header/Footer Carving
Mencari pasangan header-footer yang sesuai
Header/Size Carving
Size information dalam header (PNG, EXE)
Block-based Carving
Per-block extraction untuk fragmented files
Statistical Carving
Entropy analysis, ML classification
π οΈ Tool 1: Recuva
Features
- User-friendly GUI
- Deep scan capability
- Preview before recovery
- Multiple file systems
Recovery Status
- π’ Excellent (95-100%)
- π‘ Good (60-90%)
- π΄ Poor (10-50%)
- β« Unrecoverable (<5%)
β οΈ CRITICAL: JANGAN save hasil recovery ke drive yang sama dengan sumber! Akan overwrite data yang sedang di-recover.
π οΈ Tool 2: PhotoRec
Open-source, cross-platform, signature-based carving tool
Key Features:
- Signature-based: Ignores file system
- 500+ formats: Images, videos, documents, databases
- Cross-platform: Windows, Linux, Mac
- Free: Open-source (GPL)
β οΈ Limitation: Tidak mempertahankan filename dan folder structure asli
PhotoRec: Struktur Output
Destination Folder:
ββ recup_dir.1/
β ββ f0000001.jpg β Generic sequential names
β ββ f0000002.pdf
β ββ f0000003.png
β ββ ... (up to 500 files per directory)
ββ recup_dir.2/
β ββ f0000501.docx
β ββ ...
ββ report.xml β Recovery report
Why no original names?
PhotoRec carves berdasarkan signatures, tidak menggunakan MFT/FAT metadata (filename, path, timestamps tersimpan terpisah dari file content)
π οΈ Tool 3 & 4: Foremost vs Scalpel
| Feature |
Foremost |
Scalpel |
| Threading |
Single-threaded |
Multi-threaded |
| Speed |
~100 MB/s |
~250 MB/s (2-3x) |
| Memory |
~100 MB |
~300 MB |
| Preview |
No |
Yes (-p flag) |
| Best For |
Small images (<10 GB) |
Large images (>100 GB) |
π‘ Scalpel recommended untuk large-scale forensic investigations
π οΈ Tool 5: Autopsy
Integrated file carving dalam case management:
Advantages
- GUI-based workflow
- Case management
- Automatic timeline
- Built-in reporting
- Hash database
- Tagging system
Carving Modules
- Photorec Carver
- File Type Identification
- Extension Mismatch Detector
- Tika MIME Type Detection
β Best untuk military investigations: Chain of custody, documentation, professional reporting
π Manual Carving: HxD Hex Editor
Workflow manual extraction:
- Step 1: Open image/drive (read-only mode)
- Step 2: Search signature (Ctrl+F) β Hex values
- Step 3: Identify boundaries (header + footer)
- Step 4: Select byte range β Copy
- Step 5: New file β Paste β Save
- Step 6: Validate extracted file
β οΈ Always include footer dalam extraction!
πΎ Database Carving: SQLite
SQLite Signature: 53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00
ASCII: "SQLite format 3\0"
Common locations:
Android:
- SMS: mmssms.db
- Contacts: contacts2.db
- Call log: calllog.db
Browsers:
- Firefox: places.sqlite
- Chrome: History
- Edge: History
# Validate recovered database
sqlite3 recovered.db "PRAGMA integrity_check;"
# Extract schema
sqlite3 recovered.db ".schema"
# Query data
sqlite3 -csv recovered.db "SELECT * FROM table;" > output.csv
π§ Email Database: PST/OST
PST Signature: 21 42 44 4E ("!BDN")
PST/OST Contains:
Email messages (sent/received)
Attachments
Contacts & Calendar
Deleted items (recoverable!)
π¨ High-value evidence dalam konteks kebocoran dokumen militer:
Communication records, timestamps, attachment metadata, deleted items
π½ SSD Recovery Challenges
TRIM Command: Memberi tahu SSD bahwa data blocks tidak lagi digunakan dan dapat di-erase secara internal
Impact pada recovery:
| Storage Type |
Recovery Rate |
Why? |
| HDD Tradisional |
90% |
Data persists until overwritten |
| SSD Tanpa TRIM |
70% |
Some garbage collection |
| SSD Dengan TRIM |
10% |
Immediate data erasure |
TRIM Process Flow
Step 1: User deletes file β File system marks space available
Step 2: OS sends TRIM command β SSD controller receives
Step 3: SSD marks blocks invalid β Queued for erasure
Step 4: Garbage Collection β Background process erases blocks
Result: Data PERMANENTLY ERASED - CANNOT be recovered!
β οΈ Recovery window pada SSD modern: Minutes to Hours (not days!)
Strategi Recovery pada SSD
Scenario: Laptop dengan SSD TRIM-enabled, file dihapus 3 jam lalu
Critical Actions
- Power OFF immediately
- Preserve volatile data
- DO NOT reboot
- DO NOT write to SSD
Recovery Attempts
- Memory dump (RAM)
- Forensic imaging
- Signature carving
- MFT analysis
Realistic expectation: 5-15% recovery chance dari SSD
Alternative sources: Volume Shadow Copies, cloud backup, email, temp files
π§ Recovery dari Damaged Media
Tool of choice: ddrescue
Multi-pass Strategy
- Phase 1: Quick forward (skip errors)
- Phase 2: Reverse pass
- Phase 3: Targeted retry (limited)
- Phase 4: Verification
Expected Results
- Best: 98-99% recovery
- Typical: 95-97% recovery
- Worst: 85-90% recovery
# Phase 1: Quick pass
ddrescue -f -n -v /dev/sdb evidence.img evidence.log
# Phase 2: Reverse
ddrescue -f -R -v /dev/sdb evidence.img evidence.log
# Phase 3: Limited retry
ddrescue -f -r 1 -v /dev/sdb evidence.img evidence.log
β
Best Practices: Data Recovery
DO:
β’ Write-block source media
β’ Work on forensic images
β’ Document everything
β’ Verify with hash
DON'T:
β’ Write to source drive
β’ Skip documentation
β’ Retry excessively
β’ Delay imaging
For HDD:
β’ High recovery chance
β’ Use any carving tool
β’ Time not critical
For SSD:
β’ Act IMMEDIATELY
β’ Power off quickly
β’ Seek alternatives
ποΈ Konteks Investigasi Militer
Scenario: Suspected data exfiltration di Kodam, file dihapus dari laptop SSD
Investigation priorities:
- Immediate seizure: Power off, preserve volatile data
- Forensic imaging: Write-protected, multiple copies, hash
- Recovery attempts: Carving tools, MFT analysis, manual hex
- Alternative sources: Backups, email, network logs, recipients
- Documentation: Chain of custody, detailed reporting
π Tool Selection Guide
| Scenario |
Recommended Tool |
Why? |
| Quick recovery, GUI needed |
Recuva |
User-friendly, fast, preview |
| Cross-platform, no metadata needed |
PhotoRec |
Signature-based, 500+ formats |
| Large image (>100 GB) |
Scalpel |
Multi-threaded, 2-3x faster |
| Military investigation |
Autopsy |
Case management, documentation |
| Manual analysis needed |
HxD |
Hex editor, full control |
| Damaged media |
ddrescue |
Multi-pass, bad sector handling |
π Quiz Time!
Mari uji pemahaman Anda tentang recovery data dan file carving!
3 soal multiple choice
Quiz 1
File berukuran 5,678 bytes disimpan pada sistem dengan cluster size 8 KB (8,192 bytes). Berapa besar slack space yang terbentuk?
A. 2,514 bytes
B. 3,072 bytes
C. 5,678 bytes
D. 8,192 bytes
β Jawaban: A. 2,514 bytes
Slack space = Cluster size - File size = 8,192 - 5,678 = 2,514 bytes
Quiz 2
Anda menemukan hex pattern berikut: FF D8 FF E0 00 10 4A 46 49 46. File type apa ini?
A. PNG Image
B. PDF Document
C. JPEG Image
D. ZIP Archive
β Jawaban: C. JPEG Image
FF D8 FF = JPEG SOI (Start of Image), 4A 46 49 46 = "JFIF"
Quiz 3
Laptop dengan SSD Samsung (TRIM enabled), file dihapus 3 jam lalu. Apa yang HARUS dilakukan PERTAMA?
A. Jalankan PhotoRec immediately
B. Power OFF laptop immediately
C. Check Recycle Bin dulu
D. Reboot ke Linux untuk recovery
β Jawaban: B. Power OFF laptop immediately
Mencegah garbage collection lebih lanjut. TRIM dengan 3 jam elapsed = recovery chance sangat rendah, tapi power off adalah prioritas #1.
π Ringkasan (1/2)
| Konsep |
Key Points |
| File Deletion |
Data remains until overwritten; pointer dihapus, data tetap ada |
| Data Remnants |
Unallocated space, slack space, free space, bad sectors |
| File Signatures |
Magic bytes identify file types (JPEG: FF D8 FF, PNG: 89 50 4E 47) |
| File Carving |
Extract files tanpa metadata: header/footer, size-based, statistical |
| Slack Space |
RAM slack + File slack; dapat berisi data sensitif |
π Ringkasan (2/2)
| Tool/Concept |
Application |
| Recuva |
User-friendly, quick recovery, GUI-based |
| PhotoRec |
Signature-based, 500+ formats, cross-platform |
| Scalpel |
Large images, multi-threaded, 2-3x faster than Foremost |
| Autopsy |
Case management, military investigations, documentation |
| SSD + TRIM |
Recovery chance: 5-15%; Act immediately; Seek alternatives |
| ddrescue |
Damaged media, multi-pass strategy, 95-99% recovery |
π‘ Key Takeaways
- File deletion β Data erasure: Data remains until overwritten
- Signatures > Extensions: Always verify dengan magic bytes
- Multiple tools strategy: Recuva β PhotoRec β Scalpel β Manual
- SSD = Time critical: TRIM makes recovery window very short
- Write-protection mandatory: NEVER write to source media
- Documentation is evidence: Chain of custody, hash verification
π§ Practical Tips
β Best Practices
- Always work on images, not originals
- Use write-blockers
- Document every step
- Calculate hashes
- Create multiple copies
- Test recovered files
β Common Mistakes
- Saving to source drive
- Running CHKDSK on evidence
- Excessive retry on damaged media
- Ignoring TRIM on SSD
- Delaying acquisition
- Poor documentation
π
Pertemuan Berikutnya
Pertemuan 10: Forensik Jaringan
Topik yang akan dibahas:
- Network forensics fundamentals
- Packet capture dan analysis (Wireshark)
- Traffic analysis dan anomaly detection
- Network-based indicators of compromise
- Intrusion detection dan log analysis
- Malicious traffic identification
Persiapan: Install Wireshark, familiarize dengan network basics
π Referensi
- Carrier, B. (2005). File System Forensic Analysis. Addison-Wesley. Chapter 12-14.
- Casey, E. (2022). Digital Evidence and Computer Crime (4th ed.). Academic Press. Chapter 7.
- Phillips, A., et al. (2022). Guide to Computer Forensics and Investigations (7th ed.). Cengage. Chapter 8.
- Nikkel, B. (2021). Practical Forensic Imaging. No Starch Press. Chapter 8-10.
- Wei, M., et al. (2011). "Reliably Erasing Data from Flash-Based SSDs." FAST.
- Garfinkel, S. L. (2007). "Carving Contiguous and Fragmented Files." Digital Investigation.
- Richard III, G. G., & Roussev, V. (2005). "Scalpel: A Frugal, High Performance File Carver." DFRWS.
- Fairbanks, K., et al. (2012). "Forensic Implications of Solid State Drives." Journal of Digital Forensics.
β Tanya Jawab
Silakan ajukan pertanyaan Anda!
Terima Kasih
π Forensik Digital untuk Keperluan Militer
Pertemuan 09: Teknik Recovery Data dan File Carving
Ada pertanyaan?