Database Configuration
AutoPentestX uses SQLite to store scan results, vulnerabilities, exploits, and historical data. All scan data is persisted to enable reporting, analysis, and audit trails.Database Location
Default database path (configurable inconfig.json):
Configuration Options
Database type (currently only SQLite is supported)
Path to SQLite database file (relative or absolute)
Enable automatic database backups before modifications
Number of days to retain scan data (0 = keep forever)
Database Schema
AutoPentestX creates five main tables to store scan data:1. Scans Table
Stores high-level scan metadata and results.Column Descriptions
Unique scan identifier (auto-incremented)
Target IP address or domain name
Timestamp when scan was initiated
Detected operating system from fingerprinting
Total scan duration in seconds
Total number of ports scanned
Number of open ports discovered
Total vulnerabilities identified
Overall risk level: CRITICAL, HIGH, MEDIUM, LOW, or INFO
Scan status:
completed, in_progress, interrupted, or failed2. Ports Table
Stores information about discovered ports and services.Column Descriptions
Foreign key reference to parent scan
Port number (1-65535)
Protocol:
tcp or udpPort state:
open, closed, or filteredDetected service name (e.g.,
http, ssh, mysql)Service version string if detected
3. Vulnerabilities Table
Stores vulnerability findings and CVE data.Column Descriptions
Vulnerability name or title
Detailed description of the vulnerability
CVE identifier (e.g.,
CVE-2024-1234)CVSS score (0.0 - 10.0)
Risk classification: CRITICAL, HIGH, MEDIUM, LOW, or UNKNOWN
Whether known exploits exist (1 = yes, 0 = no)
4. Web Vulnerabilities Table
Stores web-specific vulnerabilities from Nikto and SQLMap.Column Descriptions
Full URL where vulnerability was discovered
Vulnerability type (e.g.,
XSS, SQL Injection, Directory Listing)Severity level: HIGH, MEDIUM, or LOW
5. Exploits Table
Stores exploitation attempts and results.Column Descriptions
Foreign key reference to vulnerability being exploited
Name of exploit module or technique
Status:
success, failed, or simulatedJSON-encoded exploit result data
Database Operations
TheDatabase class in modules/database.py provides methods for all database operations:
Initialization
Creating a Scan
Updating Scan Results
Inserting Port Data
Inserting Vulnerabilities
Retrieving Scan Data
Listing All Scans
Querying the Database
You can query the database directly using SQLite tools:Useful SQL Queries
Find High-Risk Scans
Get All Vulnerabilities for a Target
Count Exploitable Vulnerabilities
View Open Ports Across All Scans
Backup and Maintenance
Manual Backup
Database Cleanup
The
retention_days setting automatically removes old scans. Set to 0 to keep all data indefinitely.Optimize Database
Data Export
Export to CSV
Export to JSON
Database Connection Management
The Database class automatically:- Creates the database file if it doesn’t exist
- Creates all tables on first connection
- Handles connection errors gracefully
- Commits transactions after each operation
Error Handling
Common database errors and solutions:| Error | Cause | Solution |
|---|---|---|
database is locked | Multiple processes accessing database | Close other connections, wait and retry |
unable to open database file | Incorrect path or permissions | Check path and file permissions |
no such table | Tables not created | Ensure create_tables() was called |
FOREIGN KEY constraint failed | Invalid reference ID | Verify parent record exists |
Related Resources
- Configuration Settings - Configure database path and retention
- Scan Options - CLI flags that affect database storage
- Architecture Overview - How database fits into AutoPentestX