声明
本文仅供学习交流,如有侵权请联系删除
检测
抖音采用的是谷歌的Cronet
网络协议栈,这个Cronet
是从谷歌浏览器剥离出来的。
在Chromium/net/socket/ssl_client_socket_impl.cc
源码中可以看到与抖音libsscronet.so
中相似的伪代码,如下图:
检测方法就是SSL_CTX_set_custom_verify
,这个方法最终会调用boringssl
中的SSL_CTX_set_custom_verify
。其中mode
参数的取值就是下面的三种情况,callback
回调函数就是自定义证书校验逻辑。
// SSL_VERIFY_NONE, on a client, verifies the server certificate but does not
// make errors fatal. The result may be checked with |SSL_get_verify_result|. On
// a server it does not request a client certificate. This is the default.
#define SSL_VERIFY_NONE 0x00
// SSL_VERIFY_PEER, on a client, makes server certificate errors fatal. On a
// server it requests a client certificate and makes errors fatal. However,
// anonymous clients are still allowed. See
// |SSL_VERIFY_FAIL_IF_NO_PEER_CERT|.
#define SSL_VERIFY_PEER 0x01
// SSL_VERIFY_FAIL_IF_NO_PEER_CERT configures a server to reject connections if
// the client declines to send a certificate. This flag must be used together
// with |SSL_VERIFY_PEER|, otherwise it won't work.
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
void SSL_CTX_set_custom_verify(
SSL_CTX *ctx, int mode,
enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert));
如何过
给出两种解决方案,第一种是使用frida
直接将mode
改为0x0
,第二种就是patch so
文件,硬编码一下so
,然后重新放回去。
function hook_dlopen1(module_name) {
var android_dlopen_ext = Module.findExportByName(null, "android_dlopen_ext");
if (android_dlopen_ext) {
Interceptor.attach(android_dlopen_ext, {
onEnter: function (args) {
var pathptr = args[0];
if (pathptr) {
this.path = (pathptr).readCString();
console.log(this.path);
if (this.path.indexOf(module_name) >= 0) {
this.canhook = true;
}
}
},
onLeave: function (retval) {
if (this.canhook) {
let verifyadd = Module.getExportByName("libsscronet.so", "SSL_CTX_set_custom_verify");
Interceptor.attach(verifyadd, {
onEnter(args) {
console.log(args[1])
args[1] = ptr(0x0)
}
})
}
}
});
}
}
第二种使用ida
自带的keypatch
,将#1
改为0
后,保存so
文件,重新放入,赋予对应权限后既可使用。
效果
可以看到,reply
接口评论可以正常抓取,其他接口也正常,但还有小部分是connect
失败,该方法对于tk
抓包同样有效,至于quic
协议,尝试过wireshark
抓取,但是连quic
的影子都没看到,不知道哪个接口用了。
© 版权声明
文章版权归原作者所有,本站只做转载和学习以及开发者个人原创。声明:下载本站资源即同意用户协议,本站程序仅供内部学习研究软件设计思想和原理使用,学习研究后请自觉删除,请勿传播,因未及时删除所造成的任何后果责任自负。
THE END
暂无评论内容