forked from dummyvx/decodeObfuscator
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcocomanhua.js
87 lines (75 loc) · 2.55 KB
/
cocomanhua.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
//自动解析cocomanhuan加密密钥
//必须先解密
globalThis.cocomanhua = () => {
let map = new Map();
let keyNames = Array.of("C_DATA", "enc_code1", "enc_code2");
//window.devtools.jsd(key, ...(window.C_DATA))
const extratKeys = {
CallExpression(path) {
const { callee, arguments } = path.node;
if (t.isMemberExpression(callee) && arguments.length === 2) {
let { object, property } = callee;
if (!t.isMemberExpression(object)) return
if ( //object.object.name === "window" &&
object.property.name === "devtools" && property.name === "jsd") {
let[key, tar] = arguments;
if (!t.isMemberExpression(tar.callee)) return;
let key_name = tar.callee.object.arguments[0].property.name;
if (!keyNames.includes(key_name)) return;
let _set = map.get(key_name) || new Set();
console.info(path.toString());
console.log(`=== find aes key of ${key_name} ===`);
let decodeKey = getBindingValue(key, path);
if (!!decodeKey) {
_set.add(decodeKey);
map.set(key_name, _set)
}
}
}
}
}
// ....(我是密钥, ...C_DATA...)
const extratKeys2 = {
CallExpression(path) {
const { arguments } = path.node;
if (arguments.length === 2) {
let[key, tar] = arguments;
let code = generator(tar).code;
let key_name = keyNames.find(name => code.includes(name));
if (key_name) {
let _set = map.get(key_name) || new Set();
console.info(path.toString())
let decodeKey = getBindingValue(key, path);
if (!!decodeKey) {
_set.add(decodeKey);
map.set(key_name, _set)
}
}
}
}
}
console.info('extra cocomanahua keys...\n');
let visitors = Array.of(extratKeys, extratKeys2);
for (let visitor of visitors) {
traverse(ast, visitor);
if (Array.from(map.keys()).sort().toString() != keyNames.sort().toString()) {
console.warn(`keys of keysMap not equal to[${keyNames}], switch to another visitor`)
} else {
break
}
}
for (let[key, value] of map) {
map.set(key, Array.from(value))
}
let keys = JSON.stringify(Object.fromEntries(map));
if (typeof require == "function") {
let keysFile = "./coco_keys.json";
const fs = require('fs');
fs.writeFile(keysFile, keys, () => {});
console.info(`coco漫画密钥文件: ${keysFile}`);
} else {
globalThis.keys = keys;
console.info("密钥保存到keys变量")
}
console.log(keys);
}