SgnSharp 0.2.0

dotnet add package SgnSharp --version 0.2.0
                    
NuGet\Install-Package SgnSharp -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SgnSharp" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SgnSharp" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SgnSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SgnSharp --version 0.2.0
                    
#r "nuget: SgnSharp, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SgnSharp@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SgnSharp&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SgnSharp&version=0.2.0
                    
Install as a Cake Tool

SgnSharp

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

Supported Native Runtimes

The packaged Keystone native runtime currently supports these host runtimes:

  • win-x64
  • linux-x64
  • linux-musl-x64

linux-arm64, win-x86, and macOS are not bundled in this pass.

Building Native Assets And Packages

Build the native Keystone runtime into the shared staging layout:

pwsh ./eng/build-keystone.ps1 -RuntimeIdentifier win-x64
sh ./eng/build-keystone.sh linux-x64
sh ./eng/build-keystone.sh linux-musl-x64

Once all staged runtime assets exist under artifacts/native/runtimes, pack both NuGet artifacts:

pwsh ./eng/pack.ps1
pwsh ./eng/validate-packages.ps1
sh ./eng/pack.sh
sh ./eng/validate-packages.sh

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 library and CLI both load Keystone from bundled runtime assets under runtimes/<rid>/native.
  • Package builds expect staged native assets for all supported runtimes before dotnet pack runs.
  • Third-party notice and upstream license links are tracked in THIRD-PARTY-NOTICES.md.

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.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 171 4/14/2026
0.1.0 196 12/27/2025