injection

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package injection models injection points (parameters, body fields, headers, cookies, path segments and explicit `*` markers) and renders per-test requests from a base request.

Index

Constants

View Source
const (
	TypeGET    = "GET"
	TypePOST   = "POST"
	TypeJSON   = "JSON"
	TypeXML    = "XML"
	TypeHeader = "HEADER"
	TypeCookie = "COOKIE"
	TypePath   = "PATH"
	TypeMarker = "MARKER"
)

Point types.

View Source
const Marker = "*"

Marker is the character a user embeds in a URL, header or body to force an injection position.

Variables

View Source
var (
	// ErrMalformedRawRequest indicates a Burp-style request file could not be
	// parsed.
	ErrMalformedRawRequest = errors.New("malformed raw request")
	// ErrUnsupportedMethod indicates the request line used a method the
	// engine will not replay.
	ErrUnsupportedMethod = errors.New("unsupported HTTP method in raw request")
)
View Source
var ErrNoInjectionPoints = errors.New("no injectable parameters or markers found")

ErrNoInjectionPoints is returned when nothing can receive a payload.

Functions

This section is empty.

Types

type Header struct {
	Key   string
	Value string
}

Header is a single HTTP header in encounter order.

type InjectionPoint

type InjectionPoint struct {
	Type     string
	Name     string
	Value    string
	Location string
	// contains filtered or unexported fields
}

InjectionPoint is one location that can receive a payload, with closures to materialise an injected request and the clean baseline request.

func Enumerate

func Enumerate(rs RequestSource, opts Options) ([]*InjectionPoint, error)

Enumerate finds every injectable position in the request and returns the points in deterministic order. Markers take precedence: when any `*` is present, only marker points are produced.

func (*InjectionPoint) Render

func (p *InjectionPoint) Render(value string) *RenderedRequest

Render returns the request with value injected at this point.

func (*InjectionPoint) RenderBase

func (p *InjectionPoint) RenderBase() *RenderedRequest

RenderBase returns the clean request with all markers emptied and no injection applied.

type Options

type Options struct {
	Level         int
	TestParameter string
	SkipParameter []string
}

Options controls how injection points are enumerated and filtered.

type RawRequest

type RawRequest struct {
	Method  string
	Target  string
	Version string
	Headers []Header
	Body    []byte
}

RawRequest is the parsed form of a Burp-style request file.

func ParseRaw

func ParseRaw(data []byte, tls bool) (*RawRequest, error)

ParseRaw parses a Burp-style raw HTTP request. Line endings are handled for both \r\n and bare \n. Errors carry the offending line number.

func (*RawRequest) AbsoluteURL

func (r *RawRequest) AbsoluteURL(tls bool) string

AbsoluteURL reconstructs a full URL (scheme derived from tls, host from the Host header, target as typed). It returns "" when host parsing fails.

func (*RawRequest) Host

func (r *RawRequest) Host() string

Host extracts the Host header value, if present.

type RenderedRequest

type RenderedRequest struct {
	Method  string
	URL     string
	Headers map[string]string
	Body    []byte
}

RenderedRequest is a fully materialised request ready to be sent.

type RequestSource

type RequestSource struct {
	Method  string
	URL     string
	Headers []Header
	Body    []byte
}

RequestSource describes the request that will be scanned for points.

type Template

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

Template is a string with zero or more * markers. Render keeps one marker populated and empties the rest, so each marker is exercised independently while the document stays syntactically valid.

func NewTemplate

func NewTemplate(raw string) *Template

NewTemplate splits raw on the marker character, preserving empties so that round-tripping reconstructs the original exactly.

func (*Template) HasMarkers

func (t *Template) HasMarkers() bool

HasMarkers reports whether the template contains at least one marker.

func (*Template) Render

func (t *Template) Render(idx int, value string) string

Render returns the template with the marker at idx replaced by value and every other marker emptied.

func (*Template) RenderAllEmpty

func (t *Template) RenderAllEmpty() string

RenderAllEmpty returns the template with every marker emptied. This is used for the clean (baseline) request when markers are present.

Jump to

Keyboard shortcuts

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