首页
社区
课程
招聘
[原创]frida源码编译详解
2023-1-9 00:46 12715

[原创]frida源码编译详解

2023-1-9 00:46
12715

frida - 编译教程 - iyue

  • 当前编译环境: Mac m1 Ubuntu20.04 都可以成功编译 frida git 分支 16.0.7`
  1. 下载源码
1
2
3
git clone --recurse-submodules https://github.com/frida/frida.git
cd frida
make
  1. 切换需要的分支 当前基于 16.0.7
1
2
git checkout 16.0.7
git submodule update
  1. 配置编译环境
  • NDK下载目录 不同分支版本 有不同的ndk 可在源码 查看 或者 根据make后的提示
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# for linux ubuntu20.04 别更新 别更新 别更新 或者尝试使用docker
sudo apt-get install build-essential curl git lib32stdc++-9-dev libc6-dev-i386 nodejs npm python3-dev python3-pip
## 配置NDK目录 ~/.bashrc add
export ANDROID_NDK_ROOT=/*your path*/ndk/25.0.8775105
 
# for mac
brew install npm
## 配置NDK目录 ~/.zshrc add
export ANDROID_NDK_ROOT=/*your path*/ndk/25.0.8775105
 
# all 
pip install colorama prompt-toolkit pygments
# install node
npm install npm -g
npm install n
n install stable
npm install frida

frida - build for Linux

  • linux 没有 证书那一步
1
cd frida && make core-android-arm64

frida - build for Mac

  • 贴图是我觉得有人可能跟我一样找了半天证书助理在哪里 百度了 都没找到最后乱点才出来的
  • 创建证书ba54d289-ed00-47af-9b6e-e7740252e9c4

  • 修改证书名称 frida-cert 名称 和 ./build.sh 脚本里写的对应上就可以 不过人家官方推荐的bf481ad1-ea0c-4e81-887c-61ddecd62b6b

  • 双击打开 frida-cert设置始终信任89702f92-a402-403c-9513-2c2610dcbc30

  • 拷贝到系统 删除登录页刚创建的 frida-cert

  • 要确保 macOS 接受新创建的证书,请重新启动任务门控守护进程:

1
sudo killall taskgated
  • build frida module
    1. 在frida目录创建编译脚本 build.sh
    2. 执行: ./build.sh core-android-arm64
    3. 可选参数 不同平台有不同的 生成目标 core-android-arm64 全平台都有
      1. core-android-arm64 core-android-arm core-android-x86_64 core-android-x86
      2. python-macos linux 为 python-linux-x86 || x86_64
      3. tools-macos 同上
1
2
3
4
5
export MACOS_CERTID=frida-cert
export IOS_CERTID=frida-cert
export WATCHOS_CERTID=frida-cert
export TVOS_CERTID=frida-cert
make $1 -j 8
  • 体验一下成功的感觉
  • core-android-arm64 226cc7a6-5e41-438d-9b23-ecbaebbfdb67

  • python-macos 93a0df74-a279-4ae8-a599-2386759bd226

  • tools-macos 29b3c5a1-2faa-4dc9-8bcb-00ccb84f54c6

frida - Build frida whl

  • 创建文件build_frida_python.sh
  • 下载 frida-core-devkit 对应的分支tag 对应版本 对应平台的 frida-core-devkit-16.0.7-android-arm64
  • 使用: ./build_frida_python.sh ./frida-core-devkit/frida-core-devkit-16.0.7-android-arm64
    重要的事情说三遍
  • 下面脚本使用绝对路径
  • 下面脚本使用绝对路径
  • 下面脚本使用绝对路径
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
set FRIDA=$(pwd) # 根目录 frida 源码的上层目录
set FRIDA_VERSION=16.0.7 # from frida-version.h version
set FRIDA_EXTENSION=$FRIDA/build/frida-macos-arm64/lib/python3.10/site-packages/_frida.so
export FRIDA_CORE_DEVKIT=$FRIDA/frida-core-devkit-16.0.7-android-arm64
# 编译可执行文件
make tools-macos -j 16
make core-android-arm64 -j 16
# 编译python 模块  whl 可以使用 pip 安装
mkdir dist
cd dist
pip wheel ../frida-python
cd ../frida-tools
make  # 必须执行不然有几个js 脚本会漏掉
cd ../dist
pip wheel ../frida-tools

注意事项

  1. 其它版本得注意一下源码中需要的NDK版本 以及 node版本.
  2. 期间有大量需要科学的这个只能自己处理了.
  3. 想来接下去就是修改特征了,可参考huluwpatch 和 看雪大佬们总结的frida特征.
  4. frida源码使用因为路径否则会出现编码问题.

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

最后于 2023-8-18 15:02 被iyue_t编辑 ,原因: 1.修复编译脚本
收藏
点赞5
打赏
分享
最新回复 (3)
雪    币: 10711
活跃值: (4074)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
jgs 2023-1-9 08:46
2
0
学习了,谢谢楼主,收藏。
雪    币: 546
活跃值: (582)
能力值: ( LV4,RANK:40 )
在线值:
发帖
回帖
粉丝
System32 2023-8-15 05:35
3
0
雪    币: 19299
活跃值: (28933)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
秋狝 2023-8-15 09:14
4
0
感谢分享
游客
登录 | 注册 方可回帖
返回