| name | password-recovery |
| description | Digital forensic skill for recovering passwords and sensitive data from disk images, deleted files, and binary data. This skill should be used when tasks involve extracting passwords from disk images, recovering deleted file contents, analyzing binary files for fragments, or forensic data recovery scenarios. Applies to tasks mentioning disk images, deleted files, password fragments, or data recovery. |
Password Recovery
Overview
This skill provides guidance for digital forensic recovery tasks involving the extraction of passwords or sensitive data from disk images, deleted files, and binary data. It covers systematic approaches to environment assessment, file identification, pattern searching, fragment reconstruction, and result validation.
Environment Assessment (Critical First Step)
Before attempting any recovery operations, assess the working environment:
- Identify available tools: Run
which strings hexdump xxd file binwalkto determine available forensic utilities - Understand access boundaries: In containerized environments, host filesystems and block devices are typically inaccessible
- Map the working directory: Execute
find /app -type f 2>/dev/nullor equivalent to discover all available files - Avoid premature exploration: Do not attempt to access
/proc/kcore, raw block devices, or Docker overlay directories before confirming access permissions
File Discovery and Identification
Systematic File Location
To locate potential data sources:
- List all files recursively in the working directory first
- Identify binary files: Use
file *on discovered files to determine types - Look for obvious locations: Directory names like
disks/,images/,backup/often contain relevant data - Check common extensions:
.dat,.img,.bin,.raw,.ddfiles are primary candidates
File Type Analysis
Always run file type identification on unknown binary files:
file <filename>
Common indicators:
- "data" - Generic binary, requires further analysis
- "Zip archive" - May contain recoverable data, attempt extraction
- "disk image" - Direct forensic target
- Presence of "PK" bytes (hex: 50 4B) suggests ZIP archive structure
Pattern Searching Strategies
Initial Broad Search
Start with inclusive patterns to identify potential matches:
strings <file> | grep -E '[A-Z0-9]{8,}'
Refined Pattern Search
When password format is known, construct specific regex patterns:
# For alphanumeric passwords of specific length
strings <file> | grep -E '^[A-Z0-9]{23}$'
# For partial fragments
strings <file> | grep -E '[A-Z0-9]{10,15}'
Binary-Level Search
For data not extractable via strings:
# If xxd is available
xxd <file> | grep -i '<pattern>'
# Python fallback for hex analysis
python3 -c "
import sys
with open('<file>', 'rb') as f:
data = f.read()
# Search for patterns in raw bytes
for i in range(len(data) - 10):
chunk = data[i:i+20]
if chunk.isalnum() or b'<pattern>' in chunk:
print(f'Offset {i}: {chunk}')
"
Fragment Reconstruction
Identifying Fragments
Fragments may occur due to:
- File system allocation boundaries
- Compression artifacts
- Partial file deletion
- Archive structure overhead
Fragment Combination Strategy
When multiple potential fragments are found:
- Document all candidates with their byte offsets
- Check length requirements: If target length is known, verify fragment combinations sum correctly
- Test all orderings: Fragments may appear out of order in storage
- Validate each combination against known criteria before concluding
Combination Validation Checklist
Before accepting a combined result:
- Total length matches expected value
- Character set matches requirements (alphanumeric, special chars, etc.)
- No duplicate characters if uniqueness required
- Passes any provided validation criteria
Verification Strategies
Multi-Criteria Validation
When multiple conditions must be met, verify each explicitly:
password = "CANDIDATE_PASSWORD"
checks = {
"length": len(password) == 23,
"alphanumeric": password.isalnum(),
"uppercase_letters": password.isupper(),
# Add task-specific criteria
}
print(f"All checks passed: {all(checks.values())}")
for check, result in checks.items():
print(f" {check}: {result}")
Exhaustive Search Confirmation
After finding a candidate, verify no other matches exist:
# Confirm uniqueness of the pattern in the source
grep -c '<pattern>' <file>
Common Pitfalls to Avoid
Environment-Related Mistakes
- Assuming host access: Container environments restrict access to host filesystems
- Using unavailable tools: Verify tool availability before attempting complex commands
- Broad filesystem searches: Start with the working directory, not root-level exploration
Analysis Mistakes
- Ignoring file type identification: Always run
fileon unknown binaries - Missing archive structures: Check for ZIP/archive signatures (PK headers) in binary data
- Single-pass searching: Use multiple search strategies;
stringsmay miss embedded data
Reconstruction Mistakes
- Assuming fragment order: Storage order may not match original data order
- Incomplete validation: Verify all criteria, not just length or format
- Premature conclusion: Search for alternative fragment combinations before finalizing
Workflow Summary
- Environment Assessment: Identify tools, boundaries, and available data
- File Discovery: Map all files, identify types, prioritize candidates
- Initial Analysis: Run
file,strings, and broad pattern searches - Deep Analysis: Binary-level examination if initial search insufficient
- Fragment Collection: Document all potential fragments with offsets
- Reconstruction: Combine fragments, test orderings
- Validation: Verify against all known criteria
- Confirmation: Ensure no alternative matches exist