android7及以上版本手機(jī)抓包

不能抓包的原因

Android7.0 之后默認(rèn)不信任用戶添加到系統(tǒng)的CA證書(shū):

To provide a more consistent and more secure experience across the Android ecosystem, beginning with Android Nougat, compatible devices trust only the standardized system CAs maintained in AOSP.(文檔鏈接

也就是說(shuō)對(duì)基于 SDK24 及以上的APP來(lái)說(shuō),即使你在手機(jī)上安裝了抓包工具的證書(shū)也無(wú)法抓取 https 請(qǐng)求

解決方案:

一、官方解決方案(需修改APP代碼,so 沒(méi)什么鬼用......)

官方文檔:https://developer.android.google.cn/training/articles/security-config.html
詳細(xì)演示:https://blog.csdn.net/mrxiagc/article/details/75329629

二、將抓包軟件的證書(shū)安裝成系統(tǒng)證書(shū)(需ROOT)

1、root手機(jī) (小米root教程

2、安裝adb(mac安裝adb教程

3、將charles證書(shū)保存到電腦上(重命名成getssl.crt)


WX20191224-155137@2x.png

4、 依次執(zhí)行以下命令

openssl x509 -inform PEM -subject_hash_old -in getssl.crt | head -1   //得到類(lèi)似字符串:f8ccc956
cat getssl.crt > f8ccc956.0
openssl x509 -inform PEM -text -in getssl.crt -out /dev/null >> f8ccc956.0
adb push /Users/lianwu/Documents/f8ccc956.0 /system/etc/security/cacerts/f8ccc956.0
//把生成好的文件放入手機(jī)的 /system/etc/security/cacerts 目錄下

5、成功后可在系統(tǒng)證書(shū)中看到導(dǎo)入的證書(shū):(小米手機(jī)路徑:設(shè)置->密碼、隱私與安全->系統(tǒng)安全->加密與憑據(jù)->信任的憑據(jù)->系統(tǒng))

如果在系統(tǒng)證書(shū)沒(méi)有找到導(dǎo)入的證書(shū),請(qǐng)繼續(xù)往下看:

trouble shooting

1、執(zhí)行步驟4時(shí),部分手機(jī)即使root后,/system分區(qū)也不能push文件(remote couldn't create file: Read-only file system),需要將system盤(pán)remount成可讀寫(xiě)模式:
依次執(zhí)行下面的命令:

adb shell
su  //獲取su權(quán)限
mount -o rw,remount /system   //remount成可讀寫(xiě)
mount -o ro,remount /system   //在push完文件后恢復(fù)成只讀

2、對(duì)于小米手機(jī)即使完成了以上操作也會(huì)出現(xiàn)在成功push了文件后,沒(méi)有提示任何錯(cuò)誤,但是用ls -a找不到push的文件。

這是由于小米手機(jī)即使在獲取了root權(quán)限后,/system分區(qū)依然沒(méi)有解鎖,因此我們還需要解鎖/system分區(qū)

方法: (查看教程第三步:解鎖system

建議在酷安app搜索syslock,下載后一鍵解鎖,或者直接使用下面的adb命令:

adb root

adb disable-verity

解鎖完成后,再將證書(shū)push到系統(tǒng)證書(shū)目錄中。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容