-
Notifications
You must be signed in to change notification settings - Fork 18
/
script.js
353 lines (314 loc) · 15 KB
/
script.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
String.prototype.format = function () {
var values = arguments;
return this.replace(/\{(\d+)\}/g, function (match, index) {
if (values.length > index) {
return values[index];
} else {
return "";
}
});
}
// Java.perform(function() {
// var CoolMarket = Java.use('com.coolapk.market.CoolMarketApplication');
// CoolMarket.onLog.implementation = function() {
// var deviceId = Java.use('com.coolapk.market.util.SystemUtils').getDeviceId(this);
// var app_token = Java.use('com.coolapk.market.util.AuthUtils').getAS(this, deviceId);
// console.log('+++++> [onLog] 方法hook');
// console.log('+Device Id: ', deviceId);
// console.log('+App Token: ', app_token);
// console.log('++++++++++');
// console.log('\n')
// return true;
// }
// })
var JNI_LOAD_POINTER = Module.getExportByName('libnative-lib.so', 'JNI_OnLoad');
var BASE_ADDR = parseInt(JNI_LOAD_POINTER) - parseInt('0x31A04');
//***********************************[Native Hook]***********************************
//j_getAuthString : 0x2E938
//MD5::update : 0x329AC
//MD5::finalize : 0x321C4
//getAuthString : 0x66500
//j__Z10b64_decodePKcj(b64_decode) : 0x2E80C
//b64_decode_ex : 0x31F28
//std::__ndk1::basic_string : 0x319D8
//_android_log_print : 0x2E83C
//std::__ndk1::basic_string::__init : 0x31A8C
// // append 0x31d08
// Java.perform(function() {
// var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x32168')).toString(16) // 获取要hook方法的地址
// var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
// console.log('[append] hook pointer: ', pointer)
// var arg0, arg1, arg2, arg3
// Interceptor.attach(pointer, {
// onEnter: function(args) {
// arg0 = args[0]
// arg1 = args[1]
// arg2 = args[2]
// arg3 = args[3]
// console.log('\n')
// // console.log('-----> {0}[MD5::MD5] 方法hook'.format(pointer))
// console.log('=====> [append] -> [方法调用前]')
// console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
// console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
// console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
// console.log('参数4: {0} => {1}'.format(arg3, Memory.readCString(arg3)))
// console.log('\n')
// },
// onLeave: function(retval) {
// console.log('\n')
// console.log('=====> [append] -> [方法调用后]:')
// console.log('返回值: ', retval)
// console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
// console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
// console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
// console.log('参数4: {0} => {1}'.format(arg3, Memory.readCString(arg3)))
// console.log('\n')
// }
// }
// )
// })
// MD5::hexdigest 0x32a2c
// Java.perform(function() {
// var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x32a2c')).toString(16) // 获取要hook方法的地址
// var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
// console.log('[MD5::hexdigest] hook pointer: ', pointer)
// var arg0, arg1, arg2, arg3
// Interceptor.attach(pointer, {
// onEnter: function(args) {
// arg0 = args[0]
// arg1 = args[1]
// console.log('\n')
// console.log('=====> [MD5::hexdigest] -> [方法调用前]')
// console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
// console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
// console.log('\n')
// },
// onLeave: function(retval) {
// console.log('\n')
// console.log('=====> [MD5::hexdigest] -> [方法调用后]:')
// console.log('返回值: ', retval)
// console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
// console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
// var a = (arg1 >> 1).toString(16)
// console.log(a)
// console.log('参数2右移: {0} => {1}'.format(a, Memory.readCString(a)))
// console.log('\n')
// }
// }
// )
// })
// MD5::MD5
Java.perform(function() {
var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x32168')).toString(16) // 获取要hook方法的地址
var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
console.log('[MD5::MD5] hook pointer: ', pointer)
var arg0, arg1, arg2, arg3
Interceptor.attach(pointer, {
onEnter: function(args) {
arg0 = args[0]
arg1 = args[1]
// console.log('-----> {0}[MD5::MD5] 方法hook'.format(pointer))
console.log('\n')
console.log('=====> [MD5::MD5] -> [方法调用前]')
// console.log('参数1: ', args[0])
// console.log('参数2: ', args[1])
// console.log('参数2: ', Memory.readCString(args[1]))
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('\n')
},
onLeave: function(retval) {
console.log('\n')
console.log('=====> [MD5::MD5] -> [方法调用后]:')
console.log('返回值: ', retval)
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('\n')
}
}
)
})
// MD5::update
Java.perform(function() {
var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x329AC')).toString(16) // 获取要hook方法的地址
var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
console.log('[MD5::update] hook pointer: ', pointer)
var arg0, arg1, arg2, arg3
Interceptor.attach(pointer, {
onEnter: function(args) {
arg0 = args[0]
arg1 = args[1]
arg2 = args[2]
// console.log('-----> {0}[MD5::update] 方法hook'.format(pointer))
console.log('\n')
console.log('=====> [MD5::update] -> [方法调用前]')
// console.log('参数1: ', args[0])
// console.log('参数2: ', args[1])
// console.log('参数2: ', Memory.readCString(args[1]))
// console.log('参数3: ', args[2])
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('\n')
},
onLeave: function(retval) {
console.log('\n')
console.log('=====> [MD5::update] -> [方法调用后]:')
console.log('返回值: ', retval)
// console.log('参数1: ', args[0])
// console.log('参数2: ', args[1])
// console.log('参数3: ', args[2])
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('\n')
}
}
)
})
// MD5::finalize
Java.perform(function() {
var hookpointer = '0x' + parseInt(BASE_ADDR + parseInt('0x321C4')).toString(16) // 获取要hook方法的地址
var pointer = new NativePointer(hookpointer) // 根据方法地址构建NativePointer
console.log('[MD5::finalize] hook pointer: ', pointer)
var arg0, arg1, arg2, arg3
Interceptor.attach(pointer, {
onEnter: function(args) {
arg0 = args[0]
arg1 = args[1]
arg2 = args[2]
arg3 = args[3]
// console.log('-----> {0}[MD5::finalize] 方法hook'.format(pointer))
console.log('\n')
console.log('=====> [MD5::finalize] -> [方法调用前]')
// console.log('参数1: ', args[0])
// console.log('参数2: ', args[1])
// console.log('参数3: ', args[2])
// console.log('参数4: ', args[3])
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('参数4: {0} => {1}'.format(arg3, Memory.readCString(arg3)))
console.log('\n')
},
onLeave: function(retval) {
console.log('\n')
console.log('=====> [MD5::finalize] -> [方法调用后]:')
console.log('返回值: ', retval)
// console.log('参数1: ', args[0])
// console.log('参数2: ', args[1])
// console.log('参数3: ', args[2])
// console.log('参数4: ', args[3])
console.log('参数1: {0} => {1}'.format(arg0, Memory.readCString(arg0)))
console.log('参数2: {0} => {1}'.format(arg1, Memory.readCString(arg1)))
console.log('参数3: {0} => {1}'.format(arg2, Memory.readCString(arg2)))
console.log('参数4: {0} => {1}'.format(arg3, Memory.readCString(arg3)))
console.log('\n')
}
}
)
})
// // b64_encode
// Java.perform(function() {
// var hook_pointer = '0x' + parseInt(BASE_ADDR + parseInt('0x31DB8')).toString(16);
// var pointer = new NativePointer(hook_pointer);
// // console.log('Hook Method Pointer: ', pointer);
// var b64_encode = new NativeFunction(pointer, 'pointer', ['uchar', 'uint']);
// Interceptor.attach(pointer, {
// onEnter: function(args) {
// console.log('====> [b64_encode] 方法hook');
// console.log('=[onEnter]')
// console.log('=', Memory.readCString(args[0]));
// console.log('=', args[1].toInt32());
// console.log('=');
// },
// onLeave: function(retval) {
// console.log('=[onLeave]')
// console.log('=', Memory.readCString(retval));
// console.log('============')
// console.log('\n')
// }
// });
// })
// // MD5::hexdigest
// Java.perform(function() {
// var hook_pointer = '0x' + parseInt(BASE_ADDR + parseInt('0x32a2c')).toString(16)
// var pointer = new NativePointer(hook_pointer)
// var arg0
// Interceptor.attach(pointer, {
// onEnter: function(args) {
// console.log('*****> [MD5::hexdigest] 方法hook')
// console.log('*[onEnter]')
// arg0 = args[0]
// console.log('*arg2: ', Memory.readCString(args[1]))
// },
// onLeave: function(retval) {
// console.log('*')
// console.log('*[onLeave]')
// console.log('*arg1: ', arg0)
// console.log('*arg1: ', Memory.readCString(arg0))
// console.log('\n')
// }
// })
// })
// b64_decode
// Java.perform(function() {
// var load_pointer = Module.getExportByName('libnative-lib.so', 'JNI_OnLoad')//
// var hookpointer = '0x' + parseInt(parseInt(load_pointer) - parseInt('0x31A04') + parseInt('0x31F28')).toString(16)
// var pointer = new NativePointer(hookpointer)
// var arg0, arg1, arg2, arg3
// Interceptor.attach(pointer, {
// onEnter: function(args) {
// console.log(';;;;;;;;;;;;;;;;;;;;;;;;;;;;; [b64_decode_ex] method pointer: ', hookpointer)
// console.log('===== [{0} onEnter] ====='.format(pointer))
// arg0 = args[0]
// arg1 = args[1]
// arg2 = 0//args[2]
// arg3 = 0//args[3]
// console.log('[Params]:')
// console.log('\t[param] : ({0}, {1}, {2}, {3})'
// .format(Memory.readCString(arg0), arg1, arg2, arg3))
// console.log('\n')
// },
// onLeave: function(retval) {
// console.log('===== [{0} onLeave] ====='.format(pointer))
// console.log('[Retval]:')
// console.log('\t[retval] : ', retval)
// console.log('\n--------------------------------------------------')
// }
// }
// )
// })
//MD5::finalize
// Java.perform(function() {
// // var pointer = Module.getExportByName('libnative-lib.so', 'finalize')
// var pointer = new NativePointer(0xC41F41C5)
// console.log('native pointer: ', pointer)
// Interceptor.attach(pointer,
// {
// onEnter: function(args) {
// console.log('===== [{0} onEnter] ====='.format(pointer))
// console.log('[Context information]:');
// console.log('\t[Context] : ' + JSON.stringify(this.context));
// console.log('\t[Return] : ' + this.returnAddress);
// console.log('\t[ThreadId] : ' + this.threadId);
// console.log('\t[Depth] : ' + this.depth);
// console.log('\t[Errornr] : ' + this.err);
// console.log('[Params]:')
// console.log('\t[param] : ({0}, {1}, {2}, {3})'
// .format(args[0], args[1], args[2], args[3]))
// console.log('\t[param toint32] : ({0}, {1}, {2}, {3})'
// .format(args[0].toInt32(), args[1].toInt32(),
// args[2].toInt32(), args[3].toInt32()))
// console.log('\n')
// },
// onLeave: function(retval) {
// console.log('===== [{0} onLeave] ====='.format(pointer))
// console.log('[Retval]:')
// console.log('\t[retval] : ', retval)
// console.log('\t[retval toInt32] : ', retval.toInt32())
// console.log('\n--------------------------------------------------')
// }
// }
// )
// })