主要內(nèi)容:
下載官方frida源碼并編譯安卓版本的fridaserver,然后替換內(nèi)置版本
編譯反檢測版本fridaserver工程strongFrida并替換系統(tǒng)內(nèi)置版本
1.編譯環(huán)境前期準備
1.1 操作系統(tǒng)準備
ubuntu系統(tǒng): ubuntu-20.04 java環(huán)境: JDK1.8 Python環(huán)境: >=3.7 git工具: 安裝任一版本就行。
1.2 ndk下載準備
當前最新frida源碼編譯安卓版本需要ndk-r22版本,不然會提示錯誤。
ndk下載地址:
https://dl.google.com/android/repository/android-ndk-r22-linux-x86_64.zip
下載以后解壓到一個目錄后續(xù)使用。比如我個人的存放目錄:
/home/qiang/androidndk/android-ndk-r22
1.3 安裝依賴
分別執(zhí)行如下命令:
qiang@ubuntu:~/myproject/frida/frida$sudoapt-getupdate qiang@ubuntu:~/myproject/frida/frida$sudoapt-getinstallbuild-essentialtreeninja-buildgcc-multilibg++-multiliblib32stdc++-9-devflexbisonxz-utilsrubyruby-devpython3-requestspython3-setuptoolspython3-devpython3-piplibc6-devlibc6-dev-i386-y qiang@ubuntu:~/myproject/frida/frida$sudopython-mpipinstallcoloramaprompt-toolkitpygments qiang@ubuntu:~/myproject/frida/frida$python-mpipinstalllief
1.4 frida源碼下載
執(zhí)行如下命令下載:
gitclone--recurse-submoduleshttps://github.com/frida/frida
比如我下載存儲目錄:
/home/qiang/myproject/frida/frida
2.編譯操作
2.1 官方版本編譯
(1).設(shè)置ANDROID_NDK_ROOT變量
qiang@ubuntu:~/myproject/frida/frida$exportANDROID_NDK_ROOT=/home/qiang/androidndk/android-ndk-r22
(2).進入frida源碼根目錄分別執(zhí)行如下命令編譯android版本的frida
qiang@ubuntu:~/myproject/frida/frida/frida$pwd /home/qiang/myproject/frida/frida/frida qiang@ubuntu:~/myproject/frida/frida/frida$ls buildCOPYINGfrida-gumfrida-qmlfrida-toolsMakefile.macos.mkREADME.md config.mkfrida-clrfrida-nodefrida.slnMakefileMakefile.sdk.mkreleng CONTRIBUTING.mdfrida-corefrida-pythonfrida-swiftMakefile.linux.mkMakefile.toolchain.mk qiang@ubuntu:~/myproject/frida/frida/frida$ qiang@ubuntu:~/myproject/frida/frida/frida$makecore-android-arm64 qiang@ubuntu:~/myproject/frida/frida/frida$ qiang@ubuntu:~/myproject/frida/frida/frida$makecore-android-arm qiang@ubuntu:~/myproject/frida/frida/frida$
(3).編譯完成之后的目標存儲目錄
frida-android-arm存放目錄:
qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm/bin$ qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm/bin$pwd /home/qiang/myproject/frida/frida/frida/build/frida-android-arm/bin qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm/bin$ls-la total36316 drwxr-xr-x2qiangqiang40963月3122:25. drwxrwxr-x6qiangqiang40963月3122:25.. -rwxr-xr-x1qiangqiang178460123月3122:25frida-inject -rwxr-xr-x1qiangqiang176698443月3122:25frida-server -rwxr-xr-x1qiangqiang16609003月3122:25gum-graft qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm/bin$ qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm/bin$
frida-android-arm64存儲目錄:
qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm64/bin$ls-la total83204 drwxr-xr-x2qiangqiang40963月3122:28. drwxrwxr-x6qiangqiang40963月3122:28.. -rwxr-xr-x1qiangqiang416208723月3122:28frida-inject -rwxr-xr-x1qiangqiang413832163月3122:28frida-server -rwxr-xr-x1qiangqiang21820963月3122:28gum-graft qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm64/bin$pwd /home/qiang/myproject/frida/frida/frida/build/frida-android-arm64/bin qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm64/bin$ qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm64/bin$ls frida-injectfrida-servergum-graft qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm64/bin$ qiang@ubuntu:~/myproject/frida/frida/frida/build/frida-android-arm64/bin$
2.2 strongR-frida-android版本編譯
2.2.1 簡介
strongR-frida-android主要是通過patch代碼的方式,為frida官方源碼進行一些修改,抹除一些關(guān)鍵特征,為Android構(gòu)建反檢測版本的frida-server。
2.2.2 patch補丁文件
patch補丁項目地址:
https://github.com/AAAA-Project/Patchs
2.2.3 編譯以及測試流程
strongR-frida-android編譯和官方frida編譯方式是一樣的,差異在于編譯frida源碼之前,需要先下載frida官方的源碼,然后使用git am命令將patch代碼應(yīng)用到frida官方源碼中。以下說一下具體patch補丁的流程。
(1)、為frida源碼patch 反檢測補丁
詳細流程參考如下命令:
qiang@ubuntu:~/myproject/frida/frida$ qiang@ubuntu:~/myproject/frida/frida$gitclonehttps://github.com/AAAA-Project/Patchs Cloninginto'Patchs'... remote:Enumeratingobjects:40,done. remote:Countingobjects:100%(40/40),done. remote:Compressingobjects:100%(22/22),done. remote:Total40(delta19),reused32(delta11),pack-reused0 Unpackingobjects:100%(40/40),12.04KiB|280.00KiB/s,done. qiang@ubuntu:~/myproject/frida/frida$cdfrida/frida-core/ qiang@ubuntu:~/myproject/frida/frida/frida/frida-core$gitam../../Patchs/strongR-frida/frida-core/*.patch Applying:strongR-frida:string_frida_rpc Applying:strongR-frida:io_re_frida_server Applying:strongR-frida:pipe_linjector Applying:strongR-frida:io_frida_agent_so Applying:strongR-frida:symbol_frida_agent_main Applying:strongR-frida:thread_gum_js_loop Applying:strongR-frida:thread_gmain Applying:strongR-frida:protocol_unexpected_command qiang@ubuntu:~/myproject/frida/frida/frida/frida-core$ qiang@ubuntu:~/myproject/frida/frida/frida/frida-core$ qiang@ubuntu:~/myproject/frida/frida/frida/frida-core$
(2)、編譯源碼操作
和編譯官方frida源碼一樣的流程。
(3). 替換手機內(nèi)置版本測試
通過adb push進去替換。具體請參考"不用刷機情況下升級或者降級系統(tǒng)中的fridaserver"。
4. 可參考的集成編譯腳本
編譯官方frida的shell腳本參考:
#buildforfridaandroid # sudoapt-getupdate sudoapt-getinstallbuild-essentialtreeninja-buildgcc-multilibg++-multiliblib32stdc++-9-devflexbisonxz-utilsrubyruby-devpython3-requestspython3-setuptoolspython3-devpython3-piplibc6-devlibc6-dev-i386-y sudopython-mpipinstallcoloramaprompt-toolkitpygments #setANDROID_NDK_ROOT exportANDROID_NDK_ROOT=/home/qiang/androidndk/android-ndk-r22 #deletefrida rm-rffrida #downloadagain gitclone--recurse-submoduleshttps://github.com/frida/frida cdfrida #cleanbuildingcache makeclean #buildingfridaandroidarm makecore-android-arm #buildingfridaandroidarm64 makecore-android-arm64
編譯strong frida腳本參考如下:
#buildforstrongfridaandroid # sudoapt-getupdate sudoapt-getinstallbuild-essentialtreeninja-buildgcc-multilibg++-multiliblib32stdc++-9-devflexbisonxz-utilsrubyruby-devpython3-requestspython3-setuptoolspython3-devpython3-piplibc6-devlibc6-dev-i386-y sudopython-mpipinstallcoloramaprompt-toolkitpygments # exportANDROID_NDK_ROOT=/home/qiang/androidndk/android-ndk-r22 rm-rfPatchs #DownloadPaths gitclonehttps://github.com/AAAA-Project/Patchs rm-rffrida #Downloadfridasoucecode gitclone--recurse-submoduleshttps://github.com/frida/frida cdfrida/frida-core echo"starttopatchsourcecode " gitam../../Patchs/strongR-frida/frida-core/*.patch echo"finishtopatchsourcecode " sleep2 cd.. makeclean makecore-android-arm makecore-android-arm64
審核編輯:湯梓紅
-
操作系統(tǒng)
+關(guān)注
關(guān)注
37文章
6684瀏覽量
123140 -
源碼
+關(guān)注
關(guān)注
8文章
632瀏覽量
29110 -
編譯
+關(guān)注
關(guān)注
0文章
648瀏覽量
32774
原文標題:編譯官方fridaserver或者strongFrida并替換系統(tǒng)內(nèi)置版本
文章出處:【微信號:哆啦安全,微信公眾號:哆啦安全】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
相關(guān)推薦
評論