forked from 19Vin70/premoza-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
obfuscate.cjs
63 lines (61 loc) · 2.9 KB
/
obfuscate.cjs
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
const js = require("javascript-obfuscator");
const fs = require("fs");
main("public/build/assets/");
function main(location) {
fs.readdir(location, function (err, files) {
if (err) return console.error(err);
for (let i = 0; i < files.length; i++) {
if (!files[i].startsWith('bootstrap')) {
const file = location + "/" + files[i];
fs.stat(file, async (err, stats) => {
if (err) {
console.error(err);
return;
}
if (stats.isFile()) {
const fileContent = fs.readFileSync(file, "utf8");
if (files[i].endsWith(".js")) {
console.log("[Encrypting] " + files[i]);
let result = js.obfuscate(fileContent, {
compact: true,
controlFlowFlattening: true,
debugProtection: true,
debugProtectionInterval: 2500,
disableConsoleOutput: true,
identifierNamesGenerator: 'mangled',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayShuffle: true,
stringArrayCallsTransform: true,
stringArrayCallsTransformThreshold: 0.5,
stringArrayEncoding: ['rc4'],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
});
fs.writeFileSync(file, result.getObfuscatedCode(), "utf8");
}
} else if (stats.isDirectory()) {
console.log("[Folder] " + file);
findHtmlCssFiles(file);
} else {
console.log("[Unknown] " + file);
}
});
} else {
console.log("[Ignore Files] " + files[i]);
}
}
});
}