Narco Posted March 28 Posted March 28 nodes-crypter | npm package | C++ Javascript Crypter Today you will learn how to take a C/C++ program, encrypt it with XOR and then execute it, all using Javascript with this easy-to-use npm package. Take your static or dynamic compiled program and protect its runtime by utilizing a tmp file and run it in a child process, all from a JS file! You heard that right - your program's encrypted binary will be stored inside of a final script "run.js", which you can then run with "node run.js" to inject the embedded C/C++ program and run it as normal. Code npm install -g nodes-crypter Tested on Linux & Windows run command: nodes-crypter ./original-cpp-program secretKeyPhraseHere nodes-crypter will generate a file: run.js run command: node run.js your original C++ program will be decrypted (inside of run.js) and run as a program https://www.npmjs.com/package/nodes-crypter/v/1.0.6 This is an example of how you can use JS in unique ways due to npm & node. This method of encrypting and then decrypting, pushing to a tmp file & running as a child process is a proof of concept. You are free to learn from it, use it for personal use, and enhance the codebase - within limits of its license & npm TOS. The main file is node-crypter's only bin script, which encrypts your original program using XOR. Code const xorEncrypt = (input, key) => { const keyBuffer = Buffer.from(key); const output = Buffer.alloc(input.length); for (let i = 0; i < input.length; i++) { output = input ^ keyBuffer[i % keyBuffer.length]; } return output; }; Similarly, the final run.js file has a decrypt function: Code const xorDecrypt = (input, key) => { const keyBuffer = Buffer.from(key); const output = Buffer.alloc(input.length); for (let i = 0; i < input.length; i++) { output = input ^ keyBuffer[i % keyBuffer.length]; } return output; }; The run.js file will decrypt the program (encrypted binary held inside of run.js) & push it to a tmp file: Code const tempPath = path.join('/tmp', 'decrypted_program'); fs.writeFileSync(tempPath, decryptedData); fs.chmodSync(tempPath, '755'); Then, it runs the tmp file using the exec() function. This is a basic method, mostly meant to highlight the capabilities of using an npm package to handle the "build process", and using node to handle the runtime. You can always use other runtime methods instead, and add other build steps too. I hope you enjoyed this & if you learned anything, please say a thank you below. If you have any questions or suggestions, feel free to reply!! ******************************************************************************************************* Grundsätzlich gilt: Virusscan und VM ist euer Freund. Da die meisten geuppten Tools Stealer, Rats, Bots etc. sind wird fast jedes AV eine Warnmeldung abgebeben. Das ist bei diesen Programmen normal, macht die Sache aber für Anfänger nicht besser! Darum immer eine VM (https://www.heise.de/download/product/virtualbox-40385) nutzen. Btw: Die Tools sind nicht von mir! Wie sagt man so schön: Das ist alles nur geklaut und gestohlen, nur gezogen und geraubt. Entschuldigung, das hab ich mir erlaubt. 1 Quote
Recommended Posts