checker

package
v0.0.0-...-dfe0916 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FullCheckReasonOK                       = "ok"
	FullCheckReasonModified                 = "AST modified"
	FullCheckReasonMoreStatements           = "none or multiple SQls"
	FullCheckReasonSyntaxError              = "syntax error"
	FullCheckReasonConstantBinaryExpression = "constant binary expression"
	FullCheckReasonConstantSelectStatement  = "constant select statement"
)
View Source
const (
	PartialCheckReasonOK             = "ok"
	PartialCheckReasonModified       = "AST modified"
	PartialCheckReasonTemplateError  = "template error"
	PartialCheckReasonSyntaxError    = "syntax error"
	PartialCheckReasonMoreStatements = "none or multiple SQls"
)

Variables

This section is empty.

Functions

func IsFullInjection

func IsFullInjection(node *syntax.Node, result *FullResult)

func URLDecode

func URLDecode(s string) string

URLDecode decodes a string in URL encoding.

Types

type Decoder

type Decoder struct {
	Decoders []func(string) string
}

Decoder is a chain of decoders for SQL statements.

func DefaultDecoders

func DefaultDecoders() *Decoder

DefaultDecoders returns the default decoders, with URLDecode.

func NewDecoder

func NewDecoder(decoder ...func(string) string) *Decoder

NewDecoder creates a new decoder with the given decoders.

func (*Decoder) Decode

func (d *Decoder) Decode(s string) string

type FullChecker

type FullChecker struct {
	Decoder *Decoder
}

func DefaultFullChecker

func DefaultFullChecker() *FullChecker

func NewFullChecker

func NewFullChecker(decoder *Decoder) *FullChecker

func (*FullChecker) Check

func (c *FullChecker) Check(raw string) *FullResult

type FullElementResult

type FullElementResult struct {
	Reason string
	Text   string
}

type FullResult

type FullResult struct {
	Err                     error
	Reason                  string
	Elements                []FullElementResult
	AllowMultipleStatements bool
}

func (*FullResult) IsInjection

func (r *FullResult) IsInjection() bool

type PartialChecker

type PartialChecker struct {
	Templates []PartialSQLTemplate
	Decoder   *Decoder
}

func DefaultPartialChecker

func DefaultPartialChecker() *PartialChecker

DefaultPartialChecker Create a checker for partial SQL, with default templates and decoders.

func NewPartialChecker

func NewPartialChecker(templates []PartialSQLTemplate, decoder *Decoder) *PartialChecker

NewPartialChecker Create a checker for partial SQL, with custom templates and decoders.

func (*PartialChecker) Check

func (c *PartialChecker) Check(raw string) *PartialResult

Check checks if the payload is a SQL injection. Payload CAN BE encoded, and will be decoded before checking.

type PartialResult

type PartialResult struct {
	Results []PartialSQLCheckResult
}

func (*PartialResult) IsInjection

func (r *PartialResult) IsInjection() bool

IsInjection Is a SQL injection, at least one template is a SQL injection.

type PartialSQLCheckResult

type PartialSQLCheckResult struct {
	IsInjection bool
	Template    string
	Payload     string
	Reason      string
	Err         error
	AstCorrect  []*syntax.Node
	AstPartial  []*syntax.Node
}

PartialSQLCheckResult is the result of partial SQL injection checking

func (*PartialSQLCheckResult) SQL

func (r *PartialSQLCheckResult) SQL() string

func (*PartialSQLCheckResult) SQLInColour

func (r *PartialSQLCheckResult) SQLInColour() string

type PartialSQLTemplate

type PartialSQLTemplate struct {
	Template       string
	CorrectPayload string
}

PartialSQLTemplate is a template for partial SQL injection checking.

func (PartialSQLTemplate) Build

func (t PartialSQLTemplate) Build(input string) string

func (PartialSQLTemplate) Check

Check checks if the payload is a SQL injection. Payload MUST BE raw SQL text.

func (PartialSQLTemplate) Correct

func (t PartialSQLTemplate) Correct() string

Jump to

Keyboard shortcuts

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