A Python SDK for modeling adversary capabilities against network anonymity protocols. This is an educational and defensive security research tool for understanding the threat landscape of anonymity technologies.
The SDK evaluates how different adversary tiers (from ISP-level to Nation-State) can detect and deanonymize users of common anonymity protocols (Tor, VPN, I2P, etc.) using 12 core detection techniques.
- 4 Adversary Tiers: ISP-Level, Corporate Security, APT, Nation-State — each with detailed capability matrices
- 12 Detection Techniques: Traffic analysis, timing correlation, DPI, DNS/WebRTC leakage, behavioral patterns, and more
- 5 Anonymity Protocols: Tor, VPN (single), VPN Chain (multi-hop), Proxy (SOCKS/HTTP), I2P
- Rule-Based Scoring Engine: Calculates detection probabilities with confidence intervals
- Report Generation: JSON and Markdown reports with risk scores and mitigation recommendations
- Protocol Comparison: Side-by-side analysis across protocols and adversary tiers
- MITRE ATT&CK References: Relevant technique IDs included throughout
- CLI + Python API: Use from command line or import as a library
# Clone the repository
cd threat_modeling_sdk
# Install in development mode
pip install -e .
# Verify installation
threat-model --version# Analyze Tor against a Nation-State adversary
threat-model analyze tor --adversary nation_state
# Analyze VPN against ISP-level adversary
threat-model analyze vpn --adversary isp# Compare Tor, VPN, and Proxy across all adversary tiers
threat-model compare tor vpn proxy
# Compare against a specific adversary
threat-model compare tor vpn vpn_chain --adversary apt# JSON report
threat-model report tor --format json --output tor_report.json
# Markdown report
threat-model report tor --format markdown --output tor_report.md
# Default: JSON, nation_state adversary
threat-model report vpnthreat-model list-adversaries
threat-model list-protocols
threat-model list-techniquesfrom threat_modeling import ScoringEngine, ReportGenerator
from threat_modeling import list_adversaries, list_protocols, get_protocol
# Initialize the scoring engine
engine = ScoringEngine()
# Analyze a single protocol vs adversary
result = engine.analyze("tor", "nation_state")
print(f"Risk Score: {result.overall_risk_score}/100")
print(f"Risk Level: {result.risk_level}")
print(f"Confidence: {result.confidence_low} - {result.confidence_high}")
# View per-technique breakdown
for tr in result.technique_results:
print(f" {tr.technique_name}: {tr.detection_probability:.0%}")
# Compare multiple protocols
comparison = engine.compare(["tor", "vpn", "proxy"])
# Generate reports
gen = ReportGenerator(engine)
json_report = gen.to_json(result)
md_report = gen.to_markdown(result)
# Save to files
gen.save_report(result, "tor_analysis.json", fmt="json")
gen.save_report(result, "tor_analysis.md", fmt="markdown")
# Save comparison
gen.save_comparison(comparison, "comparison.md", fmt="markdown")
# Browse protocol details
tor = get_protocol("tor")
print(f"Protocol: {tor.name}")
print(f"Layers: {tor.anonymity_layers}")
print(f"Strengths: {tor.strengths}")threat_modeling_sdk/
├── setup.py # Package configuration
├── README.md # This file
├── samples/ # Sample output reports
│ ├── tor_nation_state_report.json
│ ├── tor_nation_state_report.md
│ └── protocol_comparison.md
└── threat_modeling/ # Main package
├── __init__.py # Public API exports
├── cli.py # CLI interface
├── data/ # Data models
│ ├── adversaries.py # 4 adversary tier definitions
│ ├── protocols.py # 5 protocol definitions
│ └── techniques.py # 12 detection techniques
├── engines/
│ └── scoring.py # Rule-based scoring engine
└── reports/
└── generator.py # JSON & Markdown report generation
The scoring engine uses a rule-based probabilistic model:
- Per-technique detection probability =
technique_effectiveness(protocol) × adversary_capability(technique) - Overall risk score = Union of independent events:
1 - Π(1 - p_i), scaled to 0-100 - Confidence intervals are based on adversary tier certainty (narrower for well-understood adversaries)
| Score Range | Level |
|---|---|
| 0 – 24 | Low |
| 25 – 49 | Moderate |
| 50 – 74 | High |
| 75 – 100 | Critical |
Relevant MITRE ATT&CK techniques referenced throughout the SDK:
- T1040 — Network Sniffing
- T1071 — Application Layer Protocol
- T1090 — Proxy (and T1090.3 Multi-hop Proxy)
- T1557 — Adversary-in-the-Middle
- T1573 — Encrypted Channel
- T1583/T1584 — Acquire/Compromise Infrastructure
- T1590 — Gather Victim Network Information
- T1599 — Network Boundary Bridging
- T1600 — Weaken Encryption
This tool is designed for educational and defensive security research purposes only. It helps security professionals, researchers, and privacy advocates understand the threat landscape for anonymity technologies. It does not provide tools for attacking or deanonymizing users.
MIT License