首页
社区
课程
招聘
[原创]FRIDA 编译 | 14.2.17
发表于: 2023-2-11 21:51 9918

[原创]FRIDA 编译 | 14.2.17

2023-2-11 21:51
9918

FRIDA 魔改编译 | 14.2.17


编译

官方文档 Building

Ubuntu 环境

1
2
3
4
5
6
7
8
9
10
k@k:~/Desktop$ uname -a
Linux k 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
k@k:~/Desktop$ cat /proc/version
Linux version 5.15.0-48-generic (buildd@lcy02-amd64-080) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022
k@k:~/Desktop$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:    22.04
Codename:    jammy

依赖

1
sudo apt-get update && sudo apt-get install -y build-essential curl git lib32stdc++-9-dev libc6-dev-i386 nodejs npm python3-dev python3-pip

同步 FRIDA 源码 | 14.2.17

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 设置全局代理
git config --global http.proxy "http://192.168.1.6:7890" && git config --global https.proxy "https://192.168.1.6:7890"
 
# 以 FRIDA 14.2.17 为例
git clone -b 14.2.17 --recurse-submodules https://github.com/frida/frida.git
 
------------------------------------------------------------------------------------------
 
# 克隆最新源码
git clone --recurse-submodules https://github.com/frida/frida.git
 
# 克隆指定版本
git clone -b 14.2.17 --recurse-submodules https://github.com/frida/frida.git
proxychains git clone -b 12.8.0 --recurse-submodules https://github.com/frida/frida.git
proxychains git clone -b 15.1.28 --recurse-submodules https://github.com/frida/frida.git
 
# 指定当前下载使用代理
git clone --recurse-submodules https://github.com/frida/frida.git -c http.proxy="http://192.168.1.6:7890"
 
# 递归克隆子项目
--recurse-submodules
 
# 克隆指定版本
-b

NDK 配置

NDK 下载 | Android NDK | Android Developers

1
2
3
4
5
6
7
8
9
10
11
12
13
# 查看当前 FRIDA 版本所需的 NDK 版本
cat frida/releng/setup-env.sh |grep ndk_required=
  ndk_required=22
 
# 下载对应版本 NDK 并配置环境变量
wget https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip
unzip android-ndk-r22b-linux-x86_64
export ANDROID_NDK_ROOT=/home/k/Desktop/android-ndk-r22b  # 设置临时环境变量 不用执行 source ~/.bashrc
 
export PATH=/home/k/Desktop/android-ndk-r22b:$PATH        # 永久环境变量配置 需要使用 source ~/.bashrc 进行刷新 否者重启系统才会生效
source ~/.bashrc                                          # 刷新环境变量
env|grep NDK                                              # 查看环境变量
ndk-build -v                                              # 测试是否配置成功

Make 编译

运行 make,会列出所有编译选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
$ cd frida && make
make[1]: 进入目录“/home/k/Desktop/frida”
 
Usage: make TARGET [VARIABLE=value]
 
Where TARGET specifies one or more of:
 
  /* gum */
  gum-linux-x86                     Build for Linux/x86
  gum-linux-x86_64                  Build for Linux/x86-64
  gum-linux-x86-thin                Build for Linux/x86 without cross-arch support
  gum-linux-x86_64-thin             Build for Linux/x86-64 without cross-arch support
  gum-linux-x86_64-gir              Build for Linux/x86-64 with shared GLib and GIR
  gum-linux-arm                     Build for Linux/arm
  gum-linux-armbe8                  Build for Linux/armbe8
  gum-linux-armhf                   Build for Linux/armhf
  gum-linux-arm64                   Build for Linux/arm64
  gum-linux-mips                    Build for Linux/mips
  gum-linux-mipsel                  Build for Linux/mipsel
  gum-linux-mips64                  Build for Linux/mips64
  gum-linux-mips64el                Build for Linux/MIP64Sel
  gum-android-x86                   Build for Android/x86
  gum-android-x86_64                Build for Android/x86-64
  gum-android-arm                   Build for Android/arm
  gum-android-arm64                 Build for Android/arm64
  gum-qnx-arm                       Build for QNX/arm
  gum-qnx-armeabi                   Build for QNX/armeabi
  check-gum-linux-x86               Run tests for Linux/x86
  check-gum-linux-x86_64            Run tests for Linux/x86-64
  check-gum-linux-x86-thin          Run tests for Linux/x86 without cross-arch support
  check-gum-linux-x86_64-thin       Run tests for Linux/x86-64 without cross-arch support
  check-gum-linux-armhf             Run tests for Linux/armhf
  check-gum-linux-arm64             Run tests for Linux/arm64
 
  /* core */
  core-linux-x86                    Build for Linux/x86
  core-linux-x86_64                 Build for Linux/x86-64
  core-linux-x86-thin               Build for Linux/x86 without cross-arch support
  core-linux-x86_64-thin            Build for Linux/x86-64 without cross-arch support
  core-linux-arm                    Build for Linux/arm
  core-linux-armbe8                 Build for Linux/armbe8
  core-linux-armhf                  Build for Linux/armhf
  core-linux-arm64                  Build for Linux/arm64
  core-linux-mips                   Build for Linux/mips
  core-linux-mipsel                 Build for Linux/mipsel
  core-linux-mips64                 Build for Linux/mips64
  core-linux-mips64el               Build for Linux/mips64el
  core-android-x86                  Build for Android/x86
  core-android-x86_64               Build for Android/x86-64
  core-android-arm                  Build for Android/arm
  core-android-arm64                Build for Android/arm64
  core-qnx-arm                      Build for QNX/arm
  core-qnx-armeabi                  Build for QNX/armeabi
  check-core-linux-x86              Run tests for Linux/x86
  check-core-linux-x86_64           Run tests for Linux/x86-64
  check-core-linux-x86-thin         Run tests for Linux/x86 without cross-arch support
  check-core-linux-x86_64-thin      Run tests for Linux/x86-64 without cross-arch support
  check-core-linux-armhf            Run tests for Linux/armhf
  check-core-linux-arm64            Run tests for Linux/arm64
 
  /* python */
  python-linux-x86                  Build Python bindings for Linux/x86
  python-linux-x86_64               Build Python bindings for Linux/x86-64
  python-linux-x86-thin             Build Python bindings for Linux/x86 without cross-arch support
  python-linux-x86_64-thin          Build Python bindings for Linux/x86-64 without cross-arch support
  python-linux-armhf                Build Python bindings for Linux/armhf
  python-linux-arm64                Build Python bindings for Linux/arm64
  check-python-linux-x86            Test Python bindings for Linux/x86
  check-python-linux-x86_64         Test Python bindings for Linux/x86-64
  check-python-linux-x86-thin       Test Python bindings for Linux/x86 without cross-arch support
  check-python-linux-x86_64-thin    Test Python bindings for Linux/x86-64 without cross-arch support
  check-python-linux-armhf          Test Python bindings for Linux/armhf
  check-python-linux-arm64          Test Python bindings for Linux/arm64
 
  /* node */
  node-linux-x86                    Build Node.js bindings for Linux/x86
  node-linux-x86_64                 Build Node.js bindings for Linux/x86-64
  node-linux-x86-thin               Build Node.js bindings for Linux/x86 without cross-arch support
  node-linux-x86_64-thin            Build Node.js bindings for Linux/x86-64 without cross-arch support
  node-linux-armhf                  Build Node.js bindings for Linux/armhf
  node-linux-arm64                  Build Node.js bindings for Linux/arm64
  check-node-linux-x86              Test Node.js bindings for Linux/x86
  check-node-linux-x86_64           Test Node.js bindings for Linux/x86-64
  check-node-linux-x86-thin         Test Node.js bindings for Linux/x86 without cross-arch support
  check-node-linux-x86_64-thin      Test Node.js bindings for Linux/x86-64 without cross-arch support
  check-node-linux-armhf            Test Node.js bindings for Linux/armhf
  check-node-linux-arm64            Test Node.js bindings for Linux/arm64
 
  /* tools */
  tools-linux-x86                   Build CLI tools for Linux/x86
  tools-linux-x86_64                Build CLI tools for Linux/x86-64
  tools-linux-x86-thin              Build CLI tools for Linux/x86 without cross-arch support
  tools-linux-x86_64-thin           Build CLI tools for Linux/x86-64 without cross-arch support
  tools-linux-armhf                 Build CLI tools for Linux/armhf
  tools-linux-arm64                 Build CLI tools for Linux/arm64
  check-tools-linux-x86             Test CLI tools for Linux/x86
  check-tools-linux-x86_64          Test CLI tools for Linux/x86-64
  check-tools-linux-x86-thin        Test CLI tools for Linux/x86 without cross-arch support
  check-tools-linux-x86_64-thin     Test CLI tools for Linux/x86-64 without cross-arch support
  check-tools-linux-armhf           Test CLI tools for Linux/armhf
  check-tools-linux-arm64           Test CLI tools for Linux/arm64
 
And optionally also VARIABLE values:
  PYTHON                            Absolute path of Python interpreter including version suffix
  NODE                              Absolute path of Node.js binary
 
For example:
  $ make python-linux-x86_64 PYTHON=/opt/python36-64/bin/python3.6
  $ make node-linux-x86 NODE=/opt/node-linux-x86/bin/node

如果测试机是64位,那么就选择arm64

1
make core-android-arm64

这里会出现两个两个错误:关键词 master version

  • master 手动修改文件 | 没有规则可制作目标“.git/refs/heads/master”,由“build/frida-version.h” 需求。 停止。

    https://github.com/frida/frida/issues/1969

    1
    2
    3
    4
    5
    k@k:~/Desktop/frida$ make core-android-arm64
    make[1]: 进入目录“/home/k/Desktop/frida”
    make[1]: *** 没有规则可制作目标“.git/refs/heads/master”,由“build/frida-version.h” 需求。 停止。
    make[1]: 离开目录“/home/k/Desktop/frida”
    make: *** [Makefile:4:core-android-arm64] 错误 2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    frida$ gedit releng/frida.mk
    frida$ gedit releng/frida-deps.vcxproj
    # CTRL + H 查找 master 替换为 main
    # 修改完记得 CTRL + S 保存
     
    # 原数据
    build/frida-version.h: releng/generate-version-header.py .git/refs/heads/**master**
    # 更改为如下代码
    build/frida-version.h: releng/generate-version-header.py .git/refs/heads/**main**

    替换master

  • version 这个问题是 build/frida-version.h 文件不存在导致的,手动调用 Python 脚本传入版本信息保存地址

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    k@k:~/Desktop/frida$ ls build/
    k@k:~/Desktop/frida$ python3 releng/generate-version-header.py "build/frida-version.h"
    #ifndef __FRIDA_VERSION_H__
    #define __FRIDA_VERSION_H__
     
    #define FRIDA_VERSION "14.2.17"
     
    #define FRIDA_MAJOR_VERSION 14
    #define FRIDA_MINOR_VERSION 2
    #define FRIDA_MICRO_VERSION 17
    #define FRIDA_NANO_VERSION 0
     
    #endif
    k@k:~/Desktop/frida$ ls build/
    frida-version.h

继续执行 make core-android-arm64 进行编译

 

当编译完成之后, 会在 build/frida-android-arm64 目录找到编译后的二进制文件

1
2
$ ls build/frida-android-arm64/bin/
frida-inject  frida-server  gum-graft

build success


[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

最后于 2023-2-11 22:04 被.KK编辑 ,原因:
收藏
免费 3
支持
分享
最新回复 (6)
雪    币: 2328
活跃值: (10364)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
感谢分享,谢谢!
2023-2-15 09:28
0
雪    币: 0
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
3
frida-gum/meson.build:1:0: ERROR: Unknown compiler(s): [['/home/wulicc/Desktop/COMPILE/frida/frida/build/frida-android-arm-clang']]
这是什么问题?
2023-3-13 23:09
0
雪    币: 0
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
4
https://zhuanlan.zhihu.com/p/604566400 这篇文章 不错 编译成功
2023-3-14 13:43
0
雪    币: 178
活跃值: (1306)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
感谢分享!
2023-3-15 17:18
0
雪    币: 6408
活跃值: (4817)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
6
只有编译,说好的魔改呢
2023-5-5 00:42
0
雪    币: 3004
活跃值: (30866)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
感谢分享
2023-5-5 09:07
1
游客
登录 | 注册 方可回帖
返回
//