Files
EgeBalci-sgn/examples/encode_x64_binary.go
Drew Bonasera ecc578b28c Apply encoder options within the main loop and fix various bugs related to encoding, obfuscation, and file handling.
- feat(cli): Apply obfuscation, encoding, and safe options in main loop
- feat(obfuscation): Allow disabling garbage instruction generation via obfuscation limit
- fix(encoder): Correct schema size calculation for x64 architecture
- fix(encoder): Pad encoded payload with NOPs to ensure schema alignment
- fix(obfuscation): Add fallback for random register selection in garbage generation
- fix(cli): Truncate output file on write and ensure it is closed
- fix(examples): Correct casing in sgn package import path
- style(encoder): Remove trailing whitespace from register save definitions
2026-04-30 05:10:02 -04:00

34 lines
550 B
Go

package main
import (
"encoding/hex"
"fmt"
"os"
sgn "github.com/EgeBalci/sgn/pkg"
)
func main() {
// First open some file
file, err := os.ReadFile("myfile.bin")
if err != nil { // check error
fmt.Println(err)
return
}
// Create a new SGN encoder
encoder, err := sgn.NewEncoder(64)
if err != nil {
fmt.Println(err)
return
}
// Encode the binary
encodedBinary, err := encoder.Encode(file)
if err != nil {
fmt.Println(err)
return
}
// Print out the hex dump of the encoded binary
fmt.Println(hex.Dump(encodedBinary))
}