fuzz

package
v0.9.289 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const AnyWordRegex = `\w+`

AnyWordRegex constant

View Source
const BooleanPrefixRegex = PrefixTypeBoolean + `(false|true)`

BooleanPrefixRegex constant

View Source
const EmailRegex = `\w+@\w+\\.\w+`

EmailRegex constant

View Source
const EmailRegex2 = `\w+@\w+.?\w+`

EmailRegex2 constant

View Source
const EmailRegex3 = `.+@.+\..+`

EmailRegex3 constant

View Source
const EmailRegex4 = `.+@.+\\..+`

EmailRegex4 constant

View Source
const FixtureDataExt = ".dat"

FixtureDataExt extension

View Source
const IntPrefixRegex = PrefixTypeNumber + `[+-]?\d{1,10}`

IntPrefixRegex constant

View Source
const NumberPrefixRegex = PrefixTypeNumber + `[+-]?((\d{1,10}(\.\d{1,5})?)|(\.\d{1,10}))`

NumberPrefixRegex constant

View Source
const PrefixTypeArray = "__array__"

PrefixTypeArray type

View Source
const PrefixTypeBoolean = "__boolean__"

PrefixTypeBoolean type

View Source
const PrefixTypeExample = "__example__"

PrefixTypeExample type

View Source
const PrefixTypeNumber = "__number__"

PrefixTypeNumber type

View Source
const PrefixTypeObject = "__object__"

PrefixTypeObject type

View Source
const PrefixTypeString = "__string__"

PrefixTypeString type

View Source
const RequestCount = "_RequestCount"

RequestCount name

View Source
const UintPrefixRegex = PrefixTypeNumber + `\d{1,10}`

UintPrefixRegex constant

View Source
const UnescapeHTML = "UnescapeHTML"

UnescapeHTML flag

View Source
const WildRegex = `.+`

WildRegex constant

Variables

This section is empty.

Functions

func AllInjectionPayloads

func AllInjectionPayloads(seed ...int64) map[string]string

AllInjectionPayloads returns one random payload from each injection class. Useful for generating a diverse set of payloads in a single call.

func EnumInt

func EnumInt(anyArr ...any) (n int64)

EnumInt selects numeric

func EnumString

func EnumString(anyArr ...any) string

EnumString selects substring

func ExtractJSONPath

func ExtractJSONPath(path string, data any) any

ExtractJSONPath extracts a value at path from data. Supports: "user.id", "items[0].name", "$.user.id" (leading "$." is stripped).

func ExtractTopLevelJSONFields

func ExtractTopLevelJSONFields(body []byte) map[string]any

ExtractTopLevelJSONFields returns a flat map of top-level scalar (string/number/bool) fields from a JSON object body. Nested objects and arrays are included as-is. Used to inject request body fields as template parameters so {{.fieldName}} works in response templates without manual variable configuration.

func ExtractTopPrimitiveAttributes

func ExtractTopPrimitiveAttributes(b []byte, max int) (res []string)

ExtractTopPrimitiveAttributes to fetch attributes

func ExtractTypes

func ExtractTypes(val any, dataTemplate DataTemplateRequest) any

ExtractTypes extract types from any structure

func FileProperty

func FileProperty(fileName string, name string) any

FileProperty generator

func FindVariable

func FindVariable(name string, data any) any

FindVariable extracts variable property

func FlatRegexMap

func FlatRegexMap(val any) map[string]string

FlatRegexMap to add all regex in same map

func FormatCreditCard

func FormatCreditCard(cardNumber string) string

FormatCreditCard formats a credit card number with spaces based on its type

func GenerateCreditCard

func GenerateCreditCard(cardType CardType, seed int64) string

GenerateCreditCard generates a valid credit card number for the specified type

func GenerateFuzzData

func GenerateFuzzData(val any) any

GenerateFuzzData using regex, data or types

func IsJSONPathExpression

func IsJSONPathExpression(key string) bool

IsJSONPathExpression returns true when key starts with "$." or contains "[" followed by "]". Used to route assertion keys to JSONPath extraction instead of flat-key matching.

func IsValidCreditCard

func IsValidCreditCard(cardNumber string) bool

IsValidCreditCard checks if a credit card number is valid using the Luhn algorithm

func IsValidSSN

func IsValidSSN(ssn string) bool

IsValidSSN checks if an SSN is in the correct format and follows basic rules

func NewRandomSource

func NewRandomSource(seed int64) *rand.Rand

NewRandomSource creates a new random source with a seed

func ParseTemplate

func ParseTemplate(dir string, byteBody []byte, data any) ([]byte, error)

ParseTemplate parses GO template with dynamic parameters

func PrefixTypeStringToRegEx

func PrefixTypeStringToRegEx(val string, dataTemplate DataTemplateRequest) string

PrefixTypeStringToRegEx helper method for adding prefix and regex

func PropertyContains

func PropertyContains(name string, targets []any, data any) bool

PropertyContains checks if variable contains value

func PropertyEquals

func PropertyEquals(name string, data any, target any) bool

PropertyEquals checks if variable is equal to the value

func RandAddress

func RandAddress() string

RandAddress Generate a random address

func RandAirport

func RandAirport() string

RandAirport returns a random airport from the list

func RandBase64

func RandBase64() string

RandBase64 returns a random base64-encoded string (16 random bytes).

func RandBool

func RandBool() bool

RandBool generator

func RandCity

func RandCity() string

RandCity generator

func RandCmdInjection

func RandCmdInjection(seed ...int64) string

RandCmdInjection returns a randomized OS command injection payload.

func RandCountry

func RandCountry() string

RandCountry country generator

func RandCountryCode

func RandCountryCode() string

RandCountryCode country generator

func RandCreditCard

func RandCreditCard() string

func RandCurrencyCode

func RandCurrencyCode() string

RandCurrencyCode returns a random ISO 4217 currency code.

func RandEin

func RandEin() string

RandEin Generate a random United States Employer Identification Number EIN).

func RandEmail

func RandEmail() string

RandEmail generator

func RandFileExtension

func RandFileExtension() string

RandFileExtension returns a random file extension (without dot).

func RandFileLine

func RandFileLine(fileName string) string

RandFileLine generator

func RandFilename

func RandFilename() string

RandFilename generates a random filename with a random extension.

func RandFirstFemaleName

func RandFirstFemaleName() string

RandFirstFemaleName first name

func RandFirstMaleName

func RandFirstMaleName() string

RandFirstMaleName first name

func RandFirstName

func RandFirstName() string

RandFirstName first name

func RandFlightNumber

func RandFlightNumber() string

RandFlightNumber generates a random flight number using real airline patterns

func RandFloatMax

func RandFloatMax(max float64) float64

RandFloatMax returns random number between 0 and max

func RandFloatMinMax

func RandFloatMinMax(min, max float64) float64

RandFloatMinMax returns random number between min and max

func RandFutureDate

func RandFutureDate() string

RandFutureDate returns an ISO 8601 date 1–365 days in the future.

func RandHTTPStatus

func RandHTTPStatus() int

RandHTTPStatus returns a random commonly-used HTTP status code.

func RandHexColor

func RandHexColor() string

RandHexColor generates a random CSS hex color code (e.g. #3a7fcb).

func RandHost

func RandHost() string

RandHost generator

func RandIPv6

func RandIPv6() string

RandIPv6 generates a random IPv6 address.

func RandIntArrayMinMax

func RandIntArrayMinMax(min int, max int) []int

RandIntArrayMinMax generator

func RandIntMax

func RandIntMax(max int) int

RandIntMax returns random number between 0 and max

func RandIntMinMax

func RandIntMinMax(min, max int) int

RandIntMinMax returns random number between min and max

func RandItin

func RandItin() string

RandItin generator for random United States Individual Taxpayer Identification Number ITIN).

func RandLDAPi

func RandLDAPi(seed ...int64) string

RandLDAPi returns a randomized LDAP injection payload.

func RandLastName

func RandLastName() string

RandLastName last name

func RandLatitude

func RandLatitude() float64

RandLatitude returns a random latitude value between -90 and 90.

func RandLongitude

func RandLongitude() float64

RandLongitude returns a random longitude value between -180 and 180.

func RandMACAddress

func RandMACAddress() string

RandMACAddress generates a random locally-administered unicast MAC address.

func RandMD5

func RandMD5() string

RandMD5 returns a random MD5 hex digest.

func RandMimeType

func RandMimeType() string

RandMimeType returns a random MIME type string.

func RandName

func RandName() string

RandName name generator

func RandNoSQLi

func RandNoSQLi(seed ...int64) string

RandNoSQLi returns a randomized NoSQL injection payload.

func RandParagraph

func RandParagraph(min, max int) string

RandParagraph generate a paragraph with at least min sentences and at most max sentences.

func RandPassword

func RandPassword() string

RandPassword generates a random strong password (12–16 characters).

func RandPastDate

func RandPastDate() string

RandPastDate returns an ISO 8601 date 1–365 days in the past.

func RandPathTraversal

func RandPathTraversal(seed ...int64) string

RandPathTraversal returns a randomized path traversal payload.

func RandPhone

func RandPhone() string

RandPhone generator

func RandPort

func RandPort() int

RandPort returns a random unprivileged port number (1024–65535).

func RandRGBColor

func RandRGBColor() string

RandRGBColor generates a random CSS rgb() color string.

func RandRegex

func RandRegex(re string) string

RandRegex generator

func RandSHA256

func RandSHA256() string

RandSHA256 returns a random SHA-256 hex digest.

func RandSQLi

func RandSQLi(seed ...int64) string

RandSQLi returns a randomized SQL injection payload.

func RandSSN

func RandSSN() string

func RandSSTI

func RandSSTI(seed ...int64) string

RandSSTI returns a randomized server-side template injection payload.

func RandSemver

func RandSemver() string

RandSemver generates a random semantic version string (e.g. 3.14.159).

func RandSentence

func RandSentence(min, max int) string

RandSentence generate a sentence with at least min words and at most max words.

func RandSlug

func RandSlug() string

RandSlug generates a URL-friendly slug (two lowercase words joined by a hyphen).

func RandSsn

func RandSsn() string

RandSsn Generate a random invalid United States Social Security Identification Number SSN).

func RandString

func RandString(n int) string

RandString generator

func RandStringArrayMinMax

func RandStringArrayMinMax(min int, max int) []string

RandStringArrayMinMax generator

func RandStringMinMax

func RandStringMinMax(min int, max int) string

RandStringMinMax generator

func RandTimezone

func RandTimezone() string

RandTimezone returns a random IANA timezone identifier.

func RandTriString

func RandTriString(sep string) string

RandTriString phrase generator

func RandURL

func RandURL() string

RandURL generator

func RandUSState

func RandUSState() string

RandUSState Generate US State

func RandUSStateAbbr

func RandUSStateAbbr() string

RandUSStateAbbr Generate US State

func RandUnixTimestamp

func RandUnixTimestamp() int64

RandUnixTimestamp returns the current Unix epoch timestamp.

func RandUsername

func RandUsername() string

RandUsername generates a random lowercase username (first name + digits).

func RandWord

func RandWord(min, max int) string

RandWord generate a word with at least min letters and at most max letters.

func RandXSS

func RandXSS(seed ...int64) string

RandXSS returns a randomized cross-site scripting payload.

func RandXXE

func RandXXE(seed ...int64) string

RandXXE returns a randomized XML External Entity payload.

func RandomAirportByRegion

func RandomAirportByRegion(region string) string

RandomAirportByRegion returns a random airport from a specific region

func ReMarshalArrayOrObjectWithIndent

func ReMarshalArrayOrObjectWithIndent(b []byte) string

ReMarshalArrayOrObjectWithIndent helper method to unmarshal and marshal with indent

func SeededAddress

func SeededAddress(seed int64) string

SeededAddress Generate a random address

func SeededAirport

func SeededAirport(seed int64) string

SeededAirport returns a deterministic airport based on a seed

func SeededBool

func SeededBool(seed int64) bool

SeededBool generator

func SeededCity

func SeededCity(seed int64) string

SeededCity generator

func SeededCountry

func SeededCountry(seed int64) string

SeededCountry country generator

func SeededCountryCode

func SeededCountryCode(seed int64) string

SeededCountryCode country generator

func SeededCreditCard

func SeededCreditCard(seed int64) string

func SeededCurrencyCode

func SeededCurrencyCode(seed int64) string

SeededCurrencyCode returns a deterministic currency code based on seed.

func SeededFileLine

func SeededFileLine(fileName string, seed int64) string

SeededFileLine generator

func SeededFirstFemaleName

func SeededFirstFemaleName(seed int64) string

SeededFirstFemaleName first name

func SeededFirstMaleName

func SeededFirstMaleName(seed int64) string

SeededFirstMaleName first name

func SeededFirstName

func SeededFirstName(seed int64) string

SeededFirstName first name

func SeededFlightNumber

func SeededFlightNumber(seed int64) string

SeededFlightNumber generates a deterministic flight number based on a seed

func SeededLastName

func SeededLastName(seed int64) string

SeededLastName last name

func SeededName

func SeededName(seed int64) string

SeededName name generator

func SeededRandCmdInjection

func SeededRandCmdInjection(seed int64) string

SeededRandCmdInjection returns a deterministic command injection payload for the given seed.

func SeededRandFloatMax

func SeededRandFloatMax(seed int64, min, max float64) float64

SeededRandFloatMax returns random number with seed upto a max

func SeededRandIntMax

func SeededRandIntMax(seed int64, min, max int) int

SeededRandIntMax returns random number with seed upto a max

func SeededRandLDAPi

func SeededRandLDAPi(seed int64) string

SeededRandLDAPi returns a deterministic LDAP injection payload for the given seed.

func SeededRandNoSQLi

func SeededRandNoSQLi(seed int64) string

SeededRandNoSQLi returns a deterministic NoSQL injection payload for the given seed.

func SeededRandPathTraversal

func SeededRandPathTraversal(seed int64) string

SeededRandPathTraversal returns a deterministic path traversal payload for the given seed.

func SeededRandSQLi

func SeededRandSQLi(seed int64) string

SeededRandSQLi returns a deterministic SQL injection payload for the given seed.

func SeededRandSSTI

func SeededRandSSTI(seed int64) string

SeededRandSSTI returns a deterministic SSTI payload for the given seed.

func SeededRandXSS

func SeededRandXSS(seed int64) string

SeededRandXSS returns a deterministic XSS payload for the given seed.

func SeededRandXXE

func SeededRandXXE(seed int64) string

SeededRandXXE returns a deterministic XXE payload for the given seed.

func SeededSSN

func SeededSSN(seed int64) string

SeededSSN generates a random valid SSN - First 3 digits (area number): cannot be 000, 666, or 900-999 - Middle 2 digits (group number): cannot be 00 - Last 4 digits (serial number): cannot be 0000

func SeededTimezone

func SeededTimezone(seed int64) string

SeededTimezone returns a deterministic IANA timezone based on seed.

func SeededTriString

func SeededTriString(seed int64, sep string) string

SeededTriString phrase generator

func SeededUSPostal

func SeededUSPostal(state string, seed int64) string

SeededUSPostal Generate US postal code

func SeededUSState

func SeededUSState(seed int64) string

SeededUSState Generate US State

func SeededUSStateAbbr

func SeededUSStateAbbr(seed int64) string

SeededUSStateAbbr Generate US State

func SeededUUID

func SeededUUID(seed int64) string

SeededUUID generates a deterministic UUID v4 based on a seed value

func StripTypeTags

func StripTypeTags(re string) string

StripTypeTags removes type prefixes

func TemplateFuncs

func TemplateFuncs(dir string, data any) template.FuncMap

TemplateFuncs returns template functions

func ToFloat64

func ToFloat64(input any) (res float64)

ToFloat64 converter

func ULID

func ULID() string

ULID generator

func UUID

func UUID() string

UUID generator

func UnmarshalArrayOrObject

func UnmarshalArrayOrObject(b []byte) (res any, err error)

UnmarshalArrayOrObject helper function to unmarshal bytes based on object/array

func UnmarshalArrayOrObjectAndExtractTypes

func UnmarshalArrayOrObjectAndExtractTypes(str string, dataTemplate DataTemplateRequest) (map[string]string, error)

UnmarshalArrayOrObjectAndExtractTypes helper method to unmarshal, add types and marshal again

func UnmarshalArrayOrObjectAndExtractTypesAndMarshal

func UnmarshalArrayOrObjectAndExtractTypesAndMarshal(str string, dataTemplate DataTemplateRequest) (string, error)

UnmarshalArrayOrObjectAndExtractTypesAndMarshal helper method to unmarshal, add types and marshal again

func ValidateRegexMap

func ValidateRegexMap(val any, regex map[string]string) error

ValidateRegexMap validate data against regex map. Keys starting with "$." or containing "[…]" are treated as JSONPath expressions and extracted from val before matching. All other keys use the existing flat-key logic.

func ValueToRegEx

func ValueToRegEx(val string, dataTemplate DataTemplateRequest) string

ValueToRegEx value to regex

func VariableJsonPath

func VariableJsonPath(varPath string, expected string, data any) bool

VariableJsonPath Enhance PropertyMatches to support nested objects with JSON path

func VariableNumber

func VariableNumber(name string, data any) float64

VariableNumber returns numeric value for variable

func VariableSize

func VariableSize(name string, data any) int

VariableSize finds size of the variable

Types

type Airline

type Airline struct {
	Code      string
	MinNumber int
	MaxNumber int
}

Airline represents an airline with its code and flight number range

type Airport

type Airport struct {
	Code    string
	City    string
	Country string
	Region  string // NA = North America, EU = Europe, AS = Asia, etc.
}

Airport represents an airport with its IATA code, city, and country

func SeededAirportByRegion

func SeededAirportByRegion(seed int64, region string) Airport

SeededAirportByRegion returns a deterministic airport from a specific region

type CardInfo

type CardInfo struct {
	Type   CardType
	Prefix []string
	Length []int
}

CardInfo stores credit card type prefix information

type CardType

type CardType string

CardType represents different credit card types

const (
	Visa            CardType = "Visa"
	Mastercard      CardType = "Mastercard"
	AmericanExpress CardType = "American Express"
	Discover        CardType = "Discover"
	JCB             CardType = "JCB"
	DinersClub      CardType = "Diners Club"
	Unknown         CardType = "Unknown"
)

func GenerateRandomCreditCard

func GenerateRandomCreditCard(seed int64) (string, CardType)

GenerateRandomCreditCard generates a random valid credit card number of any type

func IdentifyCardType

func IdentifyCardType(cardNumber string) CardType

IdentifyCardType attempts to identify the card type from a card number

type DataTemplateRequest

type DataTemplateRequest struct {
	IncludeType   bool `yaml:"include_type" json:"include_type"`
	MinMultiplier int  `yaml:"min_multiplier" json:"min_multiplier"`
	MaxMultiplier int  `yaml:"max_multiplier" json:"max_multiplier"`
}

DataTemplateRequest for generating random data pattern

func NewDataTemplateRequest

func NewDataTemplateRequest(includeType bool, minMultiplier int, maxMultiplier int) DataTemplateRequest

NewDataTemplateRequest constructor

func (DataTemplateRequest) WithInclude

func (dtr DataTemplateRequest) WithInclude(includeType bool) DataTemplateRequest

WithInclude instantiates copy with a new include type

func (DataTemplateRequest) WithMaxMultiplier

func (dtr DataTemplateRequest) WithMaxMultiplier(multiplier int) DataTemplateRequest

WithMaxMultiplier instantiates copy with a new max multiplier

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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