GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - re100io/frida-agent-example: Example Frida agent written in TypeScript

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

47 Commits
47 Commits

Folders and files

NameName
Last commit message
Last commit date
agent
agent
 
 
.gitignore
.gitignore
 
 
Chrome测试使用说明.md
Chrome测试使用说明.md
 
 
README.md
README.md
 
 
SystemServer测试说明.md
SystemServer测试说明.md
 
 
fix-frida-compile.js
fix-frida-compile.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
快速测试指南.md
快速测试指南.md
 
 
目录结构说明.md
目录结构说明.md
 
 
解决方案总结.md
解决方案总结.md
 
 

Repository files navigation

Frida Android 测试框架

一个完整的Frida TypeScript框架,用于Android应用和系统服务的动态分析和Hook测试。

🎯 功能特性

📱 Chrome浏览器测试

  • WebView监控: Hook Chrome WebView的URL加载、JavaScript执行
  • 网络拦截: 监控HTTP/HTTPS请求
  • 脚本注入: 向Chrome页面注入测试代码
  • 实时日志: 详细的操作反馈和错误报告

🔧 System Server监控

  • 系统服务Hook: 监控ActivityManager、PackageManager等核心服务
  • Binder通信: 实时监控进程间通信
  • 权限检查: 追踪系统权限验证
  • 系统类发现: 动态枚举已加载的系统类

🚀 快速开始

环境准备

# 克隆项目
git clone <repository-url>
cd frida-agent-example

# 安装依赖
npm install

# 确保Android设备连接并启用USB调试
adb devices

Chrome测试

1. 简单连接测试 (推荐新手)

npm run test-simple

验证基础连接功能,包括:

  • 设备连接
  • Chrome进程附加
  • Java反射测试
  • 应用信息获取

2. 完整Chrome测试

npm run test-chrome

加载完整的Chrome监控Agent,包含:

  • WebView Hook监控
  • JavaScript接口Hook
  • 网络请求拦截
  • 脚本注入功能

System Server测试

1. 简单System Server测试

npm run test-system-simple

基础system_server连接测试:

  • 系统服务枚举
  • 核心服务访问验证
  • 系统属性读取

2. System Server Hooks测试 (推荐)

node test-system-hooks.js

简化版系统服务监控:

  • 基础系统服务Hook
  • Binder通信监控
  • 系统类动态发现

3. 完整System Server测试

npm run test-system-server

完整的系统服务监控框架。

📋 可用脚本

类别 脚本命令 功能描述 推荐场景
Chrome测试 npm run test-simple 简单Chrome连接测试 🟢 新手入门
npm run test-chrome 完整Chrome功能测试 🔵 完整监控
npm run test-chrome-compressed 压缩版Agent测试 🟡 性能优化
System Server npm run test-system-simple 简单system_server测试 🟢 基础验证
npm run test-system-hooks 简化版Hooks测试 🔵 推荐使用
npm run test-system-server 完整system_server测试 🔴 高级功能
构建 npm run build-chrome 构建Chrome Agent 📦 标准构建
npm run build-chrome-compressed 构建压缩版Agent 📦 优化构建
npm run build-system-server 构建System Server Agent 📦 系统服务
npm run build-system-server-hooks 构建简化Hooks Agent 📦 轻量级
npm run build-all 构建所有Agent 📦 批量构建
开发 npm run watch-chrome Chrome文件监听自动编译 🔧 开发模式
npm run watch-system-server System Server文件监听 🔧 开发模式
npm run clean 清理构建文件 🧹 清理

快速命令参考

🚀 推荐的测试流程

# 1. 首次使用 - Chrome基础测试
npm run test-simple

# 2. Chrome完整功能测试
npm run test-chrome

# 3. System Server监控 (需要root)
npm run test-system-hooks

🔧 开发工作流

# 启动开发模式 (自动重编译)
npm run watch

# 在另一个终端运行测试
npm run test-simple

📦 构建命令

# 构建所有Agent
npm run build-all

# 清理重建
npm run clean && npm run build-all

# 单独构建
npm run build-chrome              # 只构建Chrome
npm run build-system-server       # 只构建System Server

📁 项目结构

├── agent/                          # Agent源码目录
│   ├── logger.ts                   # 通用日志工具
│   ├── com_android_chrome/         # Chrome浏览器Agent
│   │   ├── index.ts               # 完整Chrome监控Agent
│   │   └── simple-test.ts         # Chrome简单测试Agent
│   └── system_server/             # System Server Agent
│       ├── index.ts               # 完整System Server监控Agent
│       ├── simple-hooks.ts        # 简化版Hooks Agent
│       └── simple-test.ts         # System Server简单测试Agent
├── dist/                          # 编译输出目录
│   ├── _agent_chrome.js          # Chrome完整Agent (编译后)
│   ├── _agent_chrome_simple.js   # Chrome简单测试Agent (编译后)
│   ├── _agent_system_server.js   # System Server完整Agent (编译后)
│   ├── _agent_system_server_hooks.js    # System Server Hooks Agent (编译后)
│   └── _agent_system_server_simple.js  # System Server简单测试Agent (编译后)
├── test-chrome-connection.js       # Chrome连接测试脚本
├── simple-test-connection.js       # 简单Chrome测试脚本
├── test-system-server.js          # System Server测试脚本
├── simple-system-server-test.js   # 简单System Server测试脚本
├── test-system-hooks.js           # System Server Hooks测试脚本
├── fix-frida-compile.js           # 编译修复工具
├── Chrome测试使用说明.md          # Chrome测试详细文档
├── SystemServer测试说明.md        # System Server测试详细文档
├── 快速测试指南.md                # 快速入门指南
└── 目录结构说明.md                # 新目录结构说明

🎯 测试目标

Chrome浏览器

  • 目标进程: Chrome主进程 (避免zygote和sandbox进程)
  • 监控内容: WebView活动、网络请求、JavaScript执行
  • 注入功能: 页面脚本注入、DOM操作测试

System Server

  • 目标进程: system_server (PID通常为几百)
  • 监控服务: 287个系统服务 (ActivityManager、PackageManager等)
  • 通信监控: Binder调用、权限检查、服务交互

📊 使用示例

🎯 Chrome测试示例

运行简单测试

$ npm run test-simple

成功输出:

🧪 开始简单Chrome连接测试...

🔍 查找设备...
找到 4 个设备:
  1. Local System (local)
  2. Local Socket (remote)  
  3. GDB Remote Stub (remote)
  4. Android Emulator 5554 (usb)
✅ 连接到设备: Android Emulator 5554

🔍 查找Chrome进程...
找到Chrome进程:
  1. Chrome (PID: 25380)
✅ 选择进程: Chrome

🎯 附加到进程...
✅ 成功附加到进程

📦 构建简单Agent...
✅ Agent构建完成

🚀 加载Agent...
✅ Java.perform() 执行成功
📋 Java版本: 0
📦 当前应用: com.android.chrome
🎉 基础测试完成!
✅ Agent加载成功

🎉 测试完成!按Ctrl+C退出...

运行完整Chrome测试

$ npm run test-chrome

Hook输出示例:

📨 [Agent]: 🚀 Chrome Agent 初始化中...
📨 [Agent]: ✅ WebView hooks 设置完成
📨 [Agent]: ✅ JavaScript Interface hooks 设置完成
📨 [Agent]: 📦 当前应用包名: com.android.chrome
📨 [Agent]: 📋 应用版本: 113.0.5672.136
📨 [Agent]: 🔍 找到 156 个Chrome/WebView相关类

# 当用户在Chrome中浏览网页时会看到:
📨 [Agent]: 📱 WebView.loadUrl() 被调用: https://www.google.com
📨 [Agent]: 🔧 WebView.evaluateJavascript() 被调用: (function(){...})

🔧 System Server测试示例

运行System Server Hooks测试

$ npm run test-system-hooks

成功输出:

🧪 开始System Server Hooks测试...

🔍 查找设备...
✅ 连接到设备: Android Emulator 5554

✅ 找到system_server进程: PID 548

🎯 附加到system_server进程...
✅ 成功附加到system_server进程

📦 构建System Server简化Hooks Agent...
✅ Agent构建完成

🚀 加载System Hooks Agent...
✅ System Hooks Agent加载成功

📨 [Agent]: 🔧 简化版 System Server Agent 初始化中...
📨 [Agent]: ✅ ActivityManagerService 基础hooks 设置完成
📨 [Agent]: ✅ PackageManagerService 基础hooks 设置完成
📨 [Agent]: ✅ PowerManagerService 基础hooks 设置完成
📨 [Agent]: 📋 系统服务列表 (前10个):
📨 [Agent]:   1. DockObserver
📨 [Agent]:   2. SurfaceFlinger
📨 [Agent]:   3. accessibility
📨 [Agent]:   4. activity
📨 [Agent]:   5. alarm
📨 [Agent]: 总计: 287 个系统服务
📨 [Agent]: ✅ activity 服务可访问
📨 [Agent]: ✅ package 服务可访问
📨 [Agent]: 📱 系统属性:
📨 [Agent]:   ro.build.version.release: 14
📨 [Agent]:   ro.product.model: sdk_gphone64_arm64

# 实时系统活动监控:
📨 [Agent]: 🔗 Binder调用来自PID: 919
📨 [Agent]: 🔗 Binder调用来自PID: 25380  # Chrome进程
📨 [Agent]: 🔍 系统类: com.android.server.wifi.WifiService
📨 [Agent]: 🔍 系统类: com.android.server.telecom.CallsManager

🎮 交互式测试

当Agent运行时,你可以在Android设备上执行操作来触发Hook:

Chrome操作触发

  • 🌐 打开网页 → 触发 WebView.loadUrl() Hook
  • 🔧 执行JavaScript → 触发 evaluateJavascript() Hook
  • 🔗 添加JS接口 → 触发 addJavascriptInterface() Hook

System Server操作触发

  • 🚀 启动应用 → 触发 ActivityManagerService Hook
  • 📦 安装APK → 触发 PackageManagerService Hook
  • 🔋 按电源键 → 触发 PowerManagerService Hook
  • 📞 拨打电话 → 触发大量Binder调用

🔍 脚本功能对比

测试类型 权限要求 复杂度 功能范围 适用场景
Chrome简单测试 USB调试 ⭐ 基础连接验证 新手入门、环境验证
Chrome完整测试 USB调试 ⭐⭐⭐ WebView监控、脚本注入 浏览器行为分析
System简单测试 Root ⭐⭐ 系统服务枚举 系统环境检查
System Hooks测试 Root ⭐⭐⭐ 基础服务Hook、Binder监控 系统行为监控
System完整测试 Root ⭐⭐⭐⭐⭐ 全面系统服务Hook 深度系统分析

🎯 选择指南

🟢 新手推荐路径

1. npm run test-simple           # 验证Chrome连接
2. npm run test-system-simple    # 验证System Server连接  
3. npm run test-system-hooks     # 体验系统监控

🔵 开发者路径

1. npm run test-chrome           # Chrome深度分析
2. npm run test-system-hooks     # 系统服务监控
3. 自定义Agent开发               # 根据需求定制

🔴 研究者路径

1. npm run test-system-server    # 完整系统监控
2. 修改Agent源码               # 深度定制Hook
3. 长期监控分析                # 系统行为研究

⚠️ 注意事项

权限要求

  • Chrome测试: 需要USB调试权限
  • System Server测试: 需要root权限 (模拟器通常已root)

设备兼容性

  • Android版本: 支持Android 7.0+ (推荐Android 10+)
  • 设备类型: 物理设备、模拟器均可 (推荐使用模拟器测试)
  • Chrome版本: 支持所有版本 (正式版、Beta、Dev、Canary)

性能影响

  • Hook会影响目标应用性能 (通常可接受)
  • System Server监控可能影响系统稳定性 (建议短时间测试)
  • 建议在测试设备上使用,避免影响日常使用

安全考虑

  • 仅在授权设备上使用
  • 不要在生产环境长时间运行
  • 注意保护敏感信息不被泄露

🔧 故障排除

常见问题

设备连接问题

# 检查设备连接
adb devices

# 重启adb服务
adb kill-server && adb start-server

进程附加失败

  • 确保目标应用正在运行
  • 检查Frida server权限
  • 对于system_server需要root权限

Agent构建失败

# 重新安装依赖
npm install

# 清理并重新构建
npm run clean && npm run build

📚 详细文档

  • Chrome测试使用说明.md - Chrome测试完整指南
  • SystemServer测试说明.md - System Server监控详解
  • 快速测试指南.md - 新手入门指南

🎉 开发工作流

持续开发

# 启动文件监听 (推荐开发时使用)
npm run watch

代码编辑

推荐使用Visual Studio Code,支持:

  • TypeScript代码补全
  • 实时类型检查
  • Frida API智能提示

测试流程

  1. 修改Agent代码
  2. 运行对应的测试脚本
  3. 查看实时输出和日志
  4. 根据需要调整Hook逻辑

🤝 贡献指南

欢迎提交Issue和Pull Request来改进这个框架!

📄 许可证

本项目仅供学习和研究使用,请遵守相关法律法规。

About

Example Frida agent written in TypeScript

www.frida.re/

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.