zyekhabdul/android-persistence-research
GitHub: zyekhabdul/android-persistence-research
一款用于检测、分析和记录Android持久化机制的防御性安全研究框架,帮助安全人员评估应用持久化行为的风险。
Stars: 0 | Forks: 0
# 🔒 Android 持久化研究框架
## 🏗️ Android 持久化分析流程
```
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)"]
```
## 🎯 概述
Android 持久化研究框架是一款专门的安全研究工具,旨在检测、分析和记录 Android 的持久化机制。它为研究人员和安全专业人员提供了一个强大的平台,用于了解应用程序如何在 Android 设备上实现持久化。
**核心功能**:
- 🔍 自动检测 10 多种持久化机制
- 📊 风险评分和严重性评估
- 🛡️ 基于证据的缓解建议
- 📝 多格式报告生成 (JSON/HTML/PDF)
- 🔬 全面的研究文档
- ⚡ 针对大量 APK 集合的批量处理
## ⚠️ 免责声明
**仅供研究**:本框架专为合法的安全研究、教育目的以及授权的防御性安全分析而设计。未经适当授权擅自分析应用程序可能会违反相关法律法规和道德标准。
**使用要求**:
- ✅ 仅分析您拥有或获得明确授权进行分析的应用程序
- ✅ 仅在受控、经授权的测试环境中使用
- ✅ 遵守所有当地的法律法规
- ✅ 遵循负责任的披露实践
## 🚀 快速开始
### 安装
```
# 克隆 repository
git clone https://github.com/yourusername/android-persistence-analysis.git
cd android-persistence-analysis
# 创建虚拟环境
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
```
### 基础分析
```
# 分析单个 APK
python -m src.persistence_detector myapp.apk -o findings.json
# 在 Python 中查看分析
python examples/basic_analysis.py myapp.apk
# 批量处理 APK 目录
python examples/batch_processing.py /path/to/apks/
```
## 📚 文档
| 文档 | 用途 |
|----------|---------|
| [安装指南](docs/INSTALLATION.md) | 设置与依赖安装 |
| [使用指南](docs/USAGE.md) | 命令行与 API 使用方法 |
| [API 参考](docs/API_REFERENCE.md) | 完整的 API 文档 |
| [研究方法论](docs/RESEARCH_METHODOLOGY.md) | 分析方法与验证 |
| [调查报告](research/findings.md) | 研究结论与统计数据 |
| [持久化向量](research/persistence_vectors.md) | 详细的持久化技术 |
| [缓解策略](research/mitigation_techniques.md) | 防御方法 |
| [参考资源](research/references.md) | 学术论文与相关资源 |
## 🏗️ 项目结构
```
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
```
## 🔑 核心特性
### 1. **全面的持久化检测**
检测多种 Android 持久化机制:
- ✅ Broadcast Receivers (BOOT_COMPLETED 等)
- ✅ Services (START_STICKY, Foreground)
- ✅ JobScheduler 和 WorkManager
- ✅ Intent Filters 和 Component Hijacking
- ✅ Content Provider 漏洞
- ✅ Native Library Hooks
- ✅ 系统级持久化
### 2. **风险评估**
- 基于严重程度的分类 (CRITICAL, HIGH, MEDIUM, LOW)
- 置信度评分 (0-100%)
- 整体风险得分计算
- 对比分析
### 3. **智能建议**
- 基于证据的缓解策略
- 每项缓解措施的有效性评级
- 实施难度评估
- 用于修复的代码示例
### 4. **专业报告**
- **JSON 导出**:机器可读的发现结果
- **HTML 报告**:交互式可视化
- **PDF 文档**:专业的可打印报告
- **自定义格式**:可扩展的报告生成
### 5. **研究级分析**
- 学术级文档
- 全面的案例研究
- 统计分析
- 方法论文档
## 📊 分析输出
### 发现结果示例
```
{
"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 = (MAX_SEVERITY / 5) * 100 + (MATCH_COUNT * 5)
Example: 4 high-risk findings = (4/5)*100 + (4*5) = 80 + 20 = 100
```
## 🔬 研究发现
### 数据集统计
- **已分析应用总数**:1,247
- **具有持久化行为的应用**:923 (74%)
- **严重问题 (Critical Issues)**:156 (13%)
- **每个应用的平均发现数量**:3.2
### 主要发现
| 持久化类型 | 检出率 | 有效性 |
|------------------|-----------------|----------------|
| BOOT_COMPLETED | 65% | 95% |
| Sticky Service | 45% | 90% |
| JobScheduler | 42% | 70% |
| Native Hooks | 34% | 85% |
| Intent Filter | 72% | 30% |
**有关详细的研究结果,请参阅 [findings.md](research/findings.md)。**
## 🛡️ 防御策略
### 检测到的威胁 → 缓解措施映射
```
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
```
**有关全面的策略,请参阅 [mitigation_techniques.md](research/mitigation_techniques.md)。**
## 💻 使用示例
### Python API
```
from src.persistence_detector import PersistenceDetector
from src.report_generator import ReportGenerator
# 分析 APK
detector = PersistenceDetector()
detector.analyze_apk("myapp.apk")
# 获取 findings
findings = detector.get_findings()
risk_score = detector.get_risk_score()
# 生成报告
generator = ReportGenerator()
generator.add_findings(findings)
generator.generate_json_report("findings.json")
generator.generate_html_report("findings.html")
# 显示摘要
detector.print_summary()
```
### 命令行
```
# 基础分析
python -m src.persistence_detector app.apk
# 使用输出文件
python -m src.persistence_detector app.apk -o findings.json
# 详细输出
python -m src.persistence_detector app.apk -v
# 批量分析
python examples/batch_processing.py /path/to/apks/
```
## 🧪 测试
运行测试套件:
```
# 所有测试
pytest tests/ -v
# 使用 coverage
pytest tests/ -v --cov=src --cov-report=html
# 特定测试文件
pytest tests/test_detector.py -v
# Coverage 报告
coverage run -m pytest tests/
coverage report -m
```
**当前覆盖率**:70%+
## 📦 依赖项
### 核心依赖
- **androguard** (4.1.2) - APK 分析
- **capstone** (5.0.1) - 反汇编引擎
- **pycryptodomex** (3.20.0) - 加密组件
- **requests** (2.31.0) - HTTP 客户端
### 可选依赖
- **reportlab** (4.0.7) - PDF 生成
- **pytest** (7.4.3) - 测试框架
有关完整列表,请参阅 [requirements.txt](requirements.txt)。
## 📄 许可证
本项目基于 **Apache License 2.0** 授权 - 详情请参阅 [LICENSE](LICENSE) 文件。
## 🔗 资源
### 学术论文
- [Android 安全研究综述](https://ieeexplore.ieee.org/)
- [恶意软件分析技术](https://researchgate.net/)
- [APE: Android Package Exploration](https://arxiv.org/)
### 工具与文档
- [Androguard](https://github.com/androguard/androguard)
- [Android 安全文档](https://developer.android.com/security)
- [OWASP 移动安全](https://owasp.org/)
### 社区
- [Google Android 安全团队](https://security.googleblog.com/)
- [USENIX Security](https://www.usenix.org/)
- [IEEE S&P](https://www.ieee-security.org/)
## 📞 支持
- **文档**:参阅 [docs/](docs/) 目录
- **问题**:[GitHub Issues](https://github.com/yourusername/android-persistence-analysis/issues)
- **邮箱**:contact@example.com
- **研究**:参阅 [research/](research/) 目录
## 📈 项目状态
- ✅ 核心功能已完成
- ✅ 单元测试已实现
- ✅ 文档已定稿
- ✅ 已提供示例
- ⏳ 欢迎社区贡献
## 🎓 引用
如果您在研究中使用本框架,请引用:
```
@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}
}
```
## 📋 更新日志
### 版本 1.0.0 (2024)
- ✨ 初始版本
- 🎯 核心持久化检测
- 📊 报告生成
- 🛡️ 缓解建议
- 📚 全面文档
- 🧪 单元测试套件
**由安全研究团队 ❤️ 制作**
[](https://github.com/yourusername/android-persistence-analysis)
[](https://github.com/yourusername/android-persistence-analysis)
[](https://github.com/yourusername/android-persistence-analysis/issues)
*最后更新:2024*
标签:Android, DSL, Python, 云安全监控, 威胁情报, 安全规则引擎, 开发者工具, 持久化机制, 无后门, 逆向工具, 静态分析