Skip to main content

๐Ÿ”’ Android Persistence Research Framework

PyPI Version CI Build Status License: MIT Python 3.9+ Security Audited

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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. 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

๐Ÿ“ˆ 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

GitHub Stars GitHub Forks GitHub Issues

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

android_persistence-1.0.0.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

android_persistence-1.0.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

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

Hashes for android_persistence-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9405fb9e6f630dbd539444afe7d48ded75e3f2cd777685c5f465a3647b2aca54
MD5 07defcd3cd1e48424613b4647d05b961
BLAKE2b-256 19f17ddc0156700cc811492835bbf4f59db4087744dbf9ed2ad1a8274e97d75d

See more details on using hashes here.

Provenance

The following attestation bundles were made for android_persistence-1.0.0.tar.gz:

Publisher: publish.yml on zyekhabdul/android-persistence-research

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file android_persistence-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for android_persistence-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 299c0af68333417373651f8a59e7b7f800b6b9bbbacbea9180049a791be19ba2
MD5 436098646de7cb4f4b6c45df76f30f79
BLAKE2b-256 0a154373094fecdb9f6c57457ed00d86f8c0a851970b208222d275acdc195382

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page