-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAndroid-ClassMethod-Enum.js
88 lines (79 loc) · 2.06 KB
/
Android-ClassMethod-Enum.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Original filename: raptor_frida_android_enum.js
* Copyright (c) 2017 Marco Ivaldi <[email protected]>
*
* Example usage:
* # frida -U -f com.target.app -l raptor_frida_android_enum.js --no-pause
*/
// Enumerate all Java classes
function enumAllClasses()
{
var allClasses = [];
// Enumerate all currently loaded classes
var classes = Java.enumerateLoadedClassesSync();
// Iterate over each loaded class
classes.forEach(function(aClass) {
try {
var className = aClass.match(/[L](.*);/)[1].replace(/\//g, ".");
}
catch(err) {
// Avoid TypeError: cannot read property 1 of null
}
// Add class name to array
allClasses.push(className);
});
// Return the array containing all class names
return allClasses;
}
// Find all Java classes that match a pattern
function findClasses(pattern)
{
// Enumerate all classes
var allClasses = enumAllClasses();
var foundClasses = [];
// Iterate over each loaded class
allClasses.forEach(function(aClass) {
try {
if (aClass.match(pattern)) {
// Matching class name found and
foundClasses.push(aClass);
}
}
catch(err) {
// Avoid TypeError: cannot read property 'match' of undefined
}
});
// Return the array containing all matching class names
return foundClasses;
}
// Enumerate all methods declared in a Java class
function enumMethods(targetClass)
{
// Get a class handler of the target class
var hook = Java.use(targetClass);
// Get all methods exposed inside the class
var ownMethods = hook.class.getDeclaredMethods();
hook.$dispose;
// Return the enumerated methods
return ownMethods;
}
// avoid java.lang.ClassNotFoundException
setTimeout(function() {
Java.perform(function() {
// enumerate all classes
/*var a = enumAllClasses();
a.forEach(function(s) {
console.log(s);
});*/
// find classes that match a pattern
/*var a = findClasses(/dbrunner/i);
a.forEach(function(s) {
console.log(s);
});*/
// enumerate all methods in a class
/*var a = enumMethods("android.util.Base64")
a.forEach(function(s) {
console.log(s);
});*/
});
}, 0);