首先我们自制一个dex,简单封装一个MD5的样例。代码如下:
然后我们开始打包编译成dex文件。
开始编写frida 脚本,代码如下:
package com.example.xibei;
import
java.math.BigInteger;
import
java.security.MessageDigest;
public
class
SignMd5 {
public static String md5(String
str
){
try
{
/
/
生成一个MD5加密计算摘要
MessageDigest md
=
MessageDigest.getInstance(
"MD5"
);
/
/
计算md5函数
md.update(
str
.getBytes());
return
new BigInteger(
1
, md.digest()).toString(
16
);
} catch (Exception e) {
e.printStackTrace();
return
null;
}
}
}
package com.example.xibei;
import
java.math.BigInteger;
import
java.security.MessageDigest;
public
class
SignMd5 {
public static String md5(String
str
){
try
{
/
/
生成一个MD5加密计算摘要
MessageDigest md
=
MessageDigest.getInstance(
"MD5"
);
/
/
计算md5函数
md.update(
str
.getBytes());
return
new BigInteger(
1
, md.digest()).toString(
16
);
} catch (Exception e) {
e.printStackTrace();
return
null;
}
}
}
jar
-
cvf xibei.jar com
/
example
/
xibei
jar
-
cvf xibei.jar com
/
example
/
xibei
/
root
/
Android
/
Sdk
/
build
-
tools
/
30.0
.
3
/
dx
-
-
dex
-
-
output xibei.dex xibei.jar
/
root
/
Android
/
Sdk
/
build
-
tools
/
30.0
.
3
/
dx
-
-
dex
-
-
output xibei.dex xibei.jar
adb push
/
data
/
local
/
tmp
/
xibei.dex
chmod
777
xibei.dex
adb push
/
data
/
local
/
tmp
/
xibei.dex
chmod
777
xibei.dex
function dy_dex() {
var xibei
=
Java.openClassFile(
"/data/local/tmp/xibei.dex"
);
Java.perform(function () {
xibei.load();
var md5Clazz
=
Java.use(
"com.example.xibei.SignMd5"
);
console.log(
"md5 sign :"
, md5Clazz.md5(
"123456"
));
})
}
function main() {
dy_dex()
}
setImmediate(main)
/
/
结果 : [Google Pixel
2
XL::WiFi ADB]
-
> md5 sign : e10adc3949ba59abbe56e057f20f883e
function dy_dex() {
var xibei
=
Java.openClassFile(
"/data/local/tmp/xibei.dex"
);
Java.perform(function () {
xibei.load();
var md5Clazz
=
Java.use(
"com.example.xibei.SignMd5"
);
console.log(
"md5 sign :"
, md5Clazz.md5(
"123456"
));
})
}
function main() {
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!