Binary Management¶
KrakenHashes provides a comprehensive binary management system for hashcat and other password cracking tools. This document explains how to manage binaries, track versions, and ensure secure distribution to agents.
Overview¶
The binary management system allows administrators to: - Upload and manage multiple versions of hashcat binaries - Track different binary types and compression formats - Verify binary integrity with MD5 checksums - Automatically extract and prepare binaries for server-side execution - Distribute binaries securely to agents - Maintain an audit trail of all binary operations
Understanding Binary Management¶
Architecture¶
The binary management system consists of several components:
- Binary Storage: Files are stored in
<data_dir>/binaries/<version_id>/
- Local Extraction: Server-side binaries are extracted to
<data_dir>/binaries/local/<version_id>/
- Version Tracking: Database tracks all binary versions with metadata
- Distribution: Agents download binaries via secure API endpoints
- Verification: Automatic integrity checking with MD5 hashes
Binary Types¶
Currently supported binary types: - hashcat
- Hashcat password cracking tool - john
- John the Ripper (future support)
Compression Types¶
Supported compression formats: - 7z
- 7-Zip archive format - zip
- ZIP archive format - tar.gz
- Gzip-compressed TAR archive - tar.xz
- XZ-compressed TAR archive
Uploading New Binaries¶
Via Admin API¶
To add a new binary version, use the admin API endpoint:
POST /api/admin/binary
Authorization: Bearer <admin_token>
Content-Type: application/json
{
"binary_type": "hashcat",
"compression_type": "7z",
"source_url": "https://github.com/hashcat/hashcat/releases/download/v6.2.6/hashcat-6.2.6.7z",
"file_name": "hashcat-6.2.6.7z"
}
The system will: 1. Download the binary from the specified URL 2. Calculate and store the MD5 hash 3. Verify the download integrity 4. Extract the binary for server-side use 5. Mark the version as active and verified
Upload Process¶
When a binary is uploaded:
- Download Phase: The system downloads the binary with retry logic (up to 3 attempts)
- Verification Phase: MD5 hash is calculated and stored
- Storage Phase: Binary is saved to
<data_dir>/binaries/<version_id>/
- Extraction Phase: Archive is extracted to
<data_dir>/binaries/local/<version_id>/
- Status Update: Version status is set to
verified
Version Management and Tracking¶
Database Schema¶
Binary versions are tracked in the binary_versions
table with the following fields:
Field | Type | Description |
---|---|---|
id | SERIAL | Unique version identifier |
binary_type | ENUM | Type of binary (hashcat, john) |
compression_type | ENUM | Compression format |
source_url | TEXT | Original download URL |
file_name | VARCHAR(255) | Stored filename |
md5_hash | VARCHAR(32) | MD5 checksum |
file_size | BIGINT | File size in bytes |
created_at | TIMESTAMP | Creation timestamp |
created_by | UUID | User who added the version |
is_active | BOOLEAN | Whether version is active |
last_verified_at | TIMESTAMP | Last verification time |
verification_status | VARCHAR(50) | Status: pending, verified, failed, deleted |
Verification Status¶
Binary versions can have the following statuses: - pending
- Initial state, download/verification in progress - verified
- Successfully downloaded and verified - failed
- Download or verification failed - deleted
- Binary has been deleted
Listing Versions¶
To list all binary versions:
Query parameters: - type
- Filter by binary type - active
- Filter by active status (true/false) - status
- Filter by verification status
Getting Latest Version¶
Agents can retrieve the latest active version:
Platform-Specific Considerations¶
Linux¶
The system automatically handles Linux-specific binary names: - Checks for both hashcat
and hashcat.bin
- Sets executable permissions (0750) on extracted binaries
Windows¶
- Looks for
hashcat.exe
in extracted archives - Handles Windows-specific path separators
Archive Extraction¶
The extraction process intelligently handles common archive structures: - Single directory archives: Contents are moved to the target directory - Multi-file archives: All files are extracted as-is - Nested structures: Properly flattened during extraction
Binary Synchronization to Agents¶
Agent Download Process¶
Agents download binaries through the following process:
- Version Check: Agent queries for the latest active version
- Download Request: Agent requests binary download by version ID
- Authentication: API key authentication is required
- Streaming Download: Binary is streamed to the agent
- Local Verification: Agent verifies MD5 hash after download
API Endpoints for Agents¶
# Get latest version metadata
GET /api/binary/latest?type=hashcat
X-API-Key: <agent_api_key>
# Download specific version
GET /api/binary/download/{version_id}
X-API-Key: <agent_api_key>
Synchronization Protocol¶
The agent file sync system (agent/internal/sync/sync.go
) handles: - Concurrent downloads with configurable limits - Retry logic for failed downloads - Local caching to avoid re-downloads - Integrity verification with MD5 hashes
Updating and Replacing Binaries¶
Adding a New Version¶
To add a new version of hashcat:
- Upload the new version via the admin API
- The system automatically downloads and verifies it
- Previous versions remain available but can be deactivated
Deactivating Old Versions¶
This will: - Mark the version as inactive (is_active = false
) - Set verification status to deleted
- Remove the binary file from disk - Preserve the database record for audit purposes
Version Verification¶
To manually verify a binary's integrity:
This will: - Check if the file exists on disk - Recalculate the MD5 hash - Compare with stored hash - Update verification status and timestamp
Best Practices and Security¶
Security Considerations¶
- Source URLs: Only download binaries from trusted sources
- Official hashcat releases: https://github.com/hashcat/hashcat/releases
-
Verify SSL certificates for download sources
-
Hash Verification: Always verify MD5 hashes after download
- The system automatically calculates and stores hashes
-
Manual verification can be triggered via API
-
Access Control: Binary management requires admin privileges
- Only administrators can add/remove binaries
-
Agents have read-only access for downloads
-
File Permissions: Extracted binaries have restricted permissions (0750)
- Only the application user can execute binaries
- Group members have read access
Operational Best Practices¶
- Version Testing: Test new binary versions before deployment
- Upload to a test environment first
- Verify extraction and execution work correctly
-
Check compatibility with existing jobs
-
Retention Policy: Maintain a reasonable number of versions
- Keep at least 2-3 recent versions for rollback
- Delete very old versions to save storage space
-
Archive important versions externally
-
Monitoring: Regular verification of binary integrity
- Schedule periodic verification checks
- Monitor download failures in logs
-
Track agent synchronization success rates
-
Documentation: Document version changes
- Note any breaking changes between versions
- Track performance improvements
- Document known issues with specific versions
Storage Management¶
- Disk Space: Monitor available disk space
- Binary archives can be large (100MB+)
- Extracted binaries double the storage requirement
-
Plan for growth with multiple versions
-
Cleanup: Regular cleanup of old versions
- Delete inactive versions after confirming they're not needed
- Remove failed download attempts
- Clean up orphaned extraction directories
Troubleshooting¶
Common Issues¶
- Download Failures
- Check network connectivity to source URL
- Verify SSL/TLS certificates are valid
- Check firewall rules for outbound HTTPS
-
Review logs for specific error messages
-
Extraction Failures
- Ensure required tools are installed (7z, unzip, tar)
- Check disk space for extraction
- Verify archive isn't corrupted
-
Check file permissions on data directory
-
Verification Failures
- File may be corrupted during download
- Source file may have changed
- Disk errors could cause corruption
- Try re-downloading the binary
Log Locations¶
Binary management logs are written to: - Backend logs: Check for [Binary Manager]
entries - Download attempts: Look for HTTP client errors - Extraction logs: Command output is logged - Verification results: Hash comparison details
Manual Recovery¶
If automated processes fail:
- Manual Download: Download binary to a temporary location
- Manual Upload: Place in
<data_dir>/binaries/<version_id>/
- Update Database: Set correct hash and file size
- Manual Extraction: Extract to local directory
- Verify Permissions: Ensure correct file permissions
Version.json File¶
The versions.json
file in the repository root tracks component versions:
This file is used for: - Build-time version embedding - API version compatibility checks - Component version tracking - Release management
Note: This tracks KrakenHashes component versions, not binary tool versions.
API Reference¶
Admin Endpoints¶
Method | Endpoint | Description |
---|---|---|
POST | /api/admin/binary | Add new binary version |
GET | /api/admin/binary | List all versions |
GET | /api/admin/binary/{id} | Get specific version |
DELETE | /api/admin/binary/{id} | Delete/deactivate version |
POST | /api/admin/binary/{id}/verify | Verify binary integrity |
Agent Endpoints¶
Method | Endpoint | Description |
---|---|---|
GET | /api/binary/latest | Get latest active version |
GET | /api/binary/download/{id} | Download binary file |
Future Enhancements¶
Planned improvements to the binary management system:
- Automatic Updates: Check for new releases periodically
- Version Channels: Support for stable/beta/nightly channels
- Platform Detection: Automatic platform-specific binary selection
- Signature Verification: GPG signature verification for downloads
- Delta Updates: Differential updates for minor versions
- Binary Caching: CDN integration for faster agent downloads
- Performance Metrics: Track binary performance across versions