mirror of
https://github.com/smallfawn/decode_action.git
synced 2025-12-20 08:44:59 +08:00
Update main.js
This commit is contained in:
50
src/main.js
50
src/main.js
@@ -1,4 +1,4 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const PluginCommon = require('./plugin/common.js')
|
const PluginCommon = require('./plugin/common.js')
|
||||||
const PluginJjencode = require('./plugin/jjencode.js')
|
const PluginJjencode = require('./plugin/jjencode.js')
|
||||||
const PluginSojson = require('./plugin/sojson.js')
|
const PluginSojson = require('./plugin/sojson.js')
|
||||||
@@ -7,13 +7,10 @@ const PluginObfuscator = require('./plugin/obfuscator.js')
|
|||||||
const PluginAwsc = require('./plugin/awsc.js')
|
const PluginAwsc = require('./plugin/awsc.js')
|
||||||
|
|
||||||
// 读取参数
|
// 读取参数
|
||||||
let type = 'common'
|
let type = 'test'
|
||||||
let encodeFile = 'input.js'
|
let encodeFile = 'input.js'
|
||||||
let decodeFile = 'output.js'
|
let decodeFile = 'output.js'
|
||||||
for (let i = 2; i < process.argv.length; i += 2) {
|
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') {
|
if (process.argv[i] === '-i') {
|
||||||
encodeFile = process.argv[i + 1]
|
encodeFile = process.argv[i + 1]
|
||||||
}
|
}
|
||||||
@@ -28,20 +25,37 @@ console.log(`输出: ${decodeFile}`)
|
|||||||
// 读取源代码
|
// 读取源代码
|
||||||
const sourceCode = fs.readFileSync(encodeFile, { encoding: 'utf-8' })
|
const sourceCode = fs.readFileSync(encodeFile, { encoding: 'utf-8' })
|
||||||
|
|
||||||
// 净化源代码
|
|
||||||
let code
|
let processedCode = sourceCode;
|
||||||
if (type === 'sojson') {
|
let pluginUsed = '';
|
||||||
code = PluginSojson(sourceCode)
|
|
||||||
} else if (type === 'sojsonv7') {
|
// 循环尝试不同的插件,直到源代码与处理后的代码不一致
|
||||||
code = PluginSojsonV7(sourceCode)
|
const plugins = [
|
||||||
} else if (type === 'obfuscator') {
|
{ name: 'sojson', plugin: PluginSojson },
|
||||||
code = PluginObfuscator(sourceCode)
|
{ name: 'sojsonv7', plugin: PluginSojsonV7 },
|
||||||
} else if (type === 'awsc') {
|
{ name: 'obfuscator', plugin: PluginObfuscator },
|
||||||
code = PluginAwsc(sourceCode)
|
{ name: 'awsc', plugin: PluginAwsc },
|
||||||
} else if (type === 'jjencode') {
|
{ name: 'jjencode', plugin: PluginJjencode },
|
||||||
code = PluginJjencode(sourceCode)
|
{ name: 'common', plugin: PluginCommon } // 最后一次使用通用插件
|
||||||
|
];
|
||||||
|
|
||||||
|
for (let plugin of plugins) {
|
||||||
|
const code = plugin.plugin(sourceCode);
|
||||||
|
if (code !== processedCode) {
|
||||||
|
processedCode = code;
|
||||||
|
pluginUsed = plugin.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (processedCode !== sourceCode) {
|
||||||
|
// 输出代码
|
||||||
|
fs.writeFile(decodeFile, processedCode, (err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log(`使用插件 ${pluginUsed} 成功处理并写入文件 ${decodeFile}`);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
code = PluginCommon(sourceCode)
|
console.log(`所有插件处理后的代码与原代码一致,未写入文件。`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 输出代码
|
// 输出代码
|
||||||
|
|||||||
Reference in New Issue
Block a user