新人初次使用frida的js注入,这段代码在别的电脑试过没有问题可以正常注入,但是我这边怎么都过不了,就连console一个test都打印不出来,实在不知道问题出在哪里
js文件代码如下
function main() {
var resolver = new ApiResolver(‘objc’);//创建已加载Object-C类方法的API查找器
var matches = resolver.enumerateMatchesSync("-[AFSecurityPolicy evaluateServerTrust:forDomain:]");//查找evaluateServerTrust:forDomain函数,返回数组类型
console.log(“test”);
if (matches.lenght == 0) {
console.log("\n[E] -[AFSecurityPolicy evaluateServerTrust:forDomain:] is not found!\n");
return;
}
Interceptor.attach(ptr(matches[0][“address”]),{
onLeave: function(retval) {
console.log("[I] -[AFSecurityPolicy evaluateServerTrust:forDomain:] hits!");
retval.replace(1);//将返回值修改为1
}
}
);
console.log("[I] -[AFSecurityPolicy evaluateServerTrust:forDomain:] is hooked!\n")
}
命令行:frida -U -f com.mobike.bike -l hookaafsecurity.js --no-pause
结果
/ _ | Frida 12.4.4 - A world-class dynamic instrumentation toolkit
| (| |
> _ | Commands:
// |_| help → Displays the help system
. . . . object? → Display information about ‘object’
. . . . exit/quit → Exit
. . . .
. . . . More info at http://www.frida.re/docs/home/
Spawned com.mobike.bike
. Resuming main thread!
[iPhone::com.mobike.bike]-> %resume
[iPhone::com.mobike.bike]->
就是这样啥都不打印,应用会正常打开,打开之后并没有执行注入
frida安装版本如下
Successfully installed frida-12.4.4 frida-tools-1.3.2 prompt-toolkit-2.0.9
个人怀疑是frida安装问题,因为objection也无法正常注入
xkang
(Frida&IOS)
2
把function main(){} 去掉 或者末尾main();
1 个赞
main保留可以正常打开应用,去掉之后应用卡在进入的那个白屏,无法正常进入应用~~
xkang
(Frida&IOS)
4
if (ObjC.available){
try
{
var className = "AFSecurityPolicy";
var funcName = "- evaluateServerTrust:forDomain:";
var hook = eval('ObjC.classes.' + className + '["' + funcName + '"]');
Interceptor.attach(hook.implementation, {
console.log("[I] -[AFSecurityPolicy evaluateServerTrust:forDomain:] is hooked!\n");
onLeave: function(retval) {
console.log("[I] -[AFSecurityPolicy evaluateServerTrust:forDomain:] hits!");
newretval=ptr("xxxx")
retval.replace(newretval)
}
}
);
}
}
Spawned com.mobike.bike
. Resuming main thread!
[iPhone::com.mobike.bike]->
还是这样诶,输出这一句后啥也没有了~~
xkang
(Frida&IOS)
6
你不应该需要% resume嘛 你把上面那个脚本 跑一下 然后把日志发上来
嗯啊 我按照你发的又改了
只能打印这些
Spawned com.mobike.bike
. Resuming main thread!
[iPhone::com.mobike.bike]->
别的啥都没有诶
我觉得代码是没啥问题的 因为是我同学跑通了给我的 测试机我现在也是用他的 唯独换了我的电脑 但是frida我今天也是重新卸载安装了 我实在不知道环境哪里不对了
这个是我同学做这个的链接
xkang
(Frida&IOS)
10
frida -U -f com.mobike.bike -l hookaafsecurity.js
Spawned com.mobike.bike
. Use %resume to let the main thread start executing!
[iPhone::com.mobike.bike]-> %resume
[iPhone::com.mobike.bike]->
把–no-pause去掉还是这样
xkang
(Frida&IOS)
12
frida -n com.mobike.bike -l hookaafsecurity.js 先开启应用在附加
啊。。。一直在审核我的帖子,我就简单说呗~
你那个命令还是不行诶
刚刚试了你那个 frida -n com.mobike.bike -l hookaafsecurity.js这个命令 发现找不到
Failed to spawn: unable to find process with name 'com.mobike.bike’
我就查找了一下进程号
PID Name
1275 Cydia
1319 golo汽修大师
1331 微信
1381 摩拜单车
1333 设置
然后换成这个命令
frida -p 1381 -l hookaafsecurity.js
为啥还给我报错呢,。。。哎 Failed to attach: unable to find process with pid 1381
用了这个命令说是找不到进程 我就换成
$ frida -p 1381 -l hookaafsecurity.js
进程号确认没错
PID Name
1275 Cydia
1319 golo汽修大师
1331 微信
1381 摩拜单车
然后还是报错
Failed to attach: unable to find process with pid 1381
哭泣。。。。
我有两个测试机都测试过
1 ios版本 10.3.3 frida 12.4.4
2 ios版本 9.0.1 frida 12.4.4
哦啊。。。。但是-U一直都不行啊,hhhhh等等吧 我正在把所有东西都重装一遍
重新安装了,python都重装了还是不行。。直到我重新建了一个js文件。。一模一样的内容居然就可以了。。我也是无奈了。