-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest1.js
160 lines (140 loc) · 4.88 KB
/
test1.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function HookObj(wrapper, clazz, fields, methods, constructors) {
this.wrapper = wrapper;
this.clazz = clazz;
this.fields = fields;
this.methods = methods;
this.constructors = constructors;
this.hook = function (funcName, func) {
if (wrapper == null || wrapper[funcName] == null) {
return false;
}
wrapper[funcName].implementation = func;
return true;
}
}
function HookJava() {
this.hookObjects = {};
this.loadClass = function (className) {
var hookObj = null;
var wrapper = null;
var clazz = null;
var fields = null;
var methods = null;
var constructors = null;
hookObj = this.hookObjects[className];
if (hookObj != null) {
return hookObj;
}
try {
// 通过 Frida 获取该类名的 JS 包装: wrapper
wrapper = Java.use(className);
// 获取该类名的 java.lang.class 对象
clazz = wrapper.class;
// 获取该类定义的成员
fields = clazz.getDeclaredFields();
for (var i in fields) {
// 设置每个成员的可访问属性
fields[i].setAccessible(true);
}
// 获取该类定义的方法
methods = clazz.getDeclaredMethods();
for (var i in methods) {
// 设置每个方法的可访问属性
methods[i].setAccessible(true);
}
} catch (e) {
console.log(e);
}
if (wrapper == null) {
return null
}
hookObj = new HookObj(wrapper, clazz, fields, methods, constructors);
this.hookObjects[className] = hookObj;
return hookObj;
}
}
var hook = new HookJava();
var classesName = [
"java.util.ArrayList",
"java.lang.ClassLoader",
"java.lang.Byte",
"java.lang.Thread",
"java.lang.Object",
"java.lang.String",
"java.lang.Integer",
"java.lang.Exception",
"java.lang.reflect.Array",
"java.io.ByteArrayInputStream",
"android.widget.TextView",
"java.lang.CharSequence",
"android.widget.TextView$BufferType",
// ----------------------------------
"com.illuminate.texaspoker.utils.NetworkUtil"
];
Java.perform(function () {
//console.log(".");
//console.log("begin load class!");
//for (var i in classesName) {
// var hookObj = hook.loadClass(classesName[i]);
// if (hookObj == null) {
// console.log(classesName[i] + " load failed!");
// }
//}
//console.log("end load class!");
var URLClassLoaderWrapper = Java.use("java.net.URLClassLoader");
var URLWrapper = Java.use("java.net.URL");
var URLObject = URLWrapper.$new('file:/data/local/tmp/reflections-0.9.11.jar');
console.log(URLObject);
//for (var i in URLnew) {
// console.log(i + ": " + URLnew[i]);
//}
//console.log("---------");
//for (var i in URLnew.argumentTypes[0]) {
// console.log(i + ": " + URLnew.argumentTypes[0][i]);
//}
//console.log(URLnew.argumentTypes);
//URLClassLoaderWrapper.$new().overload("[java.net.URL")([URLObj]);
//var ClasspathHelperWrapper = Java.use("org.reflections.util.ClasspathHelper");
//console.log(ClasspathHelperWrapper.contextClassLoader);
//var PackageWrapper = Java.use("java.lang.Package");
//console.log(PackageWrapper.getPackages());
//var PackageClass = PackageWrapper.class;
//var PackageMethods = PackageClass.getDeclaredMethods();
//for (var i in PackageMethods) {
// PackageMethods[i].setAccessible(true);
//}
//var ClassLoaderWrapper = Java.use("java.lang.ClassLoader");
//var ClassLoaderClass = ClassLoaderWrapper.class;
//var ClassLoaderMethods = ClassLoaderClass.getDeclaredMethods();
//for (var i in ClassLoaderMethods) {
// ClassLoaderMethods[i].setAccessible(true);
//}
//var systemClassLoaderObj = ClassLoaderWrapper.getSystemClassLoader();
//var systemClassLoaderClass = systemClassLoaderObj.class;
//var systemClassLoaderClassMethods = systemClassLoaderClass.getDeclaredMethods();
//for (var i in systemClassLoaderClassMethods) {
// systemClassLoaderClassMethods[i].setAccessible(true);
// //console.log(i + ": " + systemClassLoaderClassMethods[i]);
//}
//console.log(systemClassLoaderObj.getParent().getParent());
//var packages = systemClassLoaderObj.getPackages();
//for (var i in packages) {
// console.log(i + ": " + packages[i]);
//}
//var NetworkUtil = hook.hookObjects["com.illuminate.texaspoker.utils.NetworkUtil"];
////for (var i in NetworkUtil.methods) {
//// console.log(NetworkUtil.methods[i]);
////}
//
//// Hook NetworkUtil.login == NetworkUtil.a('java.lang.String','java.lang.String','java.lang.String')
//NetworkUtil.wrapper.a.overload('java.lang.String','java.lang.String','java.lang.String').implementation = function(arg1, arg2, arg3) {
// var log = "NetworkUtil.login:\n";
// log += " strID: " + arg1 + "\n";
// log += " strPWD: " + arg2 + "\n";
// log += " strCountryCode: " + arg3 + "\n";
// var ret = this.a(arg1, arg2, arg3);
// log += " ret: " + ret + "\n";
// console.log(log);
// return ret;
//};
});