-
Notifications
You must be signed in to change notification settings - Fork 20
/
nimlibChatAttachParser.js
69 lines (61 loc) · 2 KB
/
nimlibChatAttachParser.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
/**
适用对象:通用
作用:获取云信聊天附件信息
参考:
*/
// hook java.net.URL
function hookURL() {
var URL = Java.use('java.net.URL');
URL.$init.overload('java.lang.String').implementation = function (a) {
console.log('URL:' + a)
printStack();
this.$init(a)
}
}
function hookChatAttachParser() {
var clsName = 'com.android.common.nim.parser.ChatAttachParser';
var cls = Java.use(clsName);
cls.parse.overload('java.lang.String').implementation = function (s) {
var ret = this.parse(s);
console.log(clsName + '.parse(): \n\t' + s);
printStack();
return ret;
}
}
function hookIMMessageImpl() {
var clsName = "com.netease.nimlib.session.IMMessageImpl";
var cls = Java.use(clsName);
cls.setAttachStr.overload('java.lang.String').implementation = function (s) {
console.log(clsName + '.setAttachStr(): \n\t' + s);
printStack();
return this.setAttachStr(s);
};
cls.setAttachStrOnly.overload('java.lang.String').implementation = function (s) {
console.log(clsName + '.setAttachStrOnly(): \n\t' + s);
printStack();
return this.setAttachStrOnly(s);
};
cls.getContent.overload().implementation = function () {
var text = this.toStringSimple(this);
console.log(`${clsName}.getContent(): \n\tnick: ${this.getFromNick()} \n\ttext: ${text} \n\tAttachStr: ${this.getAttachStr()}`);
printStack();
return text;
};
}
// 打印堆栈
function printStack() {
console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Exception").$new()));
}
function byte2Base64(bytes) {
//let s = String.fromCharCode.apply(null, bytes); // 字节序列转字符串
var jBase64 = Java.use('android.util.Base64');
return jBase64.encodeToString(bytes, 2);
}
function hook() {
Java.perform(function () {
hookURL();
hookIMMessageImpl();
hookChatAttachParser();
});
}
setImmediate(hook());