-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhookallmethods.js
More file actions
58 lines (48 loc) · 2 KB
/
hookallmethods.js
File metadata and controls
58 lines (48 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Hook al methods from https://github.com/haseeburrehmanfaheem/Frida-Scripts-Android/tree/main
Java.perform(function () {
Java.enumerateClassLoaders({
onMatch: function (loader) {
Java.classFactory.loader = loader;
var TestClass;
// Hook the class if found, else try next classloader.
try {
// TestClass = Java.use(
// "com.android.server.bluetooth.BluetoothManagerService$6"
// );
TestClass = Java.use(
"com.android.server.location.LocationManagerService"
);
console.log("[+] Found class using classloader: " + loader);
var methods = TestClass.class.getDeclaredMethods();
console.log("[+] Found " + methods.length + " methods in class.");
methods.forEach((element) => {
console.log(element);
var method_name = element.getName();
try{
var overloads = TestClass[element.getName()].overloads;
console.log("Method: " + method_name, "Overloads: " + overloads);
overloads.forEach((overload) => {
overload.implementation = function () {
console.log("called " + TestClass + "." + method_name);
console.log("Arguments: " + arguments);
var result = this[element.getName()].apply(this, arguments);
console.log("Result: " + result);
return result;
};
});
} catch (error) {
console.log("Error: " + error);
}
});
return
} catch (error) {
if (error.message.includes("ClassNotFoundException")) {
console.log(
"\n You are trying to load encrypted class, trying next loader"
);
}
}
},
onComplete: function () {},
});
});