什么是Flutter
Flutter是Google使用Dart语言开发的移动应用开发框架,使用一套Dart代码就能快速构建高性能、高保真的iOS和Android应用程序。
由于Dart使用Mozilla的NSS库生成并编译自己的Keystore,导致我们就不能通过将代理CA添加到系统CA存储来绕过SSL验证。
flutter打包的apk,会把核心逻辑放在so层,且SSL Pining也在Native层,这就导致没法抓包。
这里不做过多缀叙。
app名称:ZXhwaW5n
开始抓包
-
启动Postern设置代理配合charles抓包这个app,发现都是SSL证书问题:
image.png
怎么判定app是flutter开发的
把apk包复制一份,后缀改为zip,然后解压,进入lib目录,如果看到有libflutter.so,那就是flutter开发的了,否则则不是。
反抓包分析
这里参考了两篇大佬的帖子:
https://bbs.pediy.com/thread-261941.htm
https://mp.weixin.qq.com/s/pXpfXK-Ez0n70f3bqFuuFg
然后跟着操作了一下,在打开app的包文件,用IDA去打开libflutter.so(注意32位与64位)比葫芦画瓢。
我这里用的IDA Pro7.0.170914。
首先用IDA 32位打开libflutter.so。
然后点search->text->输入ssl_client,
点ok,等一会儿,找到有【Rx,PC :"ssl_client"】之类的字眼
点进去,进入这里:
按下空格键
这时候,点ida里的菜单栏,options->General,把这个由0改成4。
点ok,现在再看,已经多了点东西了。
然后当前位置往上找,找到有_unwind开头的,停下来,从_unwind开始,拿到字符串前面10个字符(也可以大于10)。
用那几个字符串,加上flutter的hook脚本,配合postern开始重新抓包。
首先启动frida注入代码:
function hook_flutter(){
Java.perform(function () {
var m = Process.findModuleByName("libflutter.so");
var pattern = "2D E9 F0 4F 85 B0 06 46 50 20 10 70";
var res = Memory.scan(m.base, m.size, pattern, {
onMatch: function(address, size){
console.log('[+] ssl_verify_result found at: ' + address.toString());
hook_ssl_verify_result(address.add(0x01));
},
onError: function(reason){
console.log('[!] There was an error scanning memory');
},
onComplete: function() {
console.log("All done")
}
});
});
}
function hook_ssl_verify_result(address) {
Interceptor.attach(address, {
onEnter: function(args) {
console.log("Disabling SSL validation")
},
onLeave: function(retval) {
console.log("Retval: " + retval);
retval.replace(0x1);
}
});
}
setImmediate(hook_flutter);
开始注入:
frida -H 127.0.0.1:8889 -f com.******.exping -l exping.js
发现报错:
这里说明应用还尚未加载libflutter.so,注入过早,我们使用frida hook attach模式启动,或者hook dlopen等so加载了, 同时重新刷新页面。
果然抓到了包,而且app页面也正常显示数据。果然动手操作完之后还是挺开心的,好记性不如烂笔头,大家加油!!
更多的flutter资料,以下资料链接源于肉师傅和葫芦娃的知识星球,还有微信好友@奋飞、@岂可修
http://91fans.com.cn/post/fruittwo/
https://github.com/google/boringssl
https://rloura.wordpress.com/2020/12/04/reversing-flutter-for-android-wip/
https://github.com/rscloura/Doldrums
https://bbs.pediy.com/thread-261941.htm
https://mp.weixin.qq.com/s/Ad0v44Bxs1LFy93RT_brYQ
https://tinyhack.com/2021/03/07/reversing-a-flutter-app-by-recompiling-flutter-engine/
https://blog.tst.sh/reverse-engineering-flutter-apps-part-1/
https://blog.tst.sh/reverse-engineering-flutter-apps-part-2/
https://github.com/hellodword/xflutter/blob/main/snapshot-hash.csv
https://raphaeldenipotti.medium.com/bypassing-ssl-pinning-on-android-flutter-apps-with-ghidra-77b6e86b9476
https://github.com/G123N1NJ4/c2hack/blob/0f85a9b0208e9ee05dcbfb4fbcebd1c7babc4047/Mobile/flutter-ssl-bypass.md
https://github.com/ptswarm/reFlutter?msclkid=41b563c4ab7a11ecad34e0a8139bac19
https://github.com/mildsunrise/darter
flutter app的流量监控和逆向库
https://github.com/ptswarm/reFlutter
dart反编译,只能编译2018年前的
https://github.com/hdw09/darter