SgnSharp.Cli 0.1.0

dotnet tool install --global SgnSharp.Cli --version 0.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local SgnSharp.Cli --version 0.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=SgnSharp.Cli&version=0.1.0
                    
nuke :add-package SgnSharp.Cli --version 0.1.0
                    

SgnSharp

SgnSharp is a .NET port of EgeBalci's SGN encoder for x86/x64 payloads. It provides a library API and a console utility.

CLI Usage

Build and run from the repo root:

dotnet build
dotnet run --project SgnSharp.Cli -- -i path\to\payload.bin -a 64 -c 2 -M 50 -S -v

CLI Flags

-h, --help               Show help
-i, --input=STRING       Input binary path
-o, --out=STRING         Encoded output binary name
-a, --arch=64            Binary architecture (32/64)
-c, --enc=1              Number of times to encode the binary
-M, --max=50             Maximum number of bytes for decoder obfuscation
    --plain              Do not encode the decoder stub
    --ascii              Generate ASCII printable payload (not supported yet)
-S, --safe               Preserve all register values
    --badchars=STRING    Disallow specified bytes in hex form (not supported yet)
    --seed=BYTE          Hex seed value (e.g. 0x2a)
-v, --verbose            Verbose output
    --version            Show version

Notes

  • --ascii and --badchars are not implemented yet and will return an error.
  • The CLI uses Keystone for assembly; the build copies the x64 keystone.dll into the output folder. If you need x86, update SgnSharp.Cli/SgnSharp.Cli.csproj to copy installed\x86-windows\bin\keystone.dll instead.

Library Usage

using SgnSharp;
using SgnSharp.Types;

var payload = File.ReadAllBytes("myfile.bin");
var encoder = new Encoder(
    Arch.x64,
    obfuscationLimit: 50,
    plainDecoder: false,
    encodingCount: 1,
    saveRegisters: false
);

var result = encoder.Encode(payload);
if (result.IsFailure)
{
    Console.WriteLine(result.Error);
    return;
}

File.WriteAllBytes("myfile.bin.sgn", result.Value);
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.1.0 94 12/27/2025