使用ubuntu进行frida-server编译
1.更新命令
sudo apt-get update
sudo apt-get upgrade
2.安装下面的包
sudo apt-get install build-essential curl git lib32stdc++-9-dev libc6-dev-i386 nodejs npm python3-dev python3-pip
pip install lief # 安装 lief 库
3.查看当前 frida 版本所需的 NDK 版本
cat setup-env.sh | grep ndk
得知ndk的版本号为22
所以接下来下载。
4.下载上述ndk文件
wget https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip
之后unzip进行解压
unzip android-ndk-r22b-linux-x86_64.zip
将文件夹拷贝到home目录下放便后续操作。
5.设置ndk环境变量
打开文件
sudo gedit ~/.bashrc
内容如下
export ANDROID_NDK_ROOT=/home/chennan/Desktop/android-ndk-r22b
export PATH=$ANDROID_NDK_ROOT:$PATH
6.测试是否配置成功
ndk-build -v
7.创建 frida-version.h
查看frida文件下面是否有 build目录, 没有就创建一个,然后在该目录文件夹下创建头文件 frida-version.h ,如果没有就手动创建,然后根据自己编译版本填入下面代码
#ifndef __FRIDA_VERSION_H__
#define __FRIDA_VERSION_H__
#define FRIDA_VERSION "14.2.12"
#define FRIDA_MAJOR_VERSION 14
#define FRIDA_MINOR_VERSION 2
#define FRIDA_MICRO_VERSION 12
#define FRIDA_NANO_VERSION 0
#endif
8.修改文件
frida-deps.vcxproj和frida.mk里面的master都替换为main
chennan@ubuntu:~/frida/releng$ subl frida-deps.vcxproj
chennan@ubuntu:~/frida/releng$ subl frida.mk
9.编译
make core-android-arm64
10.下载patch
并切换到14.2.12版本,保证一致才行。
git clone https://github.com/AAAA-Project/Patchs.git
git checkout 8e1308b
11.打patch
chennan@ubuntu:~/frida/frida-core$ git am ../../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
/home/chennan/frida/.git/modules/frida-core/rebase-apply/patch:53: trailing whitespace.
/home/chennan/frida/.git/modules/frida-core/rebase-apply/patch:101: trailing whitespace.
/home/chennan/frida/.git/modules/frida-core/rebase-apply/patch:112: trailing whitespace.
warning: 3 lines add whitespace errors.
Applying: strongR-frida: thread_gum_js_loop
Applying: strongR-frida: thread_gmain
Applying: strongR-frida: protocol_unexpected_command
11.将所有的local/tmp目录替换掉
cd frida
sed -i 's#data/local/tmp#data/data/com.android.settings#g' `grep -ril "local/tmp" ./`