#前言
frida的官方文档写的并不是很好,有些例子好像还有些问题。这就不得不去研究它的源码了。frida的源码有许多个模块,我们这只关注 frida-java-bridge这个模块。为什么呢?这个模块实现了js世界到java世界的单向通道。所以我们主要的代码在这。可以看看这篇文章对frida-java的介绍frida源码阅读之frida-java。
这里我就记录一下frida-java的编译环境搭建
#环境
VMware 12
Ubuntu16
Android8.0
Google pixel (已root)
#步骤
1.下载安装配置Ubuntu16需要使用到的软件
1.安装配置JDK
2.安装配置SDK
3.安装配置NDK
4.编译安装Nodejs
5.编译运行frida-java
这里就跳过安装Ubuntu16虚拟机的步骤了
#下载安装配置Ubuntu16需要使用到的软件
配置apt国内软件源镜像
使用清华大学开源软件镜像站
将软件源的配置拷贝到
更新apt
安装curl
安装git
#安装配置JDK
下载jdk
http://jdk.android-studio.org/
这里为了方便我在家目录创建一个work目录,有关环境我都安装到这个目录下。读者可以自行选择目录、
将下载的jdk解压
配置环境变量
加入配置如下,请修改自己的jdk位置
加载配置
查看是否配置成功
#安装配置SDK
这里我借助android studio进行下载sdk。
android studio下载地址:http://www.android-studio.org/
下载后移动到work目录,解压运行
其他操作和Windows上的as一样
安装sdk版本,我们下载29版本。
这里可以看到as下载的sdk在/home/fj/Android/Sdk,所以我们需要配置这个目录的环境变量
配置如下,请注意修改自己sdk的位置:
注意配置build-tools/30.0.3 因为编译时会用到dx
加载配置文件
运行dx命令,如果出现以下信息说明成功
#安装配置NDK
ndk下载地址:https://developer.android.google.cn/ndk/downloads/
下载android-ndk-r21d-linux-x86_64.zip这个版本,因为frida的ndk默认版本就是这个
下载后移动到work目录,解压
添加/etc/profile配置
加载配置文件
查看ndk版本,如果出现以下信息说明成功
#编译安装Nodejs
这里我使用源码安装,使用apt安装的话版本过老。不支持frida的编译,并且升级麻烦。
修改目录权限:
使用 ./configure 创建编译文件,并按照:
查看 node 和npm版本:
#编译运行frida-java
使用Git下载frida-java-bridge源码,这里我选择3.9.4,因为我的frida用的就是这个版本
frida-java对应的版本在test/Makefile下可以看到
修改配置文件
修改为如下内容
一般情况修改上面我注释的部分就行了,如果你的机型的架构不一样注意修改一下。
进行编译
如果你看到
daemon started successfully
adb: no devices/emulators found
这些信息说明编译成功了,后面的错误是因为我还有没有连接我的手机。
测试运行
现在连接上我的手机,这里我使用无线adb的方式连接
再次编译运行
看到最后面的OK就知道成功了,其中有58个方法被测试。
sudo gedit
/
etc
/
apt
/
sources.
list
sudo gedit
/
etc
/
apt
/
sources.
list
sudo apt
-
get update
sudo apt
-
get install curl
sudo apt
-
get install curl
sudo apt
-
get install git
mkdir work
tar
-
zxvf jdk
-
8u77
-
linux
-
x64.tar.gz
tar
-
zxvf jdk
-
8u77
-
linux
-
x64.tar.gz
sudo gedit
/
etc
/
profile
export JAVA_HOME
=
/
home
/
fj
/
work
/
jdk1.
8.0_231
export JRE_HOME
=
${JAVA_HOME}
/
jre
export CLASSPATH
=
.:${JAVA_HOME}
/
lib:${JRE_HOME}
/
lib
export PATH
=
${JAVA_HOME}
/
bin
:$PATH
export JAVA_HOME
=
/
home
/
fj
/
work
/
jdk1.
8.0_231
export JRE_HOME
=
${JAVA_HOME}
/
jre
export CLASSPATH
=
.:${JAVA_HOME}
/
lib:${JRE_HOME}
/
lib
export PATH
=
${JAVA_HOME}
/
bin
:$PATH
source
/
etc
/
profile
fj@ubuntu:~
/
work
/
jdk1.
8.0_231
$ java
-
version
java version
"1.8.0_231"
Java(TM) SE Runtime Environment (build
1.8
.
0_231
-
b11)
Java HotSpot(TM)
64
-
Bit Server VM (build
25.231
-
b11, mixed mode)
fj@ubuntu:~
/
work
/
jdk1.
8.0_231
$ java
-
version
java version
"1.8.0_231"
Java(TM) SE Runtime Environment (build
1.8
.
0_231
-
b11)
Java HotSpot(TM)
64
-
Bit Server VM (build
25.231
-
b11, mixed mode)
tar
-
zxvf android
-
studio
-
ide
-
191.5977832
-
linux.tar.gz
cd android
-
studio
/
bin
.
/
studio.sh
tar
-
zxvf android
-
studio
-
ide
-
191.5977832
-
linux.tar.gz
cd android
-
studio
/
bin
.
/
studio.sh
sudo gedit
/
etc
/
profile
export ANDROID_SDK_HOME
=
/
home
/
fj
/
Android
/
Sdk
export PATH
=
$PATH:${ANDROID_SDK_HOME}
/
tools
export PATH
=
$PATH:${ANDROID_SDK_HOME}
/
build
-
tools
/
30.0
.
3
export PATH
=
$PATH:${ANDROID_SDK_HOME}
/
platform
-
tools
export ANDROID_SDK_HOME
=
/
home
/
fj
/
Android
/
Sdk
export PATH
=
$PATH:${ANDROID_SDK_HOME}
/
tools
export PATH
=
$PATH:${ANDROID_SDK_HOME}
/
build
-
tools
/
30.0
.
3
export PATH
=
$PATH:${ANDROID_SDK_HOME}
/
platform
-
tools
source
/
etc
/
profile
fj@ubuntu:~
/
work
/
android
-
ndk
-
r21d$ dx
error: no command specified
usage:
dx
-
-
dex [
-
-
debug] [
-
-
verbose] [
-
-
positions
=
<style>] [
-
-
no
-
locals
]
[
-
-
no
-
optimize] [
-
-
statistics] [
-
-
[no
-
]optimize
-
list
=
<
file
>] [
-
-
no
-
strict]
[
-
-
keep
-
classes] [
-
-
output
=
<
file
>] [
-
-
dump
-
to
=
<
file
>] [
-
-
dump
-
width
=
<n>]
[
-
-
dump
-
method
=
<name>[
*
]] [
-
-
verbose
-
dump] [
-
-
no
-
files] [
-
-
core
-
library]
[
-
-
num
-
threads
=
<n>] [
-
-
incremental] [
-
-
force
-
jumbo] [
-
-
no
-
warning]
[
-
-
multi
-
dex [
-
-
main
-
dex
-
list
=
<
file
> [
-
-
minimal
-
main
-
dex]]
[
-
-
input
-
list
=
<
file
>] [
-
-
min
-
sdk
-
version
=
<n>]
[
-
-
allow
-
all
-
interface
-
method
-
invokes]
fj@ubuntu:~
/
work
/
android
-
ndk
-
r21d$ dx
error: no command specified
usage:
dx
-
-
dex [
-
-
debug] [
-
-
verbose] [
-
-
positions
=
<style>] [
-
-
no
-
locals
]
[
-
-
no
-
optimize] [
-
-
statistics] [
-
-
[no
-
]optimize
-
list
=
<
file
>] [
-
-
no
-
strict]
[
-
-
keep
-
classes] [
-
-
output
=
<
file
>] [
-
-
dump
-
to
=
<
file
>] [
-
-
dump
-
width
=
<n>]
[
-
-
dump
-
method
=
<name>[
*
]] [
-
-
verbose
-
dump] [
-
-
no
-
files] [
-
-
core
-
library]
[
-
-
num
-
threads
=
<n>] [
-
-
incremental] [
-
-
force
-
jumbo] [
-
-
no
-
warning]
[
-
-
multi
-
dex [
-
-
main
-
dex
-
list
=
<
file
> [
-
-
minimal
-
main
-
dex]]
[
-
-
input
-
list
=
<
file
>] [
-
-
min
-
sdk
-
version
=
<n>]
[
-
-
allow
-
all
-
interface
-
method
-
invokes]
unzip android
-
ndk
-
r21d
-
linux
-
x86_64.
zip
cd android
-
ndk
-
r21d
unzip android
-
ndk
-
r21d
-
linux
-
x86_64.
zip
cd android
-
ndk
-
r21d
export NDK_HOME
=
/
home
/
fj
/
work
/
android
-
ndk
-
r21d
export PATH
=
$NDK_HOME:$PATH
export NDK_HOME
=
/
home
/
fj
/
work
/
android
-
ndk
-
r21d
export PATH
=
$NDK_HOME:$PATH
source
/
etc
/
profile
fj@ubuntu:~
/
work
/
android
-
ndk
-
r21d$ ndk
-
build
-
-
v
GNU Make
4.2
.
1
Built
for
x86_64
-
pc
-
linux
-
gnu
Copyright (C)
1988
-
2016
Free Software Foundation, Inc.
License GPLv3
+
: GNU GPL version
3
or
later <http:
/
/
gnu.org
/
licenses
/
gpl.html>
This
is
free software: you are free to change
and
redistribute it.
There
is
NO WARRANTY, to the extent permitted by law.
fj@ubuntu:~
/
work
/
android
-
ndk
-
r21d$ ndk
-
build
-
-
v
GNU Make
4.2
.
1
Built
for
x86_64
-
pc
-
linux
-
gnu
Copyright (C)
1988
-
2016
Free Software Foundation, Inc.
License GPLv3
+
: GNU GPL version
3
or
later <http:
/
/
gnu.org
/
licenses
/
gpl.html>
This
is
free software: you are free to change
and
redistribute it.
There
is
NO WARRANTY, to the extent permitted by law.
$ sudo git clone https:
/
/
github.com
/
nodejs
/
node.git
Cloning into
'node'
...
$ sudo git clone https:
/
/
github.com
/
nodejs
/
node.git
Cloning into
'node'
...
$ sudo chmod
-
R
755
node
$ cd node
$ sudo .
/
configure
$ sudo make
$ sudo make install
$ cd node
$ sudo .
/
configure
$ sudo make
$ sudo make install
fj@ubuntu:~
/
work
/
node$ npm
-
v
7.4
.
2
fj@ubuntu:~
/
work
/
node$ node
-
v
v16.
0.0
-
pre
fj@ubuntu:~
/
work
/
node$ npm
-
v
7.4
.
2
fj@ubuntu:~
/
work
/
node$ node
-
v
v16.
0.0
-
pre
fj@ubuntu:~
/
work$ git clone https:
/
/
github.com
/
frida
/
frida
-
java
-
bridge.git
-
-
tag
3.9
.
4
fj@ubuntu:~
/
work$ git clone https:
/
/
github.com
/
frida
/
frida
-
java
-
bridge.git
-
-
tag
3.9
.
4
frida_version :
=
12.11
.
14
frida_version :
=
12.11
.
14
cd frida
-
java
-
bridge
/
sudo gedit test
/
config.mk
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)