forked from CreditTone/hooker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.js
244 lines (217 loc) · 12.4 KB
/
com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//crack by com.ss.android.ugc.aweme 15.0.0
//com.bytedance.frameworks.core.encrypt.RequestEncryptUtils
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 newMethodBeat(text, executor) {
var threadClz = Java.use("java.lang.Thread");
var androidLogClz = Java.use("android.util.Log");
var exceptionClz = Java.use("java.lang.Exception");
var processClz = Java.use("android.os.Process");
var currentThread = threadClz.currentThread();
var beat = new Object();
beat.invokeId = Math.random().toString(36).slice( - 8);
beat.executor = executor;
beat.myPid = processClz.myPid();
beat.threadId = currentThread.getId();
beat.threadName = currentThread.getName();
beat.text = text;
beat.startTime = new Date().getTime();
beat.stackInfo = androidLogClz.getStackTraceString(exceptionClz.$new()).substring(20);
return beat;
};
function printBeat(beat) {
var str = ("------------pid:" + beat.myPid + ",startFlag:" + beat.invokeId + ",objectHash:"+beat.executor+",thread(id:" + beat.threadId +",name:" + beat.threadName + "),timestamp:" + beat.startTime+"---------------\n");
str += beat.text + "\n";
str += beat.stackInfo;
str += ("------------endFlag:" + beat.invokeId + ",usedtime:" + (new Date().getTime() - beat.startTime) +"---------------\n");
console.log(str);
};
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) {}
};
var loadedXRadar = false;
function loadXinitDexfile(dexfile) {
loadDexfile('/data/user/0/com.ss.android.ugc.aweme/xinit/'+dexfile);
};
function loadXRadarDexfile() {
loadedXRadar = true;
loadDexfile('/data/user/0/com.ss.android.ugc.aweme/radar.dex');
};
function fastTojson(javaObject) {
var JSONClz = Java.use("gz.com.alibaba.fastjson.JSON");
return JSONClz.toJSONString(javaObject);
};
function getPrettyString(javaObject) {
var XPretty = Java.use("gz.util.XPretty");
return XPretty.getPrettyString(javaObject);
};
function xPretty(javaObject) {
var str = getPrettyString(javaObject);
console.log(str);
};
function getField(javaObject, fieldName) {
var X = Java.use("gz.util.X");
return X.getField(javaObject, fieldName);
};
function storeObjectAndLog(javaObject) {
var className = getClassName(javaObject);
var ObjectsStore = Java.use("gz.radar.objects.ObjectsStore");
var objectId = ObjectsStore.storeObject(javaObject);
console.log(className + " ObjectsStoreId: " +objectId);
};
//com.bytedance.frameworks.core.encrypt.RequestEncryptUtils
Java.perform(function() {
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz = Java
.use('com.bytedance.frameworks.core.encrypt.RequestEncryptUtils');
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_setDebug_9337 =
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.setDebug.overload('boolean');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_setDebug_9337.implementation = function(v0) {
var executor = 'Class';
var beatText = 'public static void com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.setDebug(boolean)';
var beat = newMethodBeat(beatText, executor);
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_setDebug_9337
.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0);
printBeat(beat);
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_setEncryptConfig_2345 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.setEncryptConfig.overload('com.bytedance.frameworks.core.encrypt.RequestEncryptUtils$a');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_setEncryptConfig_2345.implementation = function(v0) {
var executor = 'Class';
var beatText = 'public static void com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.setEncryptConfig(com.bytedance.frameworks.core.encrypt.RequestEncryptUtils$a)';
var beat = newMethodBeat(beatText, executor);
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_setEncryptConfig_2345.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0);
printBeat(beat);
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryEncryptRequest_2985 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.tryEncryptRequest.overload('java.lang.String', 'java.util.List');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryEncryptRequest_2985.implementation = function(v0, v1) {
var executor = 'Class';
var beatText = 'public static java.lang.String com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.tryEncryptRequest(java.lang.String,java.util.List)';
var beat = newMethodBeat(beatText, executor);
var ret = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryEncryptRequest_2985.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0, v1);
printBeat(beat);
return ret;
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryEncryptRequestBody_5472 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.tryEncryptRequestBody.overload('[B');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryEncryptRequestBody_5472.implementation = function(v0) {
var executor = 'Class';
var beatText = 'public static byte[] com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.tryEncryptRequestBody(byte[])';
var beat = newMethodBeat(beatText, executor);
var ret = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryEncryptRequestBody_5472.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0);
printBeat(beat);
return ret;
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_format_0847 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.format.overload('java.util.List', 'boolean', 'java.lang.String');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_format_0847.implementation = function(v0, v1, v2) {
var executor = 'Class';
var beatText = 'public static java.lang.String com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.format(java.util.List,boolean,java.lang.String)';
var beat = newMethodBeat(beatText, executor);
var ret = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_format_0847.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0, v1, v2);
printBeat(beat);
return ret;
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_parseQueries_4865 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.parseQueries.overload('android.net.Uri', 'java.util.Map');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_parseQueries_4865.implementation = function(v0, v1) {
var executor = 'Class';
var beatText = 'public static void com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.parseQueries(android.net.Uri,java.util.Map) throws java.io.IOException';
var beat = newMethodBeat(beatText, executor);
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_parseQueries_4865.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0, v1);
printBeat(beat);
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryAddQuery_7937 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.tryAddQuery.overload('java.util.Map', 'java.util.List', 'java.lang.String');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryAddQuery_7937.implementation = function(v0, v1, v2) {
var executor = 'Class';
var beatText = 'public static boolean com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.tryAddQuery(java.util.Map,java.util.List,java.lang.String) throws java.io.UnsupportedEncodingException';
var beat = newMethodBeat(beatText, executor);
var ret = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_tryAddQuery_7937.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0, v1, v2);
printBeat(beat);
return ret;
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_encode_4323 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.encode.overload('java.lang.String', 'java.lang.String');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_encode_4323.implementation = function(v0, v1) {
var executor = 'Class';
var beatText = 'public static java.lang.String com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.encode(java.lang.String,java.lang.String)';
var beat = newMethodBeat(beatText, executor);
var ret = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_encode_4323.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0, v1);
printBeat(beat);
return ret;
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_createUri_3204 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.createUri.overload('java.lang.String', 'java.lang.String', 'int', 'java.lang.String', 'java.lang.String', 'java.lang.String');
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_createUri_3204.implementation = function(v0, v1, v2, v3, v4, v5) {
var executor = 'Class';
var beatText = 'public static android.net.Uri com.bytedance.frameworks.core.encrypt.RequestEncryptUtils.createUri(java.lang.String,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String)';
var beat = newMethodBeat(beatText, executor);
var ret = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_method_createUri_3204.call(com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz, v0, v1, v2, v3, v4, v5);
printBeat(beat);
return ret;
};
var com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_init_7112 = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz.$init.overload();
com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_init_7112.implementation = function() {
var executor = this.hashCode();
var beatText = 'public com.bytedance.frameworks.core.encrypt.RequestEncryptUtils()';
var beat = newMethodBeat(beatText, executor);
var returnObj = com_bytedance_frameworks_core_encrypt_RequestEncryptUtils_clz_init_7112.call(this);
printBeat(beat);
return returnObj;
};
});