Giter Site home page Giter Site logo

frida-protobuf's Introduction

简介

本项目用于辅助逆向开发人员,快速获取和转换Android APP中所使用的protobuf协议的proto文件

当前仅支持基于以下包生成protobuf的相关类

  • com.squareup.wire
  • com.google.protobuf

原生通用的脚本编写√

当前转换逻辑可能无法正确处理内部类,但frida_protobuf/configs包含了内部类的信息,如果无法直接转换,请自行处理

特性

  • string int32 int64 bool 常规类型转换
  • 识别第三方proto导入,自动转换
  • 判定com.google.protobuf.ByteStringAny
  • oneof类型识别和转换

原理

  • 通过frida枚举全部类,根据类特征得到原proto中的字段名、字段类型、字段tag等信息
  • 将信息转换、存储为特定的配置文件
  • 按需求和规则转换proto至对应的py文件

环境

  • frida-server必须是14.x.x版本
    • 因为runtimeqjs,测试使用v8会卡死,如果有人知道原因请告诉我
  • python 3.8.5

安装python包

pip install -r requirements.txt

【可选】安装npm包

有手动编译_agent.js需求

  • agent目录下安装
cd agent
npm install
  • 编译_agent.js
npm run build

使用

手机端开启frida-server

  • 首先将frida-server推送至手机(只用做一次)
adb push frida-server-14.2.18-android-arm64 /data/local/tmp/fs14218
adb shell
su
chmod +x /data/local/tmp/fs14218
  • 开启服务
/data/local/tmp/fs14218 -l 0.0.0.0:33333

使用注意

  • 当前版本生成的proto配置均包含完整包名,转换时指定proto也请完整指定
    • 使用包名的原因是可能存在同名的proto文件
  1. 注入frida脚本,获取proto配置
  2. 将proto的配置文件转换为proto文件
  3. 将proto文件转换为对应的py文件
  4. 样本测试

执行前请删除原来的protos文件夹

当主要proto文件中想额外引用特定的proto时,需要指定对应的包名,多个则使用|隔开,形式如下

--extra-import "package1:proto1,proto2|package2:proto3,proto4"

合理使用--keywords-expected可以避免APP崩溃或卡死

如果存在循环引用的情况,最后转换到py这一步会有问题,请手动处理

如果想知道哪里循环引用了,可以执行一下最后一步转换,会提示出来

案例一

  • com.tencent.qqlive 版本号 26446
python -m frida_protobuf.main -H 172.16.13.146:22222 -n com.tencent.qqlive --use-default-any --keywords-expected "com.tencent.qqlive.protocol.pb,com.tencent.spp_rpc"
python -m frida_protobuf.generate --proto com.tencent.qqlive.protocol.pb.ChangeSectionResponse --extra-import "com.tencent.qqlive.protocol.pb:Poster,Action,Attent,VideoIdKeyValueSet"
python -m frida_protobuf.proto2py --proto com.tencent.qqlive.protocol.pb.ChangeSectionResponse
python -m frida_protobuf.demo

效果演示

演示视频

案例二

  • tv.danmaku.bili 版本号 6510400
python -m frida_protobuf.main -H 172.16.13.146:22222 -n tv.danmaku.bili --use-default-any --keywords-expected "bili"
python -m frida_protobuf.generate --proto com.bapis.bilibili.app.show.popular.v1.PopularReply
python -m frida_protobuf.proto2py --proto com.bapis.bilibili.app.show.popular.v1.PopularReply
python -m frida_protobuf.demo2

效果演示

效果视频

案例三

  • com.baidu.tieba 版本号 202309888
python -m frida_protobuf.main -n com.baidu.tieba --use-default-any --keywords-expected "protobuf,tbclient"
python -m frida_protobuf.generate --proto tbclient.GetBubbleList.GetBubbleListResIdl
python -m frida_protobuf.proto2py --proto tbclient.GetBubbleList.GetBubbleListResIdl

补充

  • Q: 为何需要分三步进行
  • A: 当遭遇某些字段类型为Any时,需要根据自己的需求对proto进行补充

frida-protobuf's People

Contributors

seeflowerx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.