字节系app通用抓包方案

admin 2024年2月1日22:28:57评论67 views字数 1779阅读5分55秒阅读模式

 

已测试某音(28.4.0), 某茄小说(6.0.5.32)

原理

获取SSL_CTX_set_custom_verify的参数3(回调函数)

void SSL_CTX_set_custom_verify(SSL_CTX *ctx, int mode, enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert)) {    ctx->verify_mode = mode;    ctx->custom_verify_callback = callback;}

字节系app通用抓包方案

让回调函数的返回值保持为0, 即ssl_verify_ok即可
enum ssl_verify_result_t BORINGSSL_ENUM_INT {    ssl_verify_ok,    ssl_verify_invalid,    ssl_verify_retry,};

代码编写

首先获取一下SSL_CTX_set_custom_verify
function main() {    Java.perform(function () {        let SSL_CTX_set_custom_verify = Module.getExportByName('libsscronet.so', 'SSL_CTX_set_custom_verify');    }}setImmediate(main);
spwan模式启动下应用frida -U -f com.ss.xxx.xxx.aweme -l byteDance.js
注入后提示报错: Error: unable to find module 'libsscronet.so'
很明显, 问题的原因在于注入的时机过早, so还没有加载进来, 解决办法有2个:
  1. setTimeout(main, 3000);延时执行函数
  2. hook系统函数, 监听so加载
function onLoad(name, callback) {    //void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo);//原型    const android_dlopen_ext = Module.findExportByName(null, "android_dlopen_ext");    if (android_dlopen_ext != null) {        Interceptor.attach(android_dlopen_ext, {            onEnter: function (args) {                if (args[0].readCString().indexOf(name) !== -1) {                    this.hook = true;                }            },             onLeave: function (retval) {                if (this.hook) {                    callback();                }            }        });    }}onLoad(soName, () => {    let SSL_CTX_set_custom_verify = Module.getExportByName('libsscronet.so', 'SSL_CTX_set_custom_verify');    if (SSL_CTX_set_custom_verify != null) {        Interceptor.attach(SSL_CTX_set_custom_verify, {            onEnter: function (args) {                Interceptor.attach(args[2], {                    onLeave: function (retval) {                        if (retval > 0x0) retval.replace(0x0);                    }                });            }        });    }});
当监听到so被加载时进行hook操作, hook到SSL_CTX_set_custom_verify后, 获取参数3并hook它, 让此函数执行完成后的返回值保持为0即可

效果图

字节系app通用抓包方案

字节系app通用抓包方案

完整代码已经上传至github
https://github.com/LanBaiCode/FridaScripts
作者:Slimu原文:https://www.52pojie.cn/thread-1879263-1-1.html
黑白之道发布、转载的文章中所涉及的技术、思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途及盈利等目的,否则后果自行承担!

如侵权请私聊我们删文

END

原文始发于微信公众号(黑白之道):字节系app通用抓包方案

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年2月1日22:28:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   字节系app通用抓包方案http://cn-sec.com/archives/2401922.html

发表评论

匿名网友 填写信息