Hybrid LLM + deterministic network security validation framework with MITM risk analysis.
This project generates network configurations from natural language prompts, validates them with rule-based checks, and supports MITM analysis from simulated traffic, PCAP files, live capture, and dataset-derived flows.
- LLM-based config generation for
nginx,iptables, anddns - Deterministic validation engine with severity-tagged violations
- Risk scoring for generated configurations
- Auto-remediation loop for insecure outputs
- Model-vs-model comparison on a shared evaluation dataset
- MITM detection pipeline (demo, pcap, live, dataset)
- Adversarial prompt evaluation (security persona probing)
- Flask dashboard for runs, samples, remediation, comparison, and adversarial views
main.py: CLI entrypoint and command dispatcherconfig.py: shared enums/dataclasses/constantsgenerator/: LLM generation modulevalidator/: deterministic rule engine and rule setsevaluator/: evaluation workflow + metricsremediator/: iterative fix enginecomparator/: multi-model comparisonmitm/: network and dataset MITM analysis + attack path reportdatasets/: dataset loader, LLM threat interpretation, integrated report builderdashboard/: Flask web apptests/: unit tests for validation logicdataset.json: standard benchmark samplesadversarial_dataset.json: adversarial/security-persona sampleslogs/: runtime logsoutputs/: generated artifacts and reports
- Python 3.10+
- Groq API key for LLM-backed commands
Install dependencies:
pip install -r requirements.txtFrom the project root:
cd code/netconfig_llm_v3
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCreate .env with at least:
GROQ_API_KEY=your_groq_api_key_hereOptional model override:
GROQ_MODEL=llama-3.1-8b-instantAll commands below are run from code/netconfig_llm_v3.
python demo.pypython main.py rules --target nginx
python main.py rules --target iptables
python main.py rules --target dnspython main.py generate --target nginx --prompt "Create a secure nginx reverse proxy for api.example.com with HTTPS redirect and HSTS."
python main.py generate --target iptables --prompt "Create secure iptables rules for a web server with SSH only from 10.0.1.0/24."
python main.py generate --target dns --prompt "Create secure BIND config for authoritative DNS with recursion disabled and rate limiting."python main.py evaluate
python main.py evaluate --max-samples 10 --delay 2python main.py remediate --target nginx --prompt "Set up nginx quickly on port 80 without TLS." --max-iter 3 --delay 2python main.py compare --model-a llama-3.1-8b-instant --model-b mixtral-8x7b-32768
python main.py compare --max-samples 10 --delay 2Demo mode:
python main.py mitm --mode demoPCAP mode:
python main.py mitm --mode pcap --pcap-file path/to/capture.pcapLive capture mode:
sudo python main.py mitm --mode live --interface en0 --count 500 --timeout 60python main.py analyze --target nginx --prompt "Create secure nginx for api.example.com."Demo traffic mode:
python main.py evaluate-mitm --mitm-mode demo --max-samples 10Dataset traffic mode:
python main.py evaluate-mitm --mitm-mode dataset --traffic-dataset datasets/data/MachineLearningCVE/Monday-WorkingHours.pcap_ISCX.csv --max-samples 20 --max-traffic-rows 5000PCAP folder mode:
python main.py evaluate-mitm --mitm-mode pcap --mitm-pcap-folder path/to/pcaps --max-samples 10Live mode:
sudo python main.py evaluate-mitm --mitm-mode live --interface en0 --count 300 --timeout 30 --max-samples 5python adversarial_eval.py
python adversarial_eval.py --max-samples 20 --delay 2python main.py dashboard --port 5001From the repository root, you can also use the launcher shim:
python main.py dashboard --port 5001Open in browser:
http://localhost:5001
Run from code/netconfig_llm_v3:
docker compose up -d --build
docker compose psSet secrets in .env in the same folder as docker-compose.yml:
GROQ_API_KEY=your_groq_api_key_here
NETCONFIG_SECRET_KEY=your_long_random_secretGenerate a strong secret key:
python -c "import secrets; print(secrets.token_urlsafe(64))"The dashboard is exposed at:
http://localhost:5001
Use the included script to perform a full health check + sample run verification:
chmod +x smoketest.sh
./smoketest.shFor deployment, run the Flask app behind Gunicorn from code/netconfig_llm_v3:
gunicorn -w 2 -b 0.0.0.0:5001 wsgi:appSet NETCONFIG_SECRET_KEY in production and place the app behind a reverse proxy or PaaS.
pytest -qOr run only validator tests:
pytest tests/test_validator.py -qGenerated files are written under outputs/, for example:
run_<id>_details.jsonrun_<id>_metrics.jsonrun_<id>_events.jsoncomparison_<id>_records.jsoncomparison_<id>_summary.jsonremediation_<id>_<target>.jsonmitm_<id>_<mode>.jsonanalyze_<id>_<target>.jsone2e_mitm_<id>.jsonadversarial_<id>_records.jsonadversarial_<id>_summary.json
logs/pipeline.log: structured pipeline logslogs/violations.log: security finding-focused logs
- The active runtime path is rooted in
main.pyand top-level packages. files/contains integration/backup-style material and is not the primary runtime entrypoint.- Cache/generated artifacts (
__pycache__,.pytest_cache,logs,outputs) can be cleaned as needed.