encoders

package
v1.5.22 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: GPL-3.0 Imports: 13 Imported by: 3

README

Encoders

These are the implant-side encoders, almost all of the code is shared with server/encoders but there are a few small differences.

The unit tests for this package are in server/encoders (which imports this pkg).

Documentation

Index

Constants

View Source
const Base32EncoderID = 65

Base32EncoderID - EncoderID

View Source
const Base58EncoderID = 43

Base62EncoderID - EncoderID

View Source
const Base64EncoderID = 13

Base64EncoderID - EncoderID

View Source
const Base64GzipEncoderID = 64

Base64GzipEncoderID - EncoderID

View Source
const (
	// EncoderModulus - Nonce % EncoderModulus = EncoderID, and needs to be equal
	//                  to or greater than the largest EncoderID value.
	EncoderModulus = 101
)
View Source
const EnglishEncoderID = 31

EnglishEncoderID - EncoderID

View Source
const GzipEncoderID = 49

GzipEncoderID - EncoderID

View Source
const GzipEnglishEncoderID = 45

GzipEnglishEncoderID - EncoderID

View Source
const HexEncoderID = 92

HexEncoderID - EncoderID

View Source
const (

	// PNGEncoderID - Encoder ID
	PNGEncoderID = 22
)

Variables

View Source
var EncoderMap = map[int]Encoder{
	Base64EncoderID:      Base64{},
	HexEncoderID:         Hex{},
	EnglishEncoderID:     English{},
	GzipEncoderID:        Gzip{},
	GzipEnglishEncoderID: GzipEnglish{},
	Base64GzipEncoderID:  Base64Gzip{},
}

EncoderMap - Maps EncoderIDs to Encoders

Functions

func B58Decode added in v1.5.0

func B58Decode(b string) []byte

B58Decode decodes a modified base58 string to a byte slice.

func B58Encode added in v1.5.0

func B58Encode(b []byte) string

B58Encode encodes a byte slice to a modified base58 string.

func NopNonce

func NopNonce() int

NopNonce - A NOP nonce identifies a request with no encoder/payload

any value where mod = 0

Types

type Base32 added in v1.5.0

type Base32 struct{}

Base32 Encoder

func (Base32) Decode added in v1.5.0

func (e Base32) Decode(data []byte) ([]byte, error)

Decode - Base32 Decode

func (Base32) Encode added in v1.5.0

func (e Base32) Encode(data []byte) []byte

Encode - Base32 Encode

type Base58 added in v1.5.0

type Base58 struct{}

Base58 Encoder

func (Base58) Decode added in v1.5.0

func (e Base58) Decode(data []byte) ([]byte, error)

Decode - Base58 Decode

func (Base58) Encode added in v1.5.0

func (e Base58) Encode(data []byte) []byte

Encode - Base58 Encode

type Base64

type Base64 struct{}

Base64 Encoder

func (Base64) Decode

func (e Base64) Decode(data []byte) ([]byte, error)

Decode - Base64 Decode

func (Base64) Encode

func (e Base64) Encode(data []byte) []byte

Encode - Base64 Encode

type Base64Gzip

type Base64Gzip struct{}

Base64Gzip - Base64+Gzip encoder

func (Base64Gzip) Decode

func (g Base64Gzip) Decode(data []byte) ([]byte, error)

Decode - Un-base64 gzip data

func (Base64Gzip) Encode

func (g Base64Gzip) Encode(data []byte) []byte

Encode - Base64 encode gzip data

type Encoder

type Encoder interface {
	Encode([]byte) []byte
	Decode([]byte) ([]byte, error)
}

Encoder - Can losslessly encode arbitrary binary data to ASCII

func EncoderFromNonce

func EncoderFromNonce(nonce int) (int, Encoder, error)

EncoderFromNonce - Convert a nonce into an encoder

func RandomEncoder

func RandomEncoder() (int, Encoder)

RandomEncoder - Get a random nonce identifier and a matching encoder

func RandomTxtEncoder added in v1.5.0

func RandomTxtEncoder() (int, Encoder)

RandomTxtEncoder - Get a random nonce identifier and a matching encoder

type English

type English struct{}

English Encoder - An ASCIIEncoder for binary to english text

func (English) Decode

func (e English) Decode(words []byte) ([]byte, error)

Decode - English => Binary

func (English) Encode

func (e English) Encode(data []byte) []byte

Encode - Binary => English

type Gzip

type Gzip struct{}

Gzip - Gzip compression encoder

func (Gzip) Decode

func (g Gzip) Decode(data []byte) ([]byte, error)

Decode - Uncompressed data with gzip

func (Gzip) Encode

func (g Gzip) Encode(data []byte) []byte

Encode - Compress data with gzip

type GzipEnglish

type GzipEnglish struct{}

GzipEnglish - Gzip+English encoder

func (GzipEnglish) Decode

func (g GzipEnglish) Decode(data []byte) ([]byte, error)

Decode - Uncompressed english data with gzip

func (GzipEnglish) Encode

func (g GzipEnglish) Encode(data []byte) []byte

Encode - Compress english data with gzip

type Hex

type Hex struct{}

Hex Encoder

func (Hex) Decode

func (e Hex) Decode(data []byte) ([]byte, error)

Decode - Hex Decode

func (Hex) Encode

func (e Hex) Encode(data []byte) []byte

Encode - Hex Encode

type NoEncoder

type NoEncoder struct{}

NoEncoder - A NOP encoder

func (NoEncoder) Decode

func (n NoEncoder) Decode(data []byte) ([]byte, error)

Decode - Don't do anything

func (NoEncoder) Encode

func (n NoEncoder) Encode(data []byte) []byte

Encode - Don't do anything

type PNGEncoder

type PNGEncoder struct{}

PNGEncoder - PNG image object

func (PNGEncoder) Decode

func (p PNGEncoder) Decode(data []byte) ([]byte, error)

Decode reads a encoded PNG to get the original binary data

func (PNGEncoder) Encode

func (p PNGEncoder) Encode(data []byte) []byte

Encode outputs a valid PNG file

Jump to

Keyboard shortcuts

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