Overview
ThePDFReportGenerator class creates professionally formatted PDF reports for security audits. It generates a complete audit report including cover page, executive summary, methodology, scanning results, penetration testing findings, risk analysis, and recommendations.
Class Definition
The Host object containing all audit data (IP, ports, vulnerabilities, credentials, etc.)
Attributes
The target host object containing audit results
Timestamp of report generation in format
YYYYMMDD_HHMMSSOutput file path:
outputs/REPORT_{ip}_{timestamp}.pdfReportLab stylesheet containing all paragraph styles
Color Constants
The following color constants are used throughout the report styling:Dark background color
#1a1a2e - used for headersAccent color
#e94560 - used for highlights and dividersLight background color
#f5f5f5 - used for alternating table rowsSuccess color
#27ae60 - used for positive resultsWarning color
#f39c12 - used for warningsMethods
generate()
Generates the complete PDF report by building all sections and writing to file.self.filename)
Side Effects:
- Creates PDF file in
outputs/directory - Prints confirmation message to stdout
_create_custom_styles()
Creates custom paragraph styles for the report sections.CoverTitle- 24pt centered title for cover pageCoverSubtitle- 14pt centered subtitleSectionTitle- 16pt section headersSubSection- 12pt subsection headersBodyText- 10pt justified body textAlertCritical- 10pt red text with light red backgroundAlertSuccess- 10pt green text for positive results
_add_cover_page()
Adds the cover page with audit overview information.ReportLab story list to append elements to
- Report title
- Framework version
- Target IP address
- Operating system detection
- Risk level
- Analysis date
- Summary statistics (open ports, vulnerabilities, credentials)
_add_index()
Adds table of contents listing all report sections.ReportLab story list to append elements to
- Resumen Ejecutivo
- Metodología
- Herramientas Utilizadas
- Fase de Escaneo (Reconocimiento)
- Fase de Penetración: Fuerza Bruta (WordPress)
- Fase de Penetración: Inyección SQL (DVWA)
- Credenciales Extraídas
- Análisis de Riesgo
- Recomendaciones de Seguridad
- Conclusiones
_add_executive_summary()
Adds executive summary with high-level findings.ReportLab story list to append elements to
- Target IP and OS
- Total open ports
- Total vulnerabilities by severity (critical, high, medium)
- Total credentials extracted
- Total directories discovered
- Overall risk level
_add_methodology()
Adds methodology section describing the audit process.ReportLab story list to append elements to
- Reconnaissance (Nmap, Gobuster)
- WordPress Brute Force (WPScan)
- SQL Injection (SQLMap)
- Risk Analysis
- Reporting
_add_tools()
Adds table of tools used during the audit.ReportLab story list to append elements to
- Kali Linux
- Nmap
- SQLMap
- WPScan
- Gobuster/Dirb
- Python 3
- ReportLab
_add_scanning_phase()
Adds reconnaissance phase findings (ports, services, directories).ReportLab story list to append elements to
- OS detection results
- Open ports table with service versions
- Directory enumeration results (up to 20 directories)
_add_bruteforce_phase()
Adds WordPress brute force attack findings.ReportLab story list to append elements to
- WPScan enumeration results
- Vulnerable plugins detected
- Credentials obtained via brute force
- Success/failure status
_add_sqli_phase()
Adds SQL injection attack findings against DVWA.ReportLab story list to append elements to
- SQLMap injection process
- Database dump results
- SQL injection vulnerabilities found
- Success/failure status
_add_credentials()
Adds table of all extracted credentials.ReportLab story list to append elements to
- Source (WordPress, SQLi, etc.)
- Username
- Password/Hash
- Cracked status (SI/NO)
_add_risk_analysis()
Adds comprehensive risk analysis and vulnerability details.ReportLab story list to append elements to
- Overall risk level
- Vulnerability count by severity
- Detailed vulnerability list with descriptions
- Risk calculation methodology
_add_recommendations()
Adds prioritized security recommendations.ReportLab story list to append elements to
- CRÍTICA (Critical)
- ALTA (High)
- MEDIA (Medium)
- BAJA (Low)
- Update WordPress and plugins
- Implement prepared statements
- Change compromised passwords
- Enable 2FA
- Install WAF (ModSecurity)
_add_conclusions()
Adds final conclusions and report metadata.ReportLab story list to append elements to
- Summary of findings
- Risk assessment conclusion
- Remediation urgency
- Ethical hacking disclaimer
- Generation timestamp
Usage Example
Report Structure
The generated PDF contains the following sections in order:- Cover Page - Audit overview and statistics
- Index - Table of contents
- Executive Summary - High-level findings
- Methodology - Audit process description
- Tools Used - Software and versions
- Scanning Phase - Reconnaissance results
- Brute Force Phase - WordPress attack findings
- SQL Injection Phase - DVWA attack findings
- Credentials Extracted - All compromised credentials
- Risk Analysis - Vulnerability assessment
- Recommendations - Prioritized remediation steps
- Conclusions - Final assessment
Page Layout
- Page Size: A4
- Margins: 2cm (top, bottom, left, right)
- Font: Helvetica family
- Color Scheme: Dark navy (
#1a1a2e) and red accent (#e94560)