forked from CreditTone/hooker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
org.json.JSONObject.js
171 lines (154 loc) · 6.13 KB
/
org.json.JSONObject.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
161
162
163
164
165
166
167
168
169
170
171
//org.json.JSONObject:_
function loadDexfile(dexfile) {
Java.perform(function() {
Java.openClassFile(dexfile).load();
console.log("load " + dexfile);
});
};
function checkLoadDex(className, dexfile) {
Java.perform(function() {
if (!classExists(className)) {
Java.openClassFile(dexfile).load();
console.log("load " + dexfile);
}
});
};
function classExists(className) {
var exists = false;
try {
var clz = Java.use(className);
exists = true;
} catch(err) {
//console.log(err);
}
return exists;
};
function getClassName(obj) {
if (obj.getClass) {
return obj.getClass().getName();
}
var javaObject = Java.use("java.lang.Object");
return Java.cast(obj, javaObject).getClass().getName();
}
//str1是否包含str2,str2可用正则表示
function contains(str1, str2) {
var reg = RegExp(eval("/"+str2+"/"));
if(str1 && str1.match && str1.match(reg)){
return true;
}else{
return false;
}
};
//创建ArrayList对象用这个方法就好了
function newArrayList() {
var ArrayListClz = Java.use('java.util.ArrayList');
return ArrayListClz.$new();
}
//创建HashSet对象用这个方法就好了
function newHashSet() {
var HashSetClz = Java.use('java.util.HashSet');
return HashSetClz.$new();
}
//创建HashMap对象用这个方法就好了
function newHashMap() {
var HashMapClz = Java.use('java.util.HashMap');
return HashMapClz.$new();
}
function methodInBeat(invokeId, timestamp, methodName, executor) {
var startTime = timestamp;
var androidLogClz = Java.use("android.util.Log");
var exceptionClz = Java.use("java.lang.Exception");
var threadClz = Java.use("java.lang.Thread");
var currentThread = threadClz.currentThread();
var stackInfo = androidLogClz.getStackTraceString(exceptionClz.$new());
console.log("------------startFlag:" + invokeId + ",objectHash:"+executor+",thread(id,name:" + currentThread.getId() +"," + currentThread.getName() + "),timestamp:" + startTime+"---------------");
console.log(methodName);
console.log(stackInfo.substring(20));
console.log("------------endFlag:" + invokeId + ",usedtime:" + (new Date().getTime() - startTime) +"---------------\n");
};
function log(str) {
console.log(str);
};
function getBaseContext() {
var currentApplication = Java.use('android.app.ActivityThread').currentApplication();
var context = currentApplication.getApplicationContext();
return context; //Java.scheduleOnMainThread(fn):
};
function sleep(time) {
var startTime = new Date().getTime() + parseInt(time, 10);
while(new Date().getTime() < startTime) {}
};
function loadXinitDexfile(dexfile) {
loadDexfile('/data/user/0/com.kugou.shiqutouch/xinit/'+dexfile);
};
var containRegExps = new Array(RegExp(/17岁/))
var notContainRegExps = new Array(RegExp(/\.jpg$/))
function check(stringJavaObject) {
var str = stringJavaObject.toString();
if (! (str && str.match)) {
return false;
}
for (var i = 0; i < containRegExps.length; i++) {
if (!str.match(containRegExps[i])) {
return false;
}
}
for (var i = 0; i < notContainRegExps.length; i++) {
if (str.match(notContainRegExps[i])) {
return false;
}
}
return true;
}
Java.perform(function() {
var org_json_JSONObject_clz = Java.use('org.json.JSONObject');
var org_json_JSONObject_clz_init_3nte = org_json_JSONObject_clz.$init.overload();
org_json_JSONObject_clz_init_3nte.implementation = function() {
var invokeId = Math.random().toString(36).slice( - 8);
var startTime = new Date().getTime();
var executor = this.hashCode();
var obj = org_json_JSONObject_clz_init_3nte.call(this);
methodInBeat(invokeId, startTime, 'public org.json.JSONObject()', executor);
return obj;
};
var org_json_JSONObject_clz_init_ppyl = org_json_JSONObject_clz.$init.overload('java.util.Map');
org_json_JSONObject_clz_init_ppyl.implementation = function(v0) {
var invokeId = Math.random().toString(36).slice( - 8);
var startTime = new Date().getTime();
var executor = this.hashCode();
var obj = org_json_JSONObject_clz_init_ppyl.call(this, v0);
methodInBeat(invokeId, startTime, 'public org.json.JSONObject(java.util.Map)', executor);
return obj;
};
var org_json_JSONObject_clz_init_ovu5 = org_json_JSONObject_clz.$init.overload('org.json.JSONObject', '[Ljava.lang.String;');
org_json_JSONObject_clz_init_ovu5.implementation = function(v0, v1) {
var invokeId = Math.random().toString(36).slice( - 8);
var startTime = new Date().getTime();
var executor = this.hashCode();
var obj = org_json_JSONObject_clz_init_ovu5.call(this, v0, v1);
methodInBeat(invokeId, startTime, 'public org.json.JSONObject(org.json.JSONObject,java.lang.String[]) throws org.json.JSONException', executor);
return obj;
};
var org_json_JSONObject_clz_init_0004 = org_json_JSONObject_clz.$init.overload('org.json.JSONTokener');
org_json_JSONObject_clz_init_0004.implementation = function(v0) {
var invokeId = Math.random().toString(36).slice( - 8);
var startTime = new Date().getTime();
var executor = this.hashCode();
var obj = org_json_JSONObject_clz_init_0004.call(this, v0);
methodInBeat(invokeId, startTime, 'public org.json.JSONObject(org.json.JSONTokener) throws org.json.JSONException', executor);
return obj;
};
var org_json_JSONObject_clz_init_p4nq = org_json_JSONObject_clz.$init.overload('java.lang.String');
org_json_JSONObject_clz_init_p4nq.implementation = function(v0) {
var invokeId = Math.random().toString(36).slice( - 8);
var startTime = new Date().getTime();
var executor = this.hashCode();
var obj = org_json_JSONObject_clz_init_p4nq.call(this, v0);
if (check(v0)) {
log(v0);
methodInBeat(invokeId, startTime, 'public org.json.JSONObject(java.lang.String) throws org.json.JSONException', executor);
}
//
return obj;
};
});