由于最近一直在学习frida反调试的方面的知识,所以一遍想整理一下资料文章等,后续可能会出针对各厂商的frida检测的bypass方案。大家多多关注另外有需要过frida反调试的可以去联系博主主页V。
let V = '15232101239';
一、介绍
Frida 是一个强大的动态分析和调试工具,广泛用于逆向工程、安全研究和应用程序的分析。Frida 允许开发者、渗透测试人员或研究人员在运行时注入 JavaScript 代码,动态地修改或监控应用程序的行为。由于其强大的功能,Frida 在防止反调试和检测应用程序中的使用场景中也变得非常重要。
二、常见的检测方式
frida本身就有许多特征而且又是开源项目,所以检测点很多。
1.双进程保护
命令直接 frida -UF
解决方案:spawn启动
2、检查Frida默认27042端口,比如:
boolean is_frida_server_listening() {
struct sockaddr_in sa;
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(27047);
inet_aton("127.0.0.1", &(sa.sin_addr));
int sock = socket(AF_INET , SOCK_STREAM , 0);
if (connect(sock , (struct sockaddr*)&sa , sizeof sa) != -1) {
/* Frida server detected. Do something… */
}
}
解决方案:修改端口号
3、检测maps检测
我们以mt管理器为例子我们查看进程
taimen:/ # ps -ef | grep bin.mt.plus
u0_a193 21203 878 2 11:19:42 ? 00:00:17 bin.mt.plus
root 21282 1 0 11:19:43 ? 00:00:00 mtio daemon @bin.mt.plus-2320923 0
root 21291 1 0 11:19:43 ? 00:00:00 mtio daemon @bin.mt.plus-2320923 0
root 21301 1 0 11:19:43 ? 00:00:00 mtio daemon @bin.mt.plus-2320923 0
root 22726 22620 8 11:35:01 pts/3 00:00:00 grep bin.mt.plus
taimen:/ #
我们注入Frida查看。
解决方案:魔改frida 使其无法检测字符串 这方面我们可以参考第三部分的优秀项目
4、当然你也可以尝试一把梭
function replace_str() {
var pt_strstr = Module.findExportByName("libc.so", 'strstr');
var pt_strcmp = Module.findExportByName("libc.so", 'strcmp');
Interceptor.attach(pt_strstr, {
onEnter: function (args) {
var str1 = args[0].readCString();
var str2 = args[1].readCString();
if (
str2.indexOf("REJECT") !== -1 ||
str2.indexOf("tmp") !== -1 ||
str2.indexOf("frida") !== -1 ||
str2.indexOf("gum-js-loop") !== -1 ||
str2.indexOf("gmain") !== -1 ||
str2.indexOf("linjector") !== -1
) {
console.log("strstr-->", str1, str2);
this.hook = true;
}
}, onLeave: function (retval) {
if (this.hook) {
retval.replace(0);
}
}
});
Interceptor.attach(pt_strcmp, {
onEnter: function (args) {
var str1 = args[0].readCString();
var str2 = args[1].readCString();
if (
str2.indexOf("REJECT") !== -1 ||
str2.indexOf("tmp") !== -1 ||
str2.indexOf("frida") !== -1 ||
str2.indexOf("gum-js-loop") !== -1 ||
str2.indexOf("gmain") !== -1 ||
str2.indexOf("linjector") !== -1
) {
//console.log("strcmp-->", str1, str2);
this.hook = true;
}
}, onLeave: function (retval) {
if (this.hook) {
retval.replace(0);
}
}
})
}
replace_str();
三、魔改frida优秀项目参考
https://github.com/Ylarod/Florida
ajeossida/README.md at main · hackcatml/ajeossida
Releases · hzzheyang/strongR-frida-android
这些大家都可以去看看 去研究下
四、总结
上面我们只是简述了一部分常见检测方式,当然Frida毕竟作为一个开源项目 其被检测的点太多了,之后文章会更加关注于分篇章章节去写针对各厂商的frida检测的方案。