一種基于Frida和Postern的針對Flutter抓包的方法

什么是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開發的了,否則則不是。

image.png

反抓包分析

這里參考了兩篇大佬的帖子:

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。

image.png

然后點search->text->輸入ssl_client,


image.png

點ok,等一會兒,找到有【Rx,PC :"ssl_client"】之類的字眼


image.png

點進去,進入這里:
image.png

按下空格鍵


image.png

這時候,點ida里的菜單欄,options->General,把這個由0改成4。
image.png

點ok,現在再看,已經多了點東西了。
然后當前位置往上找,找到有_unwind開頭的,停下來,從_unwind開始,拿到字符串前面10個字符(也可以大于10)。
image.png

用那幾個字符串,加上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 

發現報錯:


image.png

這里說明應用還尚未加載libflutter.so,注入過早,我們使用frida hook attach模式啟動,或者hook dlopen等so加載了, 同時重新刷新頁面。

image.png

果然抓到了包,而且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

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容