傲渊山岳 发表于 2024-7-25 08:47:12

Ubuntu上编译多个版本的frida

准备工作

Ubuntu20(WSL)


安装依赖

sudo apt update
sudo apt-get install build-essential git lib32stdc++-9-dev libc6-dev-i386 -y
nodejs

去官网下载nodejs,版本的话我就选的20.15.1:
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093741845-1575781851.png
tar -xf node-v20.15.1-linux-x64.tar.xz
下载源码

git clone -b 15.1.28 --recurse-submodules https://github.com/frida/frida
cd frida
ndk

frida各个版本需要的ndk版本都不一样,可以通过cat releng/setup-env.sh |grep ndk查看
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093742167-886883608.png
https://github.com/android/ndk/wiki/Unsupported-Downloads
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093742453-1486413552.png
开始编译

为了方便先写个env15.sh的脚本,然后实验source env15.sh,这样不会污染全局情况,假如你想编译frida16的话,再写个env16.sh。
export ANDROID_NDK_ROOT=/home/kanade/android-ndk-r24
export NODE_HOME=/home/kanade/node-v20.15.1-linux-x64
export PATH=${NODE_HOME}/bin:$ANDROID_NDK_ROOT:$PATH开始编译:make core-android-arm64,会先下载toolchain和sdk。
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093742693-4180576.png
然后就一直卡在这里,这种没有占用CPU的卡住一般都是网络缘故原由
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093742951-1069343533.png
所以在env15.sh加个设置代理的命令:
export https_proxy="http://192.168.31.25:7890"
export http_proxy="http://192.168.31.25:7890"重新编译:make core-android-arm64,等候个两三分钟就编译完成了:
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093743261-1889817639.png
构建好的文件在build/frida-android-arm64/bin
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093743546-924688161.png
想编译其他平台的话,可以输入make先查看全部的平台,选择需要编译的平台
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093743840-2009910282.png
测试

将frida-server推送到手机试试,运行没问题就不测试脚本了
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093744148-372086754.png
编译toolchain和sdk

这个一般不消操作,当你使用make编译时,假如不存在默认会下载编译好的,这里就只是提一下。
编译toolchain:proxychains make -f Makefile.toolchain.mk
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093744375-133140751.png
解决方法: sudo apt install m4 -y
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093744615-378212683.png
编译sdk:proxychains make -f Makefile.sdk.mk FRIDA_HOST=linux-x86_64
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093744861-1365974278.png
这个不显示详细的错误,看Makefile.sdk.mk的282行也看不出什么猫腻,但可以知道的是在构建gn的时间出错的。所以可以看一下gn的构建日志,先找一下日志所在路径,tree -NCfhl |grep build.log
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093745172-2088003413.png
查看这个文件发现是python命令没找到,看了下确实没有,由于现在Ubuntu自带的是python3,之前从Makefile.sdk.mk里看到实验的是deps/gn/build/gen.py这个python代码,打开文件确认下是支持python3的语法,所以做个软链接应该就可以: sudo ln -s /usr/bin/python3 /usr/bin/python。
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093745401-1571294631.png
运行sudo releng/setup-env.sh加载编译好的toolchain和sdk
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093745649-2090933834.png
编译其他版本

git checkout 16.1.4
git submodule update
然后将ndk版本切换到25,接着就可以开始编译了。
make clean
make core-android-arm64
编译低版本

编译更低版本时(14.2.2),除了上面的操作,还需要创建一个build/frida-version.h文件,写入以下内容
#ifndef __FRIDA_VERSION_H__
#define __FRIDA_VERSION_H__

#define FRIDA_VERSION "14.2.2"

#define FRIDA_MAJOR_VERSION 14
#define FRIDA_MINOR_VERSION 2
#define FRIDA_MICRO_VERSION 2
#define FRIDA_NANO_VERSION 0

#endif不然会出现下面的错误:
https://img2024.cnblogs.com/other/1914604/202407/1914604-20240725093745824-411108340.png
着实还是一个版本一个目次文件比较好,不然每次编译都要删除toolchain和sdk重新下载。
下一篇文章说一下怎么魔改frida去特征,不过现在很多APP和壳的检测都比较严格了,去特征的frida也可能过不了检测,还得自己能会找监测点去过检测。
引用链接


[*] https://nodejs.org/zh-cn/download/prebuilt-binaries
[*] https://github.com/conan-io/conan-center-index/issues/8639
参考链接


[*]https://mp.weixin.qq.com/s/4MOTfYm-GMpZQFsLKOOHwQ
本文由博客一文多发平台 OpenWrite 发布!

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: Ubuntu上编译多个版本的frida