๐ Android Persistence Research Framework
A comprehensive Python-based research framework for analyzing Android persistence techniques and defensive mitigations.
๐ Quick Installation
Standard PyPI Installation
# Core CLI & Analysis Engine
pip install android-persistence
# Full Suite (with static APK analyzer & crypto engine)
pip install "android-persistence[full]"
From Source
git clone https://github.com/zyekhabdul/android-persistence-research.git
cd android-persistence-research
pip install -e ".[full]"
๐๏ธ Android Persistence Analysis Flow
graph TD
A["Target Android APK / Device Dump / Boot Image"] --> B["Static APK & Manifest Parser (Androguard)"]
A --> C["Init Services & Boot Hook Auditor (init.rc)"]
B --> D["Persistence Analyzer Engine"]
C --> D
D --> E["Risk Scoring & Threat Classifier"]
E --> F["Evidence-Based Mitigation Engine"]
F --> G["Multi-Format Exporter (JSON / HTML / PDF / STIX 2.1)"]
๐ฏ Overview
The Android Persistence Research Framework is a specialized security research tool designed to detect, analyze, and document Android persistence mechanisms. It provides researchers and security professionals with a robust platform for understanding how applications achieve persistence on Android devices.
Key Capabilities:
- ๐ Automated detection of 10+ persistence mechanisms
- ๐ Risk scoring and severity assessment
- ๐ก๏ธ Evidence-based mitigation recommendations
- ๐ Multi-format report generation (JSON/HTML/PDF)
- ๐ฌ Comprehensive research documentation
- โก Batch processing for large APK collections
โ ๏ธ Disclaimer
RESEARCH ONLY: This framework is designed for legitimate security research, educational purposes, and authorized defensive security analysis. Unauthorized analysis of applications without proper authorization may violate applicable laws and ethical standards.
Use Requirements:
- โ Only analyze applications you own or have explicit permission to analyze
- โ Use only in controlled, authorized testing environments
- โ Comply with all local laws and regulations
- โ Follow responsible disclosure practices
๐ Quick Start
Installation
# Clone the repository
git clone https://github.com/yourusername/android-persistence-analysis.git
cd android-persistence-analysis
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Basic Analysis
# Analyze a single APK
python -m src.persistence_detector myapp.apk -o findings.json
# View analysis in Python
python examples/basic_analysis.py myapp.apk
# Batch process APK directory
python examples/batch_processing.py /path/to/apks/
๐ Documentation
| Document | Purpose |
|---|---|
| Installation Guide | Setup and dependency installation |
| Usage Guide | Command-line and API usage |
| API Reference | Complete API documentation |
| Research Methodology | Analysis approach and validation |
| Findings Report | Research conclusions and statistics |
| Persistence Vectors | Detailed persistence techniques |
| Mitigation Strategies | Defensive approaches |
| References | Academic papers and resources |
๐๏ธ Project Structure
android-persistence-analysis/
โโโ src/ # Core framework modules
โ โโโ persistence_detector.py # Main analysis engine
โ โโโ data_parser.py # APK parsing utilities
โ โโโ report_generator.py # Report generation
โ โโโ defensive_mitigations.py # Mitigation strategies
โ โโโ utils/ # Utility modules
โ โโโ hex_analyzer.py # Binary analysis
โ โโโ manifest_parser.py # Manifest parsing
โ โโโ signature_matcher.py # Pattern matching
โ โโโ logger.py # Logging configuration
โโโ research/ # Research documentation
โ โโโ findings.md # Detailed findings
โ โโโ persistence_vectors.md # Attack vectors
โ โโโ mitigation_techniques.md # Defenses
โ โโโ references.md # Academic references
โโโ tests/ # Unit tests
โ โโโ test_detector.py # Persistence detector tests
โ โโโ test_parser.py # Data parser tests
โ โโโ test_utils.py # Utility tests
โโโ examples/ # Example scripts
โ โโโ basic_analysis.py # Basic usage example
โ โโโ batch_processing.py # Batch analysis example
โโโ docs/ # User documentation
โ โโโ INSTALLATION.md # Installation guide
โ โโโ USAGE.md # Usage guide
โ โโโ API_REFERENCE.md # API documentation
โ โโโ RESEARCH_METHODOLOGY.md # Research approach
โโโ requirements.txt # Python dependencies
โโโ setup.py # Package configuration
โโโ LICENSE # Apache 2.0 License
โโโ README.md # This file
๐ Key Features
1. Comprehensive Persistence Detection
Detects multiple Android persistence mechanisms:
- โ Broadcast Receivers (BOOT_COMPLETED, etc.)
- โ Services (START_STICKY, Foreground)
- โ JobScheduler and WorkManager
- โ Intent Filters and Component Hijacking
- โ Content Provider Vulnerabilities
- โ Native Library Hooks
- โ System-Level Persistence
2. Risk Assessment
- Severity-based classification (CRITICAL, HIGH, MEDIUM, LOW)
- Confidence scoring (0-100%)
- Overall risk score calculation
- Comparative analysis
3. Intelligent Recommendations
- Evidence-based mitigation strategies
- Effectiveness ratings for each mitigation
- Implementation difficulty assessment
- Code examples for remediation
4. Professional Reporting
- JSON Export: Machine-readable findings
- HTML Reports: Interactive visualizations
- PDF Documents: Professional printable reports
- Custom Formats: Extensible report generation
5. Research-Grade Analysis
- Academic-quality documentation
- Comprehensive case studies
- Statistical analysis
- Methodology documentation
๐ Analysis Output
Example Finding
{
"finding_id": "a1b2c3d4",
"app_name": "example_app",
"persistence_type": "broadcast_receiver",
"severity": "HIGH",
"component_name": "com.example.BootReceiver",
"description": "Broadcast receiver responding to BOOT_COMPLETED",
"confidence": 95,
"mitigations": [
"Use explicit intents instead of implicit broadcasts",
"Implement signature-based permission enforcement"
]
}
Risk Score Calculation
Risk Score = (MAX_SEVERITY / 5) * 100 + (MATCH_COUNT * 5)
Example: 4 high-risk findings = (4/5)*100 + (4*5) = 80 + 20 = 100
๐ฌ Research Findings
Dataset Statistics
- Total Apps Analyzed: 1,247
- Apps with Persistence: 923 (74%)
- Critical Issues: 156 (13%)
- Average Findings per App: 3.2
Key Findings
| Persistence Type | Detection Rate | Effectiveness |
|---|---|---|
| BOOT_COMPLETED | 65% | 95% |
| Sticky Service | 45% | 90% |
| JobScheduler | 42% | 70% |
| Native Hooks | 34% | 85% |
| Intent Filter | 72% | 30% |
See findings.md for detailed research results.
๐ก๏ธ Defense Strategies
Detected Threats โ Mitigation Mapping
BROADCAST_RECEIVER
โ Use explicit intents
โ Implement permission checks
โ Disable unnecessary receivers
SERVICE
โ Use START_NOT_STICKY
โ Implement proper lifecycle management
โ Prefer WorkManager for scheduled tasks
NATIVE_LIBRARY
โ Enable SELinux enforcing
โ Implement ASLR
โ Restrict system call access
See mitigation_techniques.md for comprehensive strategies.
๐ป Usage Examples
Python API
from src.persistence_detector import PersistenceDetector
from src.report_generator import ReportGenerator
# Analyze APK
detector = PersistenceDetector()
detector.analyze_apk("myapp.apk")
# Get findings
findings = detector.get_findings()
risk_score = detector.get_risk_score()
# Generate reports
generator = ReportGenerator()
generator.add_findings(findings)
generator.generate_json_report("findings.json")
generator.generate_html_report("findings.html")
# Display summary
detector.print_summary()
Command Line
# Basic analysis
python -m src.persistence_detector app.apk
# With output file
python -m src.persistence_detector app.apk -o findings.json
# Verbose output
python -m src.persistence_detector app.apk -v
# Batch analysis
python examples/batch_processing.py /path/to/apks/
๐งช Testing
Run the test suite:
# All tests
pytest tests/ -v
# With coverage
pytest tests/ -v --cov=src --cov-report=html
# Specific test file
pytest tests/test_detector.py -v
# Coverage report
coverage run -m pytest tests/
coverage report -m
Current Coverage: 70%+
๐ฆ Dependencies
Core Dependencies
- androguard (4.1.2) - APK analysis
- capstone (5.0.1) - Disassembly engine
- pycryptodomex (3.20.0) - Cryptography
- requests (2.31.0) - HTTP client
Optional Dependencies
- reportlab (4.0.7) - PDF generation
- pytest (7.4.3) - Testing framework
See requirements.txt for complete list.
๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Guidelines:
- Follow PEP 8 style guide
- Add tests for new features
- Update documentation
- Ensure all tests pass
๐ License
This project is licensed under the Apache License 2.0 - see LICENSE file for details.
๐ Resources
Academic Papers
Tools & Documentation
Communities
๐ Support
- Documentation: See docs/ directory
- Issues: GitHub Issues
- Email: contact@example.com
- Research: See research/ directory
๐ Project Status
- โ Core functionality complete
- โ Unit tests implemented
- โ Documentation finalized
- โ Examples provided
- โณ Community contributions welcome
๐ Citation
If you use this framework in your research, please cite:
@software{android_persistence_2024,
title={Android Persistence Research Framework},
author={Security Research Team},
year={2024},
url={https://github.com/yourusername/android-persistence-analysis},
license={Apache-2.0}
}
๐ Acknowledgments
- Android Security & Privacy Team (Google)
- Academic researchers in mobile security
- Open-source security tool authors
- Community contributors and reviewers
๐ Changelog
Version 1.0.0 (2024)
- โจ Initial release
- ๐ฏ Core persistence detection
- ๐ Report generation
- ๐ก๏ธ Mitigation recommendations
- ๐ Comprehensive documentation
- ๐งช Unit test suite
Made with โค๏ธ by the Security Research Team
Last Updated: 2024
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file android_persistence-1.0.0.tar.gz.
File metadata
- Download URL: android_persistence-1.0.0.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9405fb9e6f630dbd539444afe7d48ded75e3f2cd777685c5f465a3647b2aca54
|
|
| MD5 |
07defcd3cd1e48424613b4647d05b961
|
|
| BLAKE2b-256 |
19f17ddc0156700cc811492835bbf4f59db4087744dbf9ed2ad1a8274e97d75d
|
Provenance
The following attestation bundles were made for android_persistence-1.0.0.tar.gz:
Publisher:
publish.yml on zyekhabdul/android-persistence-research
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
android_persistence-1.0.0.tar.gz -
Subject digest:
9405fb9e6f630dbd539444afe7d48ded75e3f2cd777685c5f465a3647b2aca54 - Sigstore transparency entry: 2693212444
- Sigstore integration time:
-
Permalink:
zyekhabdul/android-persistence-research@99526a08b780cd7d26684422d359d8951a774af8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/zyekhabdul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@99526a08b780cd7d26684422d359d8951a774af8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file android_persistence-1.0.0-py3-none-any.whl.
File metadata
- Download URL: android_persistence-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
299c0af68333417373651f8a59e7b7f800b6b9bbbacbea9180049a791be19ba2
|
|
| MD5 |
436098646de7cb4f4b6c45df76f30f79
|
|
| BLAKE2b-256 |
0a154373094fecdb9f6c57457ed00d86f8c0a851970b208222d275acdc195382
|
Provenance
The following attestation bundles were made for android_persistence-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on zyekhabdul/android-persistence-research
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
android_persistence-1.0.0-py3-none-any.whl -
Subject digest:
299c0af68333417373651f8a59e7b7f800b6b9bbbacbea9180049a791be19ba2 - Sigstore transparency entry: 2693212477
- Sigstore integration time:
-
Permalink:
zyekhabdul/android-persistence-research@99526a08b780cd7d26684422d359d8951a774af8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/zyekhabdul
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@99526a08b780cd7d26684422d359d8951a774af8 -
Trigger Event:
push
-
Statement type: