Nouussair/attack-surface-mapper
0
๐ Attack Surface Mapper
A comprehensive Android APK security analysis tool that extracts manifests, detects vulnerabilities, and generates detailed security reports with ML-powered risk scoring.
๐ Features
- โ APK Manifest Extraction - Parse Android manifests and extract components
- โ Vulnerability Detection - Identify exposed components, risky permissions, debuggable apps
- โ ML-Based Risk Scoring - Predict attack surface severity with scikit-learn
- โ Interactive Web Interface - Upload APKs and view reports in real-time
- โ Export Options - Download reports as HTML or PDF
- โ Docker Support - Fully containerized for easy deployment
- โ Graph Visualization - Mermaid-based component relationship graphs
๐ Quick Start (Docker - Recommended)
Prerequisites
- Docker & Docker Desktop installed
Run the Web Interface
docker build -t attack-surface-mapper .
docker run -p 5000:5000 attack-surface-mapperThen open: http://localhost:5000
Upload an APK file and get a detailed security report instantly!
๐ป Local Development Setup
Prerequisites
- Python 3.12+ (or 3.13+)
- Virtual environment at
.venv - Java (for apktool)
- apktool.bat available at
C:\xampp\htdocs\projet\apktool.bat
Installation
# Activate virtual environment
& ".venv\Scripts\Activate.ps1"
# Install dependencies
pip install -r requirements.txtRun Tests
& ".venv\Scripts\python.exe" -m pytest tests\test_apk_extractor.pyRun CLI Parser (Example)
& ".venv\Scripts\python.exe" -c "from core.apk_extractor import analyze_apk; m = analyze_apk(r'C:\xampp\htdocs\projet\UnCrackable-Level2.apk'); print(m.package); print(len(m.activities)); print(len(m.services)); print(len(m.receivers)); print(len(m.providers))"Expected result for UnCrackable Level 2:
Package: owasp.mstg.uncrackable2
Activities: 1
Services: 0
Receivers: 0
Providers: 0Run Web Interface Locally
python ui_app.pyThen navigate to: http://localhost:5000
๐ Project Structure
attack-surface-mapper/
โโโ core/ # APK parsing & manifest extraction
โ โโโ apk_extractor.py # Main APK analysis
โ โโโ manifest_parser.py # Manifest XML parsing
โ โโโ component_model.py # Data models
โ โโโ test_parser.py
โโโ detection/ # Security vulnerability detection
โ โโโ risk_patterns.py # Risk rule definitions
โ โโโ pattern_registry.py # Pattern matching engine
โ โโโ fileprovider_checker.py
โโโ ai/ # ML-based threat scoring
โ โโโ feature_extractor.py # Feature engineering
โ โโโ surface_scorer.py # Risk scoring model
โ โโโ predict_large_model.py # Large model predictions
โ โโโ explainer.py # Model explainability
โ โโโ recommendation_engine.py # Security recommendations
โโโ graph/ # Component visualization
โ โโโ graph_model.py # Graph structure
โ โโโ mermaid_builder.py # Mermaid diagram generation
โ โโโ graph_exporter.py # Export formats
โโโ reports/ # Report generation
โ โโโ report_generator.py # HTML report creation
โโโ ui/ # Web interface
โ โโโ cli.py # CLI commands
โ โโโ report_generator.py
โโโ tests/ # Unit & integration tests
โโโ Dockerfile # Docker configuration
โโโ requirements.txt # Python dependencies
โโโ demo.py # CLI demo script
โโโ ui_app.py # Flask web application
โโโ main.py # Entry point
โโโ config.yaml # Configuration file๐ Team Task Breakdown
๐ Usage Examples
Docker (Recommended)
# Build image
docker build -t attack-surface-mapper .
# Run with web interface
docker run -p 5000:5000 attack-surface-mapper
# Use different port if 5000 is busy
docker run -p 5001:5000 attack-surface-mapper
# Then access at http://localhost:5001Local Python
# Run CLI demo
python demo.py
# Run specific APK analysis
python -c "from demo import run_pipeline; run_pipeline('path/to/app.apk', 'output_report.html')"
# Run tests
pytest tests/ -vโ๏ธ Configuration
Edit config.yaml to customize:
- Risk scoring thresholds
- Graph visualization settings
- Report templates
- Security patterns and CWE mappings
๐ Sample Report Output
The generated security report includes:
- ๐ APK metadata (package name, SDK version, etc.)
- ๐ด Critical/High/Medium/Low vulnerabilities
- ๐ Attack surface scoring breakdown
- ๐ Component relationship graph
- ๐ก Security recommendations
๐ ๏ธ Development Notes
- The workspace uses
.venv, not the global Python installation - Required packages:
lxml,dataclasses-json,pytest,flask,androguard,scikit-learn - Docker image is based on
python:3.12-slimwith Java & apktool pre-installed - Flask development server runs on
0.0.0.0:5000by default
๐ฆ Dependencies
See requirements.txt for the full list. Key dependencies:
- androguard - APK analysis framework
- lxml - XML parsing
- scikit-learn - ML models
- flask - Web framework
- jinja2 - Template engine
- pyyaml - Configuration
- pytest - Testing framework
- mermaid-cli - Graph visualization
๐ Troubleshooting
Port 5000 already in use?
docker run -p 5001:5000 attack-surface-mapper
# Access at http://localhost:5001Docker build fails?
docker build -t attack-surface-mapper . --no-cacheTest failures?
pytest tests/ -v --tb=short๐ License
See LICENSE file for details.
๐ฅ Contributing
- Create a feature branch
- Make your changes
- Write/update tests
- Ensure tests pass
- Submit a pull request
Refer to the team task breakdown above for contribution areas.
