How jeanrafaellourenco/pcap-forensics-toolkit works
Project type and purpose
• This is an open-source, command-line PCAP forensics toolkit implemented in Python.
• Its goal is to parse .pcap files (and hex dumps), detect suspicious activity (scans, C2, exfiltration, credential leaks, etc.), reconstruct files transferred over TCP, and generate reports in Markdown/PDF.
File structure
• All scripts live at the top level (no deep folder hierarchy), each acting as a CLI entry point:
• analisador.py / analisador_plus.py: hex parser + HTTP header extraction
• leitor_pcap.py: SCAPY-based packet reader/exporter
• extrator_arquivos_pcap.py: TCP reassembly + file extraction
• auditoria_forense_pcap.py / auditoria_forense_pcap_completo.py: forensic analysis + report generation
• md_para_html.py / md_para_pdf.py: Markdown → HTML/PDF conversion
• No dedicated src folder—implies a modular internal structure within each script (parsers, detectors, reporters).
Extract additional insights from the README
• Dependencies: Python ≥3.6, Scapy.
• Key features: advanced forensic detection, file reconstruction, hex decoding, report generation.
• Output: Markdown forensic reports and extracted files on disk.
a. Main components
1. CLI Layer
• Individual scripts (each script’s main() function)
2. Core Library Modules (grouped logically, not physically foldered)
• PCAP Loader (Scapy wrapper)
• Hex Interpreter
• TCP Session Reassembler
• File Signature Detector (magic-byte lookup)
• Packet/HTTP Analyzer (flags, headers, user-agent, referer)
• Forensic Detection Engine (SYN scans, C2 patterns, exfiltration, creds leak)
• Report Generator (Markdown builder)
• Converter (Markdown → HTML/PDF)
3. Storage & Output
• Extracted files directory (./arquivos_extraidos/)
• Report files (.md, .html, .pdf)
4. External Libraries
• Scapy
• Python stdlib (argparse, os, io)
b. Relationships and interactions
• CLI scripts invoke the PCAP Loader or Hex Interpreter.
• Loaded data flows into the Packet/HTTP Analyzer and/or TCP Reassembler.
• TCP Reassembler hands off reconstructed streams to the File Signature Detector.
• Packet/HTTP Analyzer and Detection Engine cooperate to produce forensic indicators.
• Detection Engine outputs structured findings to the Report Generator.
• Report Generator writes .md files.
• md_para_html / md_para_pdf take Markdown → produce HTML/PDF.
• Extractor script also writes binary files to the file system.
c. Architectural patterns & design principles
• Modular CLI façade over reusable core modules.
• Single-responsibility: each component (loader, analyzer, detector, reporter) has a clear role.
• Pipeline pattern: data flows through a sequence of processors.
• No persistent DB; all state is transient or written to files.
d. Key technologies & libraries
• Python 3.6+
• Scapy for packet parsing
• Magic-byte signatures for file extraction
• Markdown for report templating
Detailed capture of architectural elements
• Break out submodules (e.g., separate “HTTP header parser” from “packet flag decoder”).
• Parallel branches (e.g., one branch for forensic detection, another for file extraction).
• Transformation steps (Markdown → PDF/HTML).