forked from echo094/decode-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
44 lines (40 loc) · 1.12 KB
/
main.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
import fs from 'fs'
import PluginSojson from './plugin/sojson.js'
import PluginSojsonV7 from './plugin/sojsonv7.js'
import PluginObfuscator from './plugin/obfuscator.js'
import PluginAwsc from './plugin/awsc.js'
// 读取参数
let type = 'obfuscator'
let encodeFile = 'input.js'
let decodeFile = 'output.js'
for (let i = 2; i < process.argv.length; i += 2) {
if (process.argv[i] === '-t') {
type = process.argv[i + 1]
}
if (process.argv[i] === '-i') {
encodeFile = process.argv[i + 1]
}
if (process.argv[i] === '-o') {
decodeFile = process.argv[i + 1]
}
}
console.log(`类型: ${type}`)
console.log(`输入: ${encodeFile}`)
console.log(`输出: ${decodeFile}`)
// 读取源代码
const sourceCode = fs.readFileSync(encodeFile, { encoding: 'utf-8' })
// 净化源代码
let code
if (type === 'sojson') {
code = PluginSojson(sourceCode)
} else if (type === 'sojsonv7') {
code = PluginSojsonV7(sourceCode)
} else if (type === 'obfuscator') {
code = PluginObfuscator(sourceCode)
} else if (type === 'awsc') {
code = PluginAwsc(sourceCode)
}
// 输出代码
if (code) {
fs.writeFile(decodeFile, code, () => {})
}