ssce

package module
v0.0.0-...-f575421 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

README

SSCE

A simple shellcode encoder, build and erase decoder at runtime and erase shellcode after execution.

Usage

ssce -arch 64 -i shellcode.bin -o shellcode_x64.bin

Development

package main

import (
    "encoding/hex"
    "fmt"
    "os"

    "github.com/RSSU-Shellcode/SSCE"
)

func main() {
    encoder := ssce.NewEncoder(0)

    shellcode, err := os.ReadFile("shellcode.bin")
    checkError(err)

    opts := ssce.Options{
        NumIterator: 4,
        NumTailInst: 64,
        MinifyMode:  false,
        SaveContext: false,
        EraseInst:   false,
        NoIterator:  false,
        NoGarbage:   false,
    }

    shellcode, err = encoder.Encode(shellcode, 64, &opts)
    checkError(err)

    out := hex.EncodeToString(shellcode)
    fmt.Println(out)

    err = encoder.Close()
    checkError(err)
}

func checkError(err error) {
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InspectJunkCodeTemplate

func InspectJunkCodeTemplate(arch int, src string) (string, []byte, error)

InspectJunkCodeTemplate is used to test junk code template.

func InspectLoaderTemplate

func InspectLoaderTemplate(arch int, src string) (string, []byte, error)

InspectLoaderTemplate is used to test loader template.

func InspectMiniDecoderTemplate

func InspectMiniDecoderTemplate(arch int, src string) (string, []byte, error)

InspectMiniDecoderTemplate is used to test mini decoder template.

Types

type Context

type Context struct {
	Output      []byte `toml:"output"       json:"output"`
	Seed        int64  `toml:"seed"         json:"seed"`
	NumIterate  int    `toml:"num_iterate"  json:"num_iterate"`
	MinifyMode  bool   `toml:"minify_mode"  json:"minify_mode"`
	NoGarbage   bool   `toml:"no_garbage"   json:"no_garbage"`
	SaveContext bool   `toml:"save_context" json:"save_context"`
	EraseInst   bool   `toml:"erase_inst"   json:"erase_inst"`
}

Context contains the output and context data in Encode.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder is a simple shellcode encoder.

func NewEncoder

func NewEncoder() *Encoder

NewEncoder is used to create a simple shellcode encoder.

func (*Encoder) Close

func (e *Encoder) Close() error

Close is used to close shellcode encoder.

func (*Encoder) Encode

func (e *Encoder) Encode(shellcode []byte, arch int, opts *Options) (ctx *Context, err error)

Encode is used to encode input shellcode to a unique shellcode.

type Options

type Options struct {
	// the number of iterate.
	NumIterate int `toml:"num_iterate" json:"num_iterate"`

	// the size of the garbage instruction at tail.
	NumTailInst int `toml:"num_tail_inst" json:"num_tail_inst"`

	// only use the mini loader, not use loader
	// for erase shellcode and more feature.
	MinifyMode bool `toml:"minify_mode" json:"minify_mode"`

	// save and restore context after call shellcode.
	SaveContext bool `toml:"save_context" json:"save_context"`

	// erase loader instruction and shellcode after call it.
	EraseInst bool `toml:"erase_inst" json:"erase_inst"`

	// disable iterator, not recommend.
	NoIterator bool `toml:"no_iterator" json:"no_iterator"`

	// disable garbage instruction, not recommend.
	NoGarbage bool `toml:"no_garbage" json:"no_garbage"`

	// specify a random seed for encoder.
	RandSeed int64 `toml:"rand_seed" json:"rand_seed"`

	// trim the seed at the tail of output.
	TrimSeed bool `toml:"trim_seed" json:"trim_seed"`

	// specify the x86 mini decoder template.
	MiniDecoderX86 string `toml:"mini_decoder_x86" json:"mini_decoder_x86"`

	// specify the x64 mini decoder template.
	MiniDecoderX64 string `toml:"mini_decoder_x64" json:"mini_decoder_x64"`

	// specify the x86 loader template.
	LoaderX86 string `toml:"loader_x86" json:"loader_x86"`

	// specify the x64 loader template.
	LoaderX64 string `toml:"loader_x64" json:"loader_x64"`

	// specify the x86 junk code templates.
	JunkCodeX86 []string `toml:"junk_code_x86" json:"junk_code_x86"`

	// specify the x64 junk code templates.
	JunkCodeX64 []string `toml:"junk_code_x64" json:"junk_code_x64"`
}

Options contains options about encode shellcode.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL