-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
131 lines (103 loc) · 3.76 KB
/
script.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
const bytenode = require('bytenode');
const v8 = require('v8');
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
const JavaScriptObfuscator = require('javascript-obfuscator');
v8.setFlagsFromString('--no-lazy');
v8.setFlagsFromString('--no-flush-bytecode');
function compileFile(file) {
if (fs.existsSync(file)) {
bytenode.compileFile(file);
console.log(`${file} compiled`);
fs.unlinkSync(file);
return;
}
}
function obfuscateDir(dirPath) {
var dirents = fs.readdirSync(dirPath, {
encoding: 'utf8',
withFileTypes: true,
});
for (let i = 0; i < dirents.length; i++) {
let dirent = dirents[i];
if (dirent.isDirectory()) {
obfuscateDir(path.join(dirPath, dirent.name));
continue;
}
if (path.extname(dirent.name) !== '.js') continue;
let filePath = path.join(dirPath, dirent.name);
if (!filePath.includes('static')) {
let content = fs.readFileSync(filePath, { encoding: 'utf8' });
let obfuscator = JavaScriptObfuscator.obfuscate(content, {
compact: true,
simplify: true,
controlFlowFlattening: false,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.1,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: true,
renameGlobals: false,
rotateStringArray: true,
selfDefending: false,
stringArray: true,
stringArrayEncoding: ['rc4', 'base64'],
target: 'node',
stringArrayThreshold: 0.75,
transformObjectKeys: false,
unicodeEscapeSequence: true,
splitStringsChunkLength: 5,
});
let obfuscatedCode = obfuscator.getObfuscatedCode();
fs.writeFileSync(filePath, obfuscatedCode, {
encoding: 'utf8',
flag: 'w+',
});
}
}
}
obfuscateDir(path.join(__dirname, './build'));
compileFile(path.join(__dirname, './build/preload.js'));
// fs.copyFileSync('./public/electron.js', './build/electron.js');
compileFile(path.join(__dirname, './build/electron.js'));
compileFile(path.join(__dirname, './build/Request.js'));
compileFile(path.join(__dirname, './build/tasks.js'));
compileFile(path.join(__dirname, './build/modules/amazon/amazon-regular.js'));
compileFile(path.join(__dirname, './build/modules/amazon/amazon-mobile.js'));
compileFile(path.join(__dirname, './build/modules/amazon/amazon-smile.js'));
compileFile(path.join(__dirname, './build/modules/amazon/amazon-login.js'));
compileFile(path.join(__dirname, './build/modules/amazon/amazon-monitor.js'));
compileFile(path.join(__dirname, './build/modules/bestbuy/bestbuy.js'));
compileFile(path.join(__dirname, './build/modules/panini/panini.js'));
compileFile(path.join(__dirname, './build/modules/shopify/shopify.js'));
compileFile(path.join(__dirname, './build/modules/target/target.js'));
compileFile(path.join(__dirname, './build/modules/notify.js'));
compileFile(path.join(__dirname, './build/modules/proxyPing.js'));
compileFile(path.join(__dirname, './build/modules/target-login.js'));
compileFile(path.join(__dirname, './build/asar.js'));
compileFile(path.join(__dirname, './build/Client/dist/index.js'));
try {
rimraf.sync(path.join(__dirname, './build/Client/golang'));
} catch (e) {}
try {
rimraf.sync(path.join(__dirname, './build/Client/src'));
} catch (e) {}
try {
fs.unlinkSync(path.join(__dirname, './build/Client/package.json'));
} catch (e) {}
try {
fs.unlinkSync(path.join(__dirname, './build/Client/tsconfig.json'));
} catch (e) {}
fs.writeFileSync(
path.join(__dirname, './build/electron.js'),
`
require('bytenode');
const v8 = require('v8');
v8.setFlagsFromString('--no-lazy');
require('./electron.jsc')
`
);
process.exit(0);