payload

package
v0.0.0-...-6656868 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package payload provides SQL injection payload construction with context-aware boundary detection and encoding utilities.

Index

Constants

View Source
const (
	TypeString  = 0
	TypeInteger = 1
	TypeFloat   = 2
)

Parameter type constants matching engine.ParameterType values.

Variables

This section is empty.

Functions

func PrefixesForType

func PrefixesForType(paramType int) []string

PrefixesForType returns likely prefixes based on parameter type. TypeInteger (1): "", ")", "))" TypeString (0) or TypeFloat (2): "'", "\"", "')", "\")", "'))"

func SuffixesForDBMS

func SuffixesForDBMS(dbms string) []string

SuffixesForDBMS returns likely suffixes for a given DBMS. MySQL: "-- -", "#", "/*" PostgreSQL: "-- -", "/*" Generic: "-- -", "#", "/*", "%00"

Types

type Base64Encoder

type Base64Encoder struct{}

Base64Encoder encodes to standard base64.

func (*Base64Encoder) Encode

func (e *Base64Encoder) Encode(s string) string

Encode applies standard base64 encoding.

func (*Base64Encoder) Name

func (e *Base64Encoder) Name() string

Name returns the encoder name.

type Boundary

type Boundary struct {
	Prefix  string
	Suffix  string
	Comment string // Optional description
}

Boundary represents a prefix/suffix pair for closing SQL context.

func CommonBoundaries

func CommonBoundaries() []Boundary

CommonBoundaries returns all common prefix/suffix pairs to try. These are ordered by likelihood/simplicity.

type Builder

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

Builder constructs payloads with context-aware boundaries.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new payload builder.

func (*Builder) Build

func (b *Builder) Build() *Payload

Build produces the final Payload.

func (*Builder) WithCore

func (b *Builder) WithCore(core string) *Builder

WithCore sets the core payload expression.

func (*Builder) WithDBMS

func (b *Builder) WithDBMS(dbms string) *Builder

WithDBMS sets the target DBMS.

func (*Builder) WithEncoder

func (b *Builder) WithEncoder(enc Encoder) *Builder

WithEncoder adds an encoder to the chain.

func (*Builder) WithPrefix

func (b *Builder) WithPrefix(prefix string) *Builder

WithPrefix sets the injection prefix.

func (*Builder) WithSuffix

func (b *Builder) WithSuffix(suffix string) *Builder

WithSuffix sets the injection suffix.

func (*Builder) WithTechnique

func (b *Builder) WithTechnique(technique string) *Builder

WithTechnique sets the technique name.

type ChainEncoder

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

ChainEncoder applies multiple encoders in sequence.

func NewChainEncoder

func NewChainEncoder(encoders ...Encoder) *ChainEncoder

NewChainEncoder creates a ChainEncoder with the given encoders.

func (*ChainEncoder) Encode

func (e *ChainEncoder) Encode(s string) string

Encode applies each encoder in order.

func (*ChainEncoder) Name

func (e *ChainEncoder) Name() string

Name returns the encoder name.

type DoubleURLEncoder

type DoubleURLEncoder struct{}

DoubleURLEncoder performs double URL encoding.

func (*DoubleURLEncoder) Encode

func (e *DoubleURLEncoder) Encode(s string) string

Encode applies URL percent-encoding twice: first encode, then encode the result again.

func (*DoubleURLEncoder) Name

func (e *DoubleURLEncoder) Name() string

Name returns the encoder name.

type Encoder

type Encoder interface {
	Name() string
	Encode(s string) string
}

Encoder transforms a payload string.

type HexEncoder

type HexEncoder struct{}

HexEncoder converts each byte to its hex representation (0xHH).

func (*HexEncoder) Encode

func (e *HexEncoder) Encode(s string) string

Encode converts each byte of the input to 0xHH format.

func (*HexEncoder) Name

func (e *HexEncoder) Name() string

Name returns the encoder name.

type Payload

type Payload struct {
	Prefix    string // Boundary prefix to close original query context (e.g., "'" or ")")
	Core      string // The actual injection logic (e.g., "AND 1=1")
	Suffix    string // Boundary suffix (e.g., "-- -" or "#")
	Encoded   string // Final form after encoding
	Technique string // Which technique generated this (e.g., "error-based")
	DBMS      string // Target DBMS (e.g., "MySQL")
}

Payload represents a complete injection payload.

func (*Payload) String

func (p *Payload) String() string

String returns the full payload string (Prefix + Core + Suffix).

type URLEncoder

type URLEncoder struct{}

URLEncoder performs URL encoding.

func (*URLEncoder) Encode

func (e *URLEncoder) Encode(s string) string

Encode applies URL percent-encoding to the input string. All non-unreserved characters (per RFC 3986) are percent-encoded. Spaces are encoded as %20 (not +) which is standard for payload encoding.

func (*URLEncoder) Name

func (e *URLEncoder) Name() string

Name returns the encoder name.

type UnicodeEncoder

type UnicodeEncoder struct{}

UnicodeEncoder converts each byte to unicode escape format (%u00XX).

func (*UnicodeEncoder) Encode

func (e *UnicodeEncoder) Encode(s string) string

Encode converts each byte of the input to %u00XX format.

func (*UnicodeEncoder) Name

func (e *UnicodeEncoder) Name() string

Name returns the encoder name.

Jump to

Keyboard shortcuts

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