How akshay-malolan/glitchcon works
Project Type and Purpose
• This is a full-stack malware-scanning application combining:
• A Python-based backend API (ai-malware-scanner/api)
• A React/Vite/Tailwind frontend (ai-malware-scanner/frontend/site)
• A CLI tool (scanner/full_scan.py)
• Static analysis (static_analysis) + dynamic analysis (dynamic_analysis) + a deep-learning model (models)
• Optional integrations: VirusTotal threat intel, Cuckoo sandbox
File Structure Analysis
• Top-level:
• api/ – Python web server (app.py, server.py) exposing REST endpoints
• frontend/site/ – Static React/Vite site with TSX components, context, hooks
• static_analysis/ & dynamic_analysis/ – Core scanning modules
• scanner/ – CLI entrypoint for full system or file/directory scans
• models/ – Pretrained model files and loader (cloud_model.py)
• utils/ – Helpers (alerts, threat_intel)
• scripts/train_model.py – ML training pipeline
• logs/ – Centralized logging
• requirements.txt, .env configuration for API keys
Key README Insights
• Workflow: user uploads file via UI or invokes CLI → API server orchestrates scan → static features extracted (LIEF) → ML model (PyTorch) classifies → suspicious samples optionally sent to sandbox (Cuckoo) → queries VirusTotal → aggregates results → JSON report returned.
• No traditional database; persistence via logs and JSON outputs.
a. Main Components
• Client Layer:
• Web UI (React/Vite)
• CLI Tool (scanner.full_scan)
• API Layer: Python server (Flask/FastAPI style in app.py/server.py)
• Core Services:
• StaticAnalysis Module (extract PE features)
• MLModel Service (load/classify via cloud_model.py + .keras/.pt)
• DynamicAnalysis Module (sandbox.py, realtime_monitor.py)
• ThreatIntel Service (VirusTotal API via utils/threat_intel.py)
• Alerts/Reporting (utils/alerts.py → JSON outputs, logging)
• Infrastructure & External Services:
• Cuckoo Sandbox (optional)
• VirusTotal API
• Logging subsystem (logs/ai_malware_scanner.log)
• Training Pipeline (scripts/train_model.py → models/)
b. Relationships & Data Flow
1. Client (UI or CLI) → HTTP/REST or direct Python call → API Server
2. API Server → invokes StaticAnalysis → raw features
3. API Server → passes features to MLModel (inference) → classification result
4. If flagged or on demand → API Server → DynamicAnalysis → sandbox tracing
5. API Server → queries ThreatIntel → enriches result
6. API Server → logs events → returns JSON response to Client
7. Separate: Training Script → trains new model → writes to models/
c. Architectural Patterns & Principles
• Modular monolith with clear separation:
• Presentation (React) vs Business Logic (API) vs Domain Services (analysis/model)
• Single-responsibility modules: each analysis step in its own folder
• Pluggable components: optional sandbox, threat-intel, deep scan vs fast scan
• Concurrency: multithreaded scanning (scanner.full_scan)
d. Key Technologies & Frameworks
• Backend: Python 3.8+, Flask/FastAPI style, LIEF, psutil, python-magic
• ML: PyTorch (classic_mlp.pt/.keras)
• Frontend: React, TypeScript, Vite, Tailwind CSS
• External: VirusTotal REST API, Cuckoo sandbox