Ravindra1t/AppPoet
GitHub: Ravindra1t/AppPoet
基于神经符号流水线与本地大语言模型的 Android 应用漏洞自动化分析与评分框架。
Stars: 0 | Forks: 0
# AppPoet - 用于 Android 漏洞发现的智能体神经符号流水线
## 架构概述
AppPoet 是一个基于 Python 的模块化流水线,使用神经符号分析技术自动发现 Android 漏洞。
### 项目结构
```
AppPoet_Project/
├── data/
│ ├── raw_apks/ # Input APK files
│ ├── decompiled_source/ # APKtool output
│ └── kaggle_data.csv # Sample training datavigne
├── src/
│ ├── extraction/ # Data extraction modules
│ ├── memory/ # Caching system
│ ├── llm_engine/ # LLM interface
│ ├── classifier/ # Neural network classifier
│ └── orchestrator/ # Pipeline orchestration
├── requirements.txt # Python dependencies
├── demo_training.py # Training pipeline demo
├── demo_apk_analysis.py # APK analysis demo
└── demo_simple.py # Architecture verification
```
## 核心模块
### 1. 提取模块
- **apktool_decoder.py**:使用 subprocess 进行 APK 反编译,使用 xml.etree.ElementTree 解析 AndroidManifest.xml
- **androguard_parser.py**:DEX 字节码方法映射和受限 API 调用隔离
- **kaggle_loader.py**:基于 Pandas 的 CSV 数据加载,用于训练数据集
### 2. 记忆模块
- **cache_manager.py**:O(1) 基于 JSON 的哈希映射,用于 LLM 响应缓存,防止 CPU 瓶颈
### 3. LLM 引擎
- **prompt_templates.py**:用于 Permission、API、URL 和诊断视图的多行字符串模板
- **qwen_interface.py**:使用 qwen2.5-coder:7b 模型向 localhost:11434 发送 HTTP POST 请求的接口
### 4. 分类器模块
- **text_embedder.py**:使用 all-MiniLM-L6-v2 模型的 SentenceTransformer 嵌入
- **pytorch_mlp.py**:精确的 1152→512→256→1 架构和 Sigmoid 激活函数的神经网络
### 5. 编排模块
- **pipeline_kaggle.py**:用于 Kaggle 数据集成的训练流水线
- **pipeline_local_apk.py**:用于本地 APK 分析的推理流水线
## 安装与设置
### 前置条件
- Python 3.8+
- 搭载 qwen2.5-coder:7b 模型的 Ollama
- APKtool(用于 APK 反编译)
### 安装
```
# 克隆项目结构(已创建)
cd AppPoet_Project
# 安装 Python 依赖
pip install -r requirements.txt
# 启动 Ollama 服务器
ollama serve
ollama pull qwen2.5-coder:7b
```
## 使用方法
### 训练流水线
```
py demo_training.py
```
- 加载 Kaggle 样本数据
- 生成基于 LLM 的安全摘要
- 训练神经网络分类器
- 将模型保存为 `vulnerability_classifier.pth`
### APK 分析流水线
```
py demo_apk_analysis.py
```
- 从 APK 文件中提取特征
- 生成缓存的 LLM 摘要
- 评估漏洞评分
- 生成诊断报告
### 架构验证
```
py demo_simple.py
```
- 验证项目结构
- 显示模块概览
- 展示流水线能力
## 工程规格
- **语言**:纯 Python(无 C++)
- **注释**:无(数学上高度密集的代码)
- **优化**:最少的中间变量
- **模块化**:独立的流水线执行
- **缓存**:O(1) 基于 JSON 的 LLM 响应缓存
- **架构**:MLP 分类器的 1152 维输入
## 团队协作
=
## 流水线工作流
1. **数据提取**:APK 文件 → 权限、API、URL
2. **LLM 分析**:通过 qwen2.5-coder:7b 生成特征摘要
3. **嵌入生成**:文本 → 384 维向量
4. **分类**:组合的 1152 维输入 → 漏洞评分
5. **报告生成**:诊断性安全评估
## 性能特点
- **O(1) 缓存**:防止冗余的 LLM 调用
- **批处理**:高效的嵌入生成
- **模块化执行**:独立的流水线组件
- **优化的架构**:数学上高度密集的实现
标签:AI安全, AI风险缓解, Androguard, Android安全, Apex, APKTool, APK静态分析, Chat Copilot, CI/CD安全, DAST, DLL 劫持, Llama, LLM, Python, PyTorch, Qwen2.5, SentenceTransformer, Unmanaged PE, URL发现, 人工智能, 代码反编译, 凭据扫描, 向量化, 多层感知机, 大语言模型, 安全检测, 安卓漏洞挖掘, 恶意软件分析, 文本嵌入, 无后门, 本地大模型, 机器学习, 深度学习, 用户模式Hook绕过, 目录枚举, 神经符号系统, 移动安全, 网络安全, 自动化安全审计, 逆向工具, 隐私保护