A comprehensive library for parsing and processing digital forensics data artifacts with enhanced testing utilities.
Project description
Unknown Data - Digital Forensics Data Processing Library
A comprehensive Python library for parsing and processing digital forensics data artifacts. This library provides standardized interfaces for handling various types of forensic data including browser artifacts, deleted files, link files, messenger data, prefetch files, and USB device information with integrated database support.
Features
- Multi-format Support: Handle browser data, deleted files, link files, messenger data, prefetch files, and USB artifacts
- Database Integration: Full PostgreSQL support with SQLAlchemy ORM for forensic data storage and retrieval
- Standardized Processing: Consistent interface for all data types
- Flexible Data Sources: Support for local files, cloud storage (S3), and database
- DataFrame Output: All processed data is converted to pandas DataFrames for easy analysis
- Session Management: Robust database session handling with auto-reconnection
- Comprehensive Logging: Built-in logging for debugging and monitoring
- Type Safety: Full type hints support for better development experience
- Production Ready: Comprehensive test suite with 100% database functionality coverage
Installation
pip install unknown-data
Quick Start
Local File Processing
from unknown_data import Category, Encoder, DataLoader, DataSaver
# Load data from local file
loader = DataLoader()
data = loader.local_data_load(Category.BROWSER, "./data/browser_results.json")
# Process the data
encoder = Encoder()
browser_encoder = encoder.convert_data(data, Category.BROWSER)
# Get processed results
results = browser_encoder.get_result_dfs()
# Save results to CSV files
saver = DataSaver("./output/path")
saver.save_all(results)
AWS S3 Integration
from unknown_data import Category, DataLoader
# Configure S3 access with task_id structure
s3_config = {
'bucket': 'your-forensic-data-bucket',
'task_id': '550e8400-e29b-41d4-a716-446655440000', # UUID format
'region': 'us-west-2', # optional
'profile': 'forensics' # optional AWS profile
}
# Load data from S3
# S3 path will be: {bucket}/{task_id}/browser_data.json
loader = DataLoader()
browser_data = loader.s3_data_load(Category.BROWSER, s3_config)
# The data is automatically loaded and ready for processing
print(f"Loaded {len(browser_data.get('browser_data', []))} browser records")
# Load different types of data from the same task
deleted_data = loader.s3_data_load(Category.DELETED, s3_config)
usb_data = loader.s3_data_load(Category.USB, s3_config)
Database Integration
from unknown_data import Category, DataLoader
from unknown_data.loader.base import Config_db
# Configure database connection
db_config = Config_db(
dbms="postgresql",
username="your_username",
password="your_password",
ip="13.124.25.47",
port=5432,
database_name="forensic_agent"
)
# Initialize loader and set database
loader = DataLoader()
loader.set_database(db_config)
# Load forensic data from database
task_id = "550e8400-e29b-41d4-a716-446655440000"
browser_data = loader.database_data_load(task_id, Category.BROWSER)
deleted_data = loader.database_data_load(task_id, Category.DELETED)
usb_data = loader.database_data_load(task_id, Category.USB)
# Process the data normally
encoder = Encoder()
browser_encoder = encoder.convert_data(browser_data, Category.BROWSER)
results = browser_encoder.get_result_dfs()
Supported Data Types
Browser Artifacts
- History (URLs, visits, downloads)
- Cookies
- Login data
- Web data
Deleted Files
- MFT deleted files
- Recycle bin files
- Collection metadata
Other Artifacts
- Link (LNK) files
- Messenger data
- Prefetch files
- USB device information
Data Structure
The library expects JSON data in specific formats for each category. Here's an example for browser data:
browser_data = {
"collected_files": [...],
"collection_time": "2023-01-01T10:00:00",
"detailed_files": [...],
"discovered_profiles": [...],
"statistics": {...},
"temp_directory": "/tmp/extraction"
}
Advanced Usage
Custom Data Processing
from unknown_data import BrowserDataEncoder
# Create specific encoder
encoder = BrowserDataEncoder()
# Process data
encoder.convert_data(your_data)
# Access specific results
chrome_data = encoder.chrome_data
edge_data = encoder.edge_data
Cloud Storage Support
# Load from S3 (requires boto3 configuration)
s3_config = {
"bucket": "your-bucket",
"key": "path/to/data.json"
}
data = loader.s3_data_load(Category.BROWSER, s3_config)
Requirements
- Python 3.8+
- pandas >= 1.3.0
- numpy
- jsonschema
- boto3 (for S3 support)
- sqlalchemy >= 2.0.0 (for database support)
- psycopg2-binary (for PostgreSQL support)
AWS S3 Configuration
Setting up AWS Credentials
Before using S3 features, configure your AWS credentials using one of these methods:
1. AWS CLI Configuration
aws configure
2. Environment Variables
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_DEFAULT_REGION=us-west-2
3. AWS Profile
s3_config = {
'bucket': 'your-bucket',
'key': 'path/to/file.json',
'profile': 'your-aws-profile'
}
S3 Data Structure
Your S3 bucket should organize forensic data using the task_id structure:
your-forensic-bucket/
├── 550e8400-e29b-41d4-a716-446655440000/ # task_id (UUID)
│ ├── browser_data.json
│ ├── deleted_data.json
│ ├── usb_data.json
│ ├── messenger_data.json
│ ├── prefetch_data.json
│ └── lnk_data.json
├── 6ba7b810-9dad-11d1-80b4-00c04fd430c8/ # another task_id
│ ├── browser_data.json
│ └── ...
└── ...
Each {category.value}_data.json file contains the forensic data for that specific category. The library automatically constructs the S3 key as {task_id}/{category.value}_data.json.
│ ├── case001/
│ │ ├── browser_data.json
│ │ ├── deleted_data.json
│ │ └── usb_data.json
│ └── case002/
│ └── messenger_data.json
└── archive/
└── old_cases/
### Error Handling
The library provides comprehensive error handling for S3 operations:
```python
from unknown_data import DataLoader, Category
from botocore.exceptions import NoCredentialsError, ClientError
try:
loader = DataLoader()
data = loader.s3_data_load(Category.BROWSER, s3_config)
except NoCredentialsError:
print("AWS credentials not found. Please configure your credentials.")
except FileNotFoundError as e:
print(f"File not found: {e}")
except ClientError as e:
print(f"AWS error: {e}")
Development
Setting up Development Environment
# Clone the repository
git clone https://github.com/daehan00/unknown_parsing_module.git
cd unknown_parsing_module
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
# Install development dependencies
pip install pytest black mypy
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=parsing_module
# Run specific test file
pytest tests/test_integration.py -v
Changelog
Version 0.1.0
- Initial release
- Support for browser artifacts processing
- Support for deleted files analysis
- Basic encoder framework
- Local and S3 data loading
- Comprehensive test coverage
Contact
- GitHub: @daehan00
- Repository: unknown_parsing_module
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unknown_data-0.3.0.tar.gz.
File metadata
- Download URL: unknown_data-0.3.0.tar.gz
- Upload date:
- Size: 35.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4dd6e4aaec6b06f7ef6e14d1f5cc39f97f8a6f2008ed5e15873e198cd8c358b
|
|
| MD5 |
f3a2ff453fdbaadea07e9d4094eb4a8d
|
|
| BLAKE2b-256 |
4c2de61e4b0d4ac2bd7465b801972af196412ee790f522a2c248bb809648ff91
|
File details
Details for the file unknown_data-0.3.0-py3-none-any.whl.
File metadata
- Download URL: unknown_data-0.3.0-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1767621a0048439d7a26324a77437da6792a02781089f0e23134b132f1263489
|
|
| MD5 |
6b4017a45090c65e75b45a0d68454346
|
|
| BLAKE2b-256 |
f73fd5839283cd36741d13d2ed2e1cdb8c0b25e87b9863d1079769dae0bab820
|