我想通过与frida挂钩来更改onClick方法的行为。 我使用的代码是
Java.perform(function() {
console.log("[*] START...")
var mClass = Java.use("sg.vantagepoint.uncrackable1.MainActivity")
mClass.a.onClick.implementation=function() {
console.log("[*] Clicked ")
}
})
出现错误
TypeError: cannot write property 'implementation' of undefined
at [anon] (../../../frida-gum/bindings/gumjs/duktape.c:57636)
at /uncrackable1.js:6
at frida/node_modules/frida-java-bridge/lib/vm.js:11
at E (frida/node_modules/frida-java-bridge/index.js:346)
at frida/node_modules/frida-java-bridge/index.js:298
at frida/node_modules/frida-java-bridge/lib/vm.js:11
at frida/node_modules/frida-java-bridge/index.js:278
at /uncrackable1.js:11
源代码是
private void a(String str) {
AlertDialog create = new AlertDialog.Builder(this).create();
create.setTitle(str);
create.setMessage("This is unacceptable. The app is now going to exit.");
create.setButton(-3, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
System.exit(0);
}
});
答案 0 :(得分:2)
您正试图钩住错误的类-很有可能是因为您使用Jadx来反编译错误的设置,并且对Java类一无所知。
如果您使用 Jadx 来反编译APK文件,请确保禁用设置内联匿名类以查看真实的类名方法属于。
方法library(magrittr)
test[ , c(
list(a = unique(a)),
lapply(.SD, function(x) {
table(x) %>% sort %>% names %>% tail(1L) %>% as(class(x))
})
), .SDcols = !'a']
属于onClick()
创建的匿名内部类,而不属于new DialogInterface.OnClickListener()
-因此,您正在尝试挂钩错误的类。使用的方法sg.vantagepoint.uncrackable1.MainActivity
与钩子完全无关。匿名内部类基于由a(String)
附加的外部类和一个数字来拥有自己的类名称。
因此,正确的类名称可以是$
或sg.vantagepoint.uncrackable1.MainActivity$1
,具体取决于存在多少其他匿名内部类。
另外不可能使用类似sg.vantagepoint.uncrackable1.MainActivity$2
的方法,因为方法内部没有方法(mClass.a.onClick
是方法,a
是方法)。
最后,您可能会得到以下frida代码:
onClick