How paresh2806/pcap-analyzer works
Project type and purpose
• This is a single‐container, full-stack Python application with a Streamlit-based frontend and a modular backend for PCAP parsing and analysis.
• Its purpose is to load PCAP files, decode and filter network traffic, perform protocol‐level and geo-IP analysis, and present interactive visualizations.
File structure
• Top-level files:
• app.py – Streamlit app entry point (UI layer)
• main.py – secondary entry or orchestration script
• requirements.txt – Python dependencies
• .devcontainer/ – development environment config
• JupyterNotebook.ipynb – exploratory analysis notebook
• Directories:
• utils/ – core backend modules
– data_extract.py, file_extract.py – raw data ingestion
– pcap_decode.py, pcap_filter.py – decoding & filtering pipeline
– proto_analyzer.py, flow_analyzer.py – protocol/flow analysis
– ipmap_tools.py, GeoIP/GeoLite2-City.mmdb – geo-IP lookup
– packet_fake.py – synthetic packet generator
– upload_tools.py – file-upload handling
– protocol/ & warning/ – rule/config repositories for decoders and alerts
• images/ – demo assets and screenshots
• sample/ftp*.pcap – example PCAP files
README for additional insights
• Confirms use of Python 3.10 and Streamlit
• Highlights interactive loading, filtering, visualization, and support for many protocols
• No external microservices; all analysis is local
Components and relationships
a. Main components:
• Streamlit UI (app.py)
• Upload Service (utils/upload_tools.py)
• File Extraction & Ingestion (file_extract.py)
• Decode & Filter Pipeline (pcap_decode.py → pcap_filter.py)
• Analysis Modules (proto_analyzer.py, flow_analyzer.py, ipmap_tools.py + GeoIP DB)
• Rule Configs (utils/protocol/, utils/warning/)
• Visualization & Reporting (Streamlit components in app.py)
• Data Store (GeoLite2-City.mmdb)
• Example PCAP Data (sample.pcap, ftp-data.pcap)
b. Data flow & interactions:
1. User uploads PCAP via UI → upload_tools
2. file_extract reads raw bytes → pcap_decode parses packet headers/payloads
3. pcap_filter applies user-driven filters
4. proto_analyzer & flow_analyzer compute protocol stats and session flows
5. ipmap_tools queries GeoIP DB for locations
6. Warning engine consults warning rules to flag anomalies
7. Results are piped back to Streamlit for tables, charts, and geo-plots
c. Architectural patterns/design principles:
• Pipeline pattern: clear, linear stages of ingestion → decode → filter → analyze → display
• Modular layering: each analysis concern lives in its own module under utils/
• Configuration-as-code: protocol and warning definitions externalized in subfolders
• Single container deployment: all components run in the same Python process
d. Key technologies:
• Python 3.10, Streamlit
• pandas, scapy or pyshark (in requirements.txt) for PCAP handling
• MaxMind GeoLite2 (MMDB file)
• Custom rule-sets in utils/protocol and utils/warning