Apktool MCP服务器
   
一个强大的 模型上下文协议(MCP)服务器 这暴露了 Apktool 工具 Android APK分析和逆向工程功能。与 Gemini CLI 通过自然语言命令提供人工智能驱动的APK安全分析、隐私审计和逆向工程指导。
🚀 特性
🔍 全面的APK分析
- 分解APK 提取资源、清单和smali代码
- 分析权限 以及用于安全评估的应用程序组件
- 提取字符串资源 并检测硬编码的秘密
- 搜索smali代码 针对特定模式和安全漏洞
- 重新编译修改后的APK 更改后
🤖 AI驱动的工作流程
- 自然语言命令 用于复杂的APK分析任务
- 自动化安全审计 基于人工智能生成的洞察
- 隐私合规性检查 GDPR/CCPA分析
- 逐步逆向工程 指导
- 智能漏洞检测 风险评估
🛠 8核心工具
| 工具 | 说明 |
|---|---|
decode_apk | 解压缩APK文件以提取所有组件 |
build_apk | 从修改后的源目录重新编译APK |
install_framework | 安装用于系统应用程序分析的系统框架 |
analyze_manifest | 解析AndroidManifest.xml以获取权限和组件 |
extract_strings | 使用区域设置支持提取字符串资源 |
list_permissions | 枚举所有请求的权限 |
find_smali_references | 在反编译的smali代码中搜索模式 |
get_apk_info | 获取基本的APK元数据和信息 |
📋 专业分析提示
- 证券分析:全面脆弱性评估
- 隐私审计:数据收集和合规性分析
- 逆向工程指南:逐步分析工作流程
📦 安装
先决条件
1.Java JDK 8+ (Apktool要求)
# Ubuntu/Debian
sudo apt update && sudo apt install default-jdk
# macOS (Homebrew)
brew install openjdk
# Verify installation
java -version2. 药房 (核心依赖)
# Option 1: Package manager (recommended)
# Ubuntu/Debian
sudo apt install apktool
# macOS
brew install apktool
# Option 2: Manual installation
# Download from https://ibotpeaches.github.io/Apktool/install/
# Verify installation
apktool --version3.Python 3.10+
python3 --version # Should be 3.10 or higher安装说明
1.克隆存储库
git clone https://github.com/SecFathy/APktool-MCP.git
cd APktool-MCP2.创建虚拟环境
python3 -m venv venv
source venv/bin/activate # Linux/macOS
# or
venv\Scripts\activate # Windows3.安装依赖项
pip install -r requirements.txt4.测试安装
python3 apktool_server.py
# Should start the MCP server successfully⚙️ 配置
Gemini CLI集成
1.安装Gemini CLI
# Follow instructions at https://github.com/google-gemini/gemini-cli2.配置MCP服务器
编辑Gemini CLI配置文件:
- Linux/macOS:
~/.config/gemini-cli/config.json - 视窗:
%APPDATA%\gemini-cli\config.json
{
"mcpServers": {
"apktool": {
"command": "python3",
"args": ["/absolute/path/to/apktool_server.py"],
"env": {
"APKTOOL_WORK_DIR": "/path/to/workspace"
}
}
}
}Claude桌面集成(替代方案)
编辑Claude桌面配置:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"apktool": {
"command": "python3",
"args": ["/absolute/path/to/apktool_server.py"],
"env": {
"APKTOOL_WORK_DIR": "/path/to/workspace"
}
}
}
}🎯 使用示例
自然语言命令
# Start Gemini CLI
gemini
# Security Analysis
> "Analyze the APK at ./suspicious_app.apk for security vulnerabilities"
# Permission Analysis
> "What permissions does ./myapp.apk request and are any of them dangerous?"
# Code Analysis
> "Find any hardcoded API keys or secrets in ./social_app.apk"
# Privacy Audit
> "Generate a privacy compliance report for ./messenger_app.apk"
# Reverse Engineering
> "Help me understand how the authentication works in ./banking_app.apk"直接工具使用
# Decompile an APK
> Use decode_apk to decompile ./sample.apk
# Analyze permissions
> Use list_permissions on the decompiled directory ./sample
# Search for patterns
> Use find_smali_references to search for "crypto" in ./sample
# Extract strings
> Use extract_strings from ./sample for locale "en"
# Rebuild APK
> Use build_apk to recompile ./sample into ./sample_modified.apk引导式工作流程
# Run automated security analysis
> Run the security analysis prompt on ./target_app.apk
# Perform privacy audit
> Execute privacy audit workflow for ./social_media_app.apk
# Get reverse engineering guidance
> Use the reverse engineering guide for analyzing login functionality in ./app.apk📁 项目结构
apktool-mcp-server/
├── apktool_server.py # Main MCP server implementation
├── requirements.txt # Python dependencies
├── config.json # Example Gemini CLI configuration
├── README.md # This file
├── GEMINI.md # AI assistant context file
├── LICENSE # MIT license
├── examples/ # Usage examples and samples
│ ├── sample_analysis.py # Example analysis scripts
│ └── workflows/ # Common workflow examples
├── tests/ # Unit tests
│ ├── test_server.py # Server functionality tests
│ └── test_tools.py # Individual tool tests
└── docs/ # Additional documentation
├── SECURITY.md # Security guidelines
├── CONTRIBUTING.md # Contribution guidelines
└── TROUBLESHOOTING.md # Common issues and solutions🔒 安全考虑
⚠️ 重要安全注意事项
- 遵守法律:仅分析您拥有或有明确权限分析的APK
- 恶意软件风险:未知的APK可能包含恶意代码-在隔离环境中使用
- 数据隐私:解压缩的APK可能包含敏感的用户信息
- 工作区隔离:配置具有受限权限的专用工作区
- 工艺限制:服务器包括超时以防止资源耗尽
最佳实践
# Use dedicated workspace
export APKTOOL_WORK_DIR="/secure/isolated/workspace"
# Set appropriate permissions
chmod 750 /secure/isolated/workspace
# Monitor resource usage
htop # Watch memory and CPU during analysis
# Clean up after analysis
rm -rf /secure/isolated/workspace/*🧪 测试
运行单元测试
# Install test dependencies
pip install pytest pytest-asyncio
# Run all tests
pytest tests/
# Run with coverage
pytest --cov=apktool_server tests/手动测试
# Test server startup
python3 apktool_server.py
# Test with sample APK
# Download a sample APK and test basic functionality集成测试
# Test Gemini CLI integration
gemini
> /tools # Should list apktool tools
> Use decode_apk to analyze sample.apk🤝 贡献
我们欢迎捐款!请看 贡献.md 了解详情。
开发设置
# Clone and setup development environment
git clone https://github.com/SecFathy/APktool-MCP.git
cd APktool-MCP
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Run tests
pytest
# Format code
black apktool_server.py