# Conducting Mobile Application Penetration Test

> 对 Android 和 iOS 应用执行移动应用渗透测试，使用 Frida、Objection 和 MobSF 识别不安全的数据存储、证书固定绕过、API 漏洞、二进制保护缺陷和运行时操控问题。

- Skill: `killvxk/conducting-mobile-application-penetration-test` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add killvxk/conducting-mobile-application-penetration-test`
- Raw SKILL.md: https://api.skillmd.com/api/skills/killvxk/conducting-mobile-application-penetration-test/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: Apache-2.0
- Author: killvxk (https://skillmd.com/u/killvxk)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/killvxk/conducting-mobile-application-penetration-test

---


# 执行移动应用渗透测试

## 概述

移动应用渗透测试遵循 OWASP 移动应用安全测试指南（MASTG）和移动应用安全验证标准（MASVS），评估 Android 和 iOS 应用的安全性。测试涵盖应用二进制文件的静态分析、动态运行时分析、API 通信安全、数据存储评估和逆向工程抵抗力。

## 前置条件

- 应用 APK/IPA 文件或 TestFlight/Play Store 访问权限
- 已 Root 的 Android 设备或模拟器（Genymotion、Android Studio AVD）
- 已越狱的 iOS 设备或 Corellium 云实例
- 工具：Frida、Objection、MobSF、Jadx、Burp Suite、adb、Ghidra
- OWASP MASTG 检查清单

## Android 测试

### 静态分析

```bash
# 使用 jadx 反编译 APK
jadx -d output_dir target.apk

# 搜索硬编码的密钥
grep -rn "api_key\|secret\|password\|token\|firebase" output_dir/sources/

# 检查 AndroidManifest.xml
# 查找：导出的组件、debuggable=true、allowBackup=true
grep -i "exported\|debuggable\|allowBackup\|android:permission" output_dir/resources/AndroidManifest.xml

# MobSF 自动化静态分析
# 上传 APK 到 MobSF Web 界面（http://localhost:8000）
# 或使用 REST API：
curl -F "file=@target.apk" http://localhost:8000/api/v1/upload \
  -H "Authorization: <api_key>"

# 检查不安全的网络安全配置
cat output_dir/resources/res/xml/network_security_config.xml
# 查找：cleartextTrafficPermitted="true"、带用户证书的 trust-anchors

# 分析原生库
find output_dir/resources/lib -name "*.so" -exec strings {} \; | grep -i "key\|secret"
```

### 动态分析

```bash
# 通过 adb 安装到设备
adb install target.apk

# 在设备上启动 Frida 服务器
adb push frida-server /data/local/tmp/
adb shell chmod 755 /data/local/tmp/frida-server
adb shell /data/local/tmp/frida-server &

# Objection — 运行时探索
objection -g com.target.app explore

# 在 Objection 内：
# 列出 Activity 和 Service
android hooking list activities
android hooking list services

# 绕过 Root 检测
android root disable

# 绕过 SSL 固定
android sslpinning disable

# 转储 Keystore
android keystore list

# 枚举 SharedPreferences
android hooking search classes SharedPreferences

# 监控剪贴板
android clipboard monitor

# 探索文件系统
env
ls /data/data/com.target.app/
file download /data/data/com.target.app/shared_prefs/
file download /data/data/com.target.app/databases/
```

### 数据存储测试

```bash
# 检查 SharedPreferences 中的敏感数据
adb shell cat /data/data/com.target.app/shared_prefs/*.xml

# 检查 SQLite 数据库
adb pull /data/data/com.target.app/databases/app.db
sqlite3 app.db ".dump" | grep -i "password\|token\|session"

# 检查外部存储中的数据
adb shell ls /sdcard/Android/data/com.target.app/

# 检查日志中的敏感数据
adb logcat -d | grep -i "token\|password\|session\|api_key"

# 备份提取
adb backup -apk -shared com.target.app -f backup.ab
java -jar abe.jar unpack backup.ab backup.tar
tar xf backup.tar
```

### 网络流量分析

```bash
# 在设备上配置 Burp 代理
# 设置 > WiFi > 代理 > 手动 > 192.168.1.100:8080
# 在设备上安装 Burp CA 证书

# 对于有证书固定的应用：
# 方法 1：Objection
objection -g com.target.app explore
android sslpinning disable

# 方法 2：Frida 脚本
frida -U -f com.target.app -l ssl_pinning_bypass.js --no-pause

# 方法 3：修补 APK
# 使用 apktool 反编译，修改 network_security_config.xml，重新打包
apktool d target.apk -o decompiled/
# 编辑 res/xml/network_security_config.xml 以信任用户 CA
apktool b decompiled/ -o patched.apk
jarsigner -keystore my.keystore patched.apk alias_name
```

## iOS 测试

### 静态分析

```bash
# 解密 IPA（从越狱设备）
# 使用 frida-ios-dump
python3 dump.py com.target.app

# 或在设备上使用 Clutch
Clutch -d com.target.app

# 使用 class-dump 分析二进制文件
class-dump -H TargetApp -o headers/
grep -rn "password\|token\|secret\|apiKey" headers/

# 检查 Info.plist
plutil -p Payload/TargetApp.app/Info.plist
# 查找：ATS 例外、URL 方案、导出的 UTI

# 检查不安全的 API 连接
grep -i "http://" headers/*.h
grep -i "NSAllowsArbitraryLoads" Payload/TargetApp.app/Info.plist
```

### 动态分析（iOS）

```bash
# iOS 上的 Frida
frida -U -f com.target.app -l ios_bypass.js --no-pause

# iOS 的 Objection
objection -g com.target.app explore

# 在 Objection 内：
ios sslpinning disable
ios jailbreak disable
ios keychain dump
ios plist cat NSUserDefaults
ios cookies get
ios nsurlcredentialstorage dump

# 检查存储在钥匙串中的密钥
objection -g com.target.app explore --startup-command 'ios keychain dump'

# 检查数据保护类
objection -g com.target.app explore --startup-command 'ios info binary'
```

### API 测试

```bash
# 通过 Burp Suite 测试捕获的 API 调用：

# 认证绕过
# 修改 JWT 令牌，测试算法混淆（none、HS256 vs RS256）

# IDOR 测试
# 修改 API 请求中的用户标识符

# 速率限制
# 暴力破解 OTP/PIN 端点

# 输入验证
# 测试 API 参数中的注入

# 业务逻辑
# 在请求中操控价格、数量、订阅级别
```

## OWASP MASVS 检查清单

| 类别 | 测试项 | 状态 |
|----------|------|--------|
| MASVS-STORAGE-1 | 系统日志中的敏感数据 | [ ] |
| MASVS-STORAGE-2 | 备份中的敏感数据 | [ ] |
| MASVS-STORAGE-3 | IPC 中的敏感数据 | [ ] |
| MASVS-CRYPTO-1 | 适当的密码学 API | [ ] |
| MASVS-AUTH-1 | 本地认证绕过 | [ ] |
| MASVS-NETWORK-1 | 使用受信任 CA 的 TLS | [ ] |
| MASVS-NETWORK-2 | 证书固定 | [ ] |
| MASVS-PLATFORM-1 | 导出组件已安全保护 | [ ] |
| MASVS-CODE-1 | 代码混淆 | [ ] |
| MASVS-RESILIENCE-1 | Root/越狱检测 | [ ] |

## 参考资料

- OWASP MASTG: https://mas.owasp.org/MASTG/
- OWASP MASVS: https://mas.owasp.org/MASVS/
- Frida: https://frida.re/
- Objection: https://github.com/sensepost/objection
- MobSF: https://github.com/MobSF/Mobile-Security-Framework-MobSF
- JADX: https://github.com/skylot/jadx

