常用工具
信息收集:AppinfoScanner
https://github.com/kelvinBen/AppInfoScanner [1]
一款適用于以HW行動/紅隊/滲透測試團隊為場景的移動端(Android、iOS、WEB、H5、靜態網站)信息收集掃描工具,可以幫助滲透測試工程師、攻擊隊成員、紅隊成員快速收集到移動端或者靜態 WEB 站點中關鍵的資產信息并提供基本的信息輸出,如:Title、Domain、CDN、指紋信息、狀態信息等。
下載
git clone https://github.com/kelvinBen/AppInfoScanner.gitcd AppInfoScannerpython -m pip install -r requirements.txt
運行
python app.py android|ios|web -i APK|DEX|IPA|Mach-o|web File
評估框架:MobSF
https://github.com/MobSF/Mobile-Security-Framework-MobSF [2]
移動安全框架(MobSF)是 Android、iOS 和 Windows Mobile 中移動應用程序的安全研究平臺。MobSF 可用于各種用例,如移動應用安全、滲透測試、惡意軟件分析和隱私分析。靜態分析器支持流行的移動端二進制文件,如 APK、IPA、APPX 和源碼。同時,動態分析器支持雙端應用程序,并為交互式儀器測試、運行時數據和網絡全流量分析產品提供平臺。
docker pull opensecurity/mobile-security-framework-mobsf:latestdocker run -it --rm -p 8000:8000 opensecurity/mobile-security-framework-mobsf:lates
# Default username and password: mobsf/mobsf
移動端滲透系統:mobexler
https://mobexler.com [3]
Mobexler 是基于 Elementary OS 的定制虛擬機,旨在幫助進行 Android 和 iOS 應用程序的滲透測試。Mobexler 預裝了各種開源工具、腳本等黑客必備軟件,這些都是安全測試 Android 和 iOS 應用程序所必需的。
解析工具:AppMessenger
https://github.com/sulab999/AppMessenger [4]
一款適用于以 APP 病毒分析、APP 漏洞挖掘、APP 開發、HW 行動/紅隊/滲透測試團隊為場景的移動端(Android、iOS、鴻蒙)輔助分析工具,可以幫助 APP 開發工程師、病毒分析師、漏洞/安全研究員提高工作效率,幫助滲透測試工程師、攻擊隊成員/紅隊成員快速收集到移動端中關鍵的資產信息并提供基本的信息輸出,如:包名(packageName)、版本(versionName\versionCode)、應用簽名(Signature)、文件MD5、SDK、URL、APP 漏洞等信息。
插樁工具:Frida
https://github.com/frida/frida [5]
Firda 是一款易用的跨平 Hook 工具, Java 層到 Native 層的 Hook 無所不能,是一種動態的插樁工具,可以插入代碼到原生 App 的內存空間中,動態的去監視和修改行為。
注意事項:與 Xposed 無法共存。
本地安裝 frida、frida-tools、frida-dexdump
pip install frida frida-tools frida-dexdump
移動設備安裝 frida-server 并運行
$ adb devices$ adb root$ adb push frida-server /data/local/tmp/$ adb shell "chmod 755 /data/local/tmp/frida-server"$ adb shell "/data/local/tmp/frida-server &"$ adb shell ps | grep frida-server
端口轉發
adb forward tcp:27042 tcp:27042
獲取進程
frida-ps -Ufrida-ps -R
獲得模擬器位數:getprop ro.product.cpu.abi
脫殼腳本:frida-dexdump
https://github.com/hluwa/frida-dexdump [6]
frida-dexdump 是一種 FRIDA 工具,用于查找 DEX 并將其轉儲到內存中,以支持安全工程師分析惡意軟件。
本地安裝
pip install frida-dexdump
脫殼命令
frida-dexdump -U -f 包名稱 -d -o /tmp/dexdump
脫殼腳本:BlackDex
https://github.com/CodingGay/BlackDex [7]
BlackDex 是一個運行在 Android 上的脫殼工具,支持 5.0~12,無需依賴任何環境,任何手機都可以使用,包括模擬器。只需幾秒,即可對已安裝包括未安裝的 APK 進行脫殼。
抓包利器:r0capture
https://github.com/r0ysue/r0capture?tab=readme-ov-file [8]
僅限安卓平臺,無視所有證書校驗或綁定、通殺 TCP/IP 四層模型中應用層的全部協議、通殺所有應用層框架、無視加固。
Spawn 模式
python3 r0capture.py -U -f com.coolapk.market -v
Attach 模式,抓包內容保存成 pcap 文件供后續分析
python3 r0capture.py -U com.qiyi.video -v -p iqiyi.pcap
老版本 Frida 使用包名,新版本 Frida 使用 APP 名。 APP 名必須是點開應用后,frida-ps -U 顯示的那個應用名字。
抓包環境搭建
模擬器:MuMu 12
第一步:Burp 導出證書
文件名以.der結尾。
第二步:轉換 pem 證書
需要用到openssl(以 kali 為例),將der證書復制到 kali 中,用openssl進行處理:
openssl x509 -inform der -in burp.der -out bp.pemopenssl x509 -subject_hash_old -in bp.pemmv bp.pem 9a5ba575.0
也可以使用在線轉換網站:http://web.chacuo.net/netsslcer2pem [9]
將pem格式的證書復制到 Windows 下。
第三步:修改 MuMu 配置
在“設置中心”將“磁盤共享”設置為“可寫系統盤”。
開啟手機 Root 權限。
重新啟動。
第四步:ADB 傳輸證書
在 MuMu 安裝目錄的 shell 文件夾下,存在adb.exe。
D:\Programs\MuMuPlayer12\shell>adb.exe devices* daemon not running; starting now at tcp:5037* daemon started successfullyList of devices attached
查看模擬器調試端口:
連接:
D:\Programs\MuMuPlayer12\shell>adb.exe connect 127.0.0.1:16384connected to 127.0.0.1:16384
D:\Programs\MuMuPlayer12\shell>adb root
切換到模擬器點擊允許。
傳輸pem證書:
D:\Programs\MuMuPlayer12\shell>adb.exe push D:/tools/Burp證書/9a5ba575.0 /system/etc/security/cacerts/D:/tools/Burp證書/9a5ba575.0: 1 file pushed, 0 skipped. 3.7 MB/s (1326 bytes in 0.000s)
進入交互環境,查看文件是否存在:
D:\Programs\MuMuPlayer12\shell>adb.exe shellishtar:/ # cd /system/etc/security/cacertsishtar:/ # ls
發現傳輸的文件是沒有后綴的,進行修改:
ishtar:/system/etc/security/cacerts # cp 9a5ba57 9a5ba575.0ishtar:/system/etc/security/cacerts # rm 9a5ba57
第五步:抓包測試
先創建監聽器。
模擬器上修改網絡配置。
可以正常抓包,也沒有彈窗警告。
抓不到數據包原因
抓不到數據包有情況兩種,一種是代理的原因,另一種是證書的原因。
代理原因
APP 在啟動的時候檢測是否開啟了代理模式,如果開啟了代理模式,就會出現無法連接的情況。
證書原因
APP 接收數據是利用抓包軟件的證書來進行交互,但是服務端去校驗證書的時候發現和 APP 的證書不一致。
如果數據走的 HTTPS 協議,那么數據包有三種驗證情況:
無檢驗,客戶端不存在證書校驗,服務器也不存在證書校驗。
單項校驗,客戶端存在校驗服務端證書,服務器也不存在證書校驗。
雙向校驗,客戶端存在證書校驗,服務器也存在證書校驗。
繞過反代理
通過 proxifier 對模擬器進行代理轉發。
繞過證書校驗
Xposed + JustTrustMe + JustMePlush
Xposed 是一個可以改變系統行為的框架,通過在 Android 應用程序中插入自己的代碼來實現。
注意事項:與 Frida 無法共存。
JustTrustMe 是一個 Xposed 模塊,用于繞過 Android 應用中的 SSL 證書檢查。
JustMePlus 是一個 Xposed 模塊,它擴展了 JustTrustMe 的功能,提供了更多的選項和更好的用戶體驗。
先安裝 Xposed 框架,然后在 Xposed 安裝器中激活 JustTrustMe 和 JustMePlus 模塊。以下是如何操作的基本步驟:
下載安裝 Xposed 框架
重啟設備以激活 Xposed
安裝 JustTrustMe 和 JustMePlus
重啟設備
開啟代理
在 Xposed 中啟用 JustTrustMe 和 JustMePlus 模塊
重啟設備(其實就是利用這兩個模塊,把 APP 里面的檢測功能屏蔽掉)
打開 JustMePlush,選擇要抓包的 APP
Xposed 框架只是解決單向證書校驗,如果是雙向驗證還是需要用 Frida 來解決。
安裝 Magisk
https://mumu.163.com/help/20240202/35044_1136675.html [10]
第一步:下載 Kitsune Mask
下載鏈接:https://github.com/HuskyDG/magisk-files/releases [11]
安裝后點擊完成。
重啟模擬器,啟動 Kitsune Mask。
第二步:安裝 Magisk
在 Kitsune Mask 界面,點擊 Magisk 欄目右側的安裝。
選擇“直接安裝(直接修改/system)”。
出現 ALL done! 說明安裝成功,重啟模擬器。
再次打開 Kitsune Mask。
安裝 LSPosed 框架
項目地址:https://github.com/LSPosed/LSPosed [12]
第一步:開啟 Zygisk
點擊“設置”。
開啟“Zygisk”。
第二步:推送 LSPosed 框架
將下載的 LSPosed-v1.9.2-7024-zygisk-release.zip 傳到/sdcard/Download目錄下。
D:\Programs\MuMuPlayer12\shell>adb.exe push D:/tools/APP滲透工具/LSPosed-v1.9.2-7024-zygisk-release.zip /sdcard/Download/LSPosed-v1.9.2-7024-zygisk-release.zip
D:/tools/APP滲透工具/LSPosed-v1.9.2-7024-zygisk-releas...ile pushed, 0 skipped. 33.3 MB/s (2462055 bytes in 0.071s)
第三步:安裝 LSPosed 框架
從本地安裝。
選擇框架所在目錄。
安裝框架。
出現下圖內容說明安裝成功。
重啟模擬器。
雖然顯示安裝成功,但在桌面上找不到 LSPosed 圖標,因為 LSPosed 是寄生到系統,默認隱藏的。
第三步:安裝 manager.apk
解壓 LSPosed-v1.9.2-7024-zygisk-release.zip。
將 manager.apk 拖到模擬器,直接安裝。
安裝 JustTrustMe++
項目地址:https://github.com/JunGe-Y/JustTrustMePP/tree/master/app/release [13]
直接推拽安裝即可。
引用鏈接
[1]: https://github.com/kelvinBen/AppInfoScanner
[2]: https://github.com/MobSF/Mobile-Security-Framework-MobSF
[3] https://mobexler.com: https://mobexler.com/
[4]: https://github.com/sulab999/AppMessenger
[5]: https://github.com/frida/frida
[6]: https://github.com/hluwa/frida-dexdump
[7]: https://github.com/CodingGay/BlackDex
[8]: https://github.com/r0ysue/r0capture?tab=readme-ov-file
[9]: http://web.chacuo.net/netsslcer2pem
[10]: https://mumu.163.com/help/20240202/35044_1136675.html
[11] https://github.com/HuskyDG/magisk-files/releases: about:blank
[12]: https://github.com/LSPosed/LSPosed
[13]: https://github.com/JunGe-Y/JustTrustMePP/tree/master/app/release
原文來源:https://mp.weixin.qq.com/s/0guv1OeKVhH8ICx8mtTTMQ