ffuf

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 22 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//VERSION holds the current version number
	VERSION = "1.5.0"
	//VERSION_APPENDIX holds additional version definition
	VERSION_APPENDIX = "-dev"
)

Functions

func FileExists added in v1.1.0

func FileExists(path string) bool

FileExists checks if the filepath exists and is not a directory. Returns false in case it's not possible to describe the named file.

func HostURLFromRequest added in v1.5.0

func HostURLFromRequest(req Request) string

HostURLFromRequest gets a host + path without the filename or last part of the URL path

func RandomString

func RandomString(n int) string

RandomString returns a random string of length of parameter n

func RequestContainsKeyword added in v1.4.1

func RequestContainsKeyword(req Request, kw string) bool

RequestContainsKeyword checks if a keyword is present in any field of a request

func UniqStringSlice

func UniqStringSlice(inslice []string) []string

UniqStringSlice returns an unordered slice of unique strings. The duplicates are dropped

func UrlEqual added in v1.4.0

func UrlEqual(url1, url2 *url.URL) bool

func Version added in v1.3.0

func Version() string

Version returns the ffuf version string

Types

type Config

type Config struct {
	AutoCalibration         bool                  `json:"autocalibration"`
	AutoCalibrationKeyword  string                `json:"autocalibration_keyword"`
	AutoCalibrationPerHost  bool                  `json:"autocalibration_perhost"`
	AutoCalibrationStrategy string                `json:"autocalibration_strategy"`
	AutoCalibrationStrings  []string              `json:"autocalibration_strings"`
	Cancel                  context.CancelFunc    `json:"-"`
	Colors                  bool                  `json:"colors"`
	CommandKeywords         []string              `json:"-"`
	CommandLine             string                `json:"cmdline"`
	ConfigFile              string                `json:"configfile"`
	Context                 context.Context       `json:"-"`
	Data                    string                `json:"postdata"`
	Delay                   optRange              `json:"delay"`
	DirSearchCompat         bool                  `json:"dirsearch_compatibility"`
	Extensions              []string              `json:"extensions"`
	FilterMode              string                `json:"fmode"`
	FollowRedirects         bool                  `json:"follow_redirects"`
	Headers                 map[string]string     `json:"headers"`
	IgnoreBody              bool                  `json:"ignorebody"`
	IgnoreWordlistComments  bool                  `json:"ignore_wordlist_comments"`
	InputMode               string                `json:"inputmode"`
	InputNum                int                   `json:"cmd_inputnum"`
	InputProviders          []InputProviderConfig `json:"inputproviders"`
	InputShell              string                `json:"inputshell"`
	Json                    bool                  `json:"json"`
	MatcherManager          MatcherManager        `json:"matchers"`
	MatcherMode             string                `json:"mmode"`
	MaxTime                 int                   `json:"maxtime"`
	MaxTimeJob              int                   `json:"maxtime_job"`
	Method                  string                `json:"method"`
	Noninteractive          bool                  `json:"noninteractive"`
	OutputDirectory         string                `json:"outputdirectory"`
	OutputFile              string                `json:"outputfile"`
	OutputFormat            string                `json:"outputformat"`
	OutputSkipEmptyFile     bool                  `json:"OutputSkipEmptyFile"`
	ProgressFrequency       int                   `json:"-"`
	ProxyURL                string                `json:"proxyurl"`
	Quiet                   bool                  `json:"quiet"`
	Rate                    int64                 `json:"rate"`
	Recursion               bool                  `json:"recursion"`
	RecursionDepth          int                   `json:"recursion_depth"`
	RecursionStrategy       string                `json:"recursion_strategy"`
	ReplayProxyURL          string                `json:"replayproxyurl"`
	SNI                     string                `json:"sni"`
	StopOn403               bool                  `json:"stop_403"`
	StopOnAll               bool                  `json:"stop_all"`
	StopOnErrors            bool                  `json:"stop_errors"`
	Threads                 int                   `json:"threads"`
	Timeout                 int                   `json:"timeout"`
	Url                     string                `json:"url"`
	Verbose                 bool                  `json:"verbose"`
	Http2                   bool                  `json:"http2"`
}

func ConfigFromOptions added in v1.2.0

func ConfigFromOptions(parseOpts *ConfigOptions, ctx context.Context, cancel context.CancelFunc) (*Config, error)

ConfigFromOptions parses the values in ConfigOptions struct, ensures that the values are sane, and creates a Config struct out of them.

func NewConfig

func NewConfig(ctx context.Context, cancel context.CancelFunc) Config

func (*Config) SetContext added in v1.2.0

func (c *Config) SetContext(ctx context.Context, cancel context.CancelFunc)

type ConfigOptions added in v1.2.0

type ConfigOptions struct {
	Filter  FilterOptions
	General GeneralOptions
	HTTP    HTTPOptions
	Input   InputOptions
	Matcher MatcherOptions
	Output  OutputOptions
}

func NewConfigOptions added in v1.2.0

func NewConfigOptions() *ConfigOptions

NewConfigOptions returns a newly created ConfigOptions struct with default values

func ReadConfig added in v1.2.0

func ReadConfig(configFile string) (*ConfigOptions, error)

func ReadDefaultConfig added in v1.2.0

func ReadDefaultConfig() (*ConfigOptions, error)

type FilterOptions added in v1.2.0

type FilterOptions struct {
	Mode   string
	Lines  string
	Regexp string
	Size   string
	Status string
	Time   string
	Words  string
}

type FilterProvider

type FilterProvider interface {
	Filter(response *Response) (bool, error)
	Repr() string
	ReprVerbose() string
}

FilterProvider is a generic interface for both Matchers and Filters

type GeneralOptions added in v1.2.0

type GeneralOptions struct {
	AutoCalibration         bool
	AutoCalibrationKeyword  string
	AutoCalibrationPerHost  bool
	AutoCalibrationStrategy string
	AutoCalibrationStrings  []string
	Colors                  bool
	ConfigFile              string `toml:"-"`
	Delay                   string
	Json                    bool
	MaxTime                 int
	MaxTimeJob              int
	Noninteractive          bool
	Quiet                   bool
	Rate                    int
	ShowVersion             bool `toml:"-"`
	StopOn403               bool
	StopOnAll               bool
	StopOnErrors            bool
	Threads                 int
	Verbose                 bool
}

type HTTPOptions added in v1.2.0

type HTTPOptions struct {
	Cookies           []string
	Data              string
	FollowRedirects   bool
	Headers           []string
	IgnoreBody        bool
	Method            string
	ProxyURL          string
	Recursion         bool
	RecursionDepth    int
	RecursionStrategy string
	ReplayProxyURL    string
	SNI               string
	Timeout           int
	URL               string
	Http2             bool
}

type InputOptions added in v1.2.0

type InputOptions struct {
	DirSearchCompat        bool
	Extensions             string
	IgnoreWordlistComments bool
	InputMode              string
	InputNum               int
	InputShell             string
	Inputcommands          []string
	Request                string
	RequestProto           string
	Wordlists              []string
}

type InputProvider

type InputProvider interface {
	ActivateKeywords([]string)
	AddProvider(InputProviderConfig) error
	Keywords() []string
	Next() bool
	Position() int
	Reset()
	Value() map[string][]byte
	Total() int
}

InputProvider interface handles the input data for RunnerProvider

type InputProviderConfig

type InputProviderConfig struct {
	Name     string `json:"name"`
	Keyword  string `json:"keyword"`
	Value    string `json:"value"`
	Template string `json:"template"` // the templating string used for sniper mode (usually "§")
}

type InternalInputProvider

type InternalInputProvider interface {
	Keyword() string
	Next() bool
	Position() int
	ResetPosition()
	IncrementPosition()
	Value() []byte
	Total() int
	Active() bool
	Enable()
	Disable()
}

InternalInputProvider interface handles providing input data to InputProvider

type Job

type Job struct {
	Config               *Config
	ErrorMutex           sync.Mutex
	Input                InputProvider
	Runner               RunnerProvider
	ReplayRunner         RunnerProvider
	Output               OutputProvider
	Counter              int
	ErrorCounter         int
	SpuriousErrorCounter int
	Total                int
	Running              bool
	RunningJob           bool
	Paused               bool
	Count403             int
	Count429             int
	Error                string
	Rate                 *RateThrottle
	// contains filtered or unexported fields
}

Job ties together Config, Runner, Input and Output

func NewJob

func NewJob(conf *Config) *Job

func (*Job) Calibrate added in v1.5.0

func (j *Job) Calibrate(input map[string][]byte) error

CalibrateResponses returns slice of Responses for randomly generated filter autocalibration requests

func (*Job) CalibrateForHost added in v1.5.0

func (j *Job) CalibrateForHost(host string, baseinput map[string][]byte) error

CalibrateForHost runs autocalibration for a specific host

func (*Job) CalibrateIfNeeded added in v1.5.0

func (j *Job) CalibrateIfNeeded(host string, input map[string][]byte) error

CalibrateIfNeeded runs a self-calibration task for filtering options (if needed) by requesting random resources and

configuring the filters accordingly

func (*Job) CheckStop

func (j *Job) CheckStop()

CheckStop stops the job if stopping conditions are met

func (*Job) DeleteQueueItem added in v1.3.0

func (j *Job) DeleteQueueItem(index int)

DeleteQueueItem deletes a recursion job from the queue by its index in the slice

func (*Job) Next added in v1.1.0

func (j *Job) Next()

Stop current, resume to next

func (*Job) Pause added in v1.3.0

func (j *Job) Pause()

Pause pauses the job process

func (*Job) QueuedJobs added in v1.3.0

func (j *Job) QueuedJobs() []QueueJob

QueuedJobs returns the slice of queued recursive jobs

func (*Job) Reset added in v1.3.0

func (j *Job) Reset(cycle bool)

Reset resets the counters and wordlist position for a job

func (*Job) Resume added in v1.3.0

func (j *Job) Resume()

Resume resumes the job process

func (*Job) SkipQueue added in v1.3.0

func (j *Job) SkipQueue()

SkipQueue allows to skip the current job and advance to the next queued recursion job

func (*Job) Start

func (j *Job) Start()

Start the execution of the Job

func (*Job) Stop

func (j *Job) Stop()

Stop the execution of the Job

type MatcherManager added in v1.5.0

type MatcherManager interface {
	SetCalibrated(calibrated bool)
	SetCalibratedForHost(host string, calibrated bool)
	AddFilter(name string, option string, replace bool) error
	AddPerDomainFilter(domain string, name string, option string) error
	RemoveFilter(name string)
	AddMatcher(name string, option string) error
	GetFilters() map[string]FilterProvider
	GetMatchers() map[string]FilterProvider
	FiltersForDomain(domain string) map[string]FilterProvider
	CalibratedForDomain(domain string) bool
	Calibrated() bool
}

MatcherManager provides functions for managing matchers and filters

type MatcherOptions added in v1.2.0

type MatcherOptions struct {
	Mode   string
	Lines  string
	Regexp string
	Size   string
	Status string
	Time   string
	Words  string
}

type Multierror

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

func NewMultierror

func NewMultierror() Multierror

NewMultierror returns a new Multierror

func (*Multierror) Add

func (m *Multierror) Add(err error)

func (*Multierror) ErrorOrNil

func (m *Multierror) ErrorOrNil() error

type OutputOptions added in v1.2.0

type OutputOptions struct {
	DebugLog            string
	OutputDirectory     string
	OutputFile          string
	OutputFormat        string
	OutputSkipEmptyFile bool
}

type OutputProvider

type OutputProvider interface {
	Banner()
	Finalize() error
	Progress(status Progress)
	Info(infostring string)
	Error(errstring string)
	Raw(output string)
	Warning(warnstring string)
	Result(resp Response)
	PrintResult(res Result)
	SaveFile(filename, format string) error
	GetCurrentResults() []Result
	SetCurrentResults(results []Result)
	Reset()
	Cycle()
}

OutputProvider is responsible of providing output from the RunnerProvider

type Progress

type Progress struct {
	StartedAt  time.Time
	ReqCount   int
	ReqTotal   int
	ReqSec     int64
	QueuePos   int
	QueueTotal int
	ErrorCount int
}

type QueueJob

type QueueJob struct {
	Url string
	// contains filtered or unexported fields
}

type RateThrottle added in v1.2.0

type RateThrottle struct {
	RateAdjustment    float64
	RateAdjustmentPos int
	Config            *Config
	RateMutex         sync.Mutex
	// contains filtered or unexported fields
}

func NewRateThrottle added in v1.2.0

func NewRateThrottle(conf *Config) *RateThrottle

func (*RateThrottle) Adjust added in v1.2.0

func (r *RateThrottle) Adjust()

Adjust changes the RateAdjustment value, which is multiplier of second to pause between requests in a thread

func (*RateThrottle) CurrentRate added in v1.2.0

func (r *RateThrottle) CurrentRate() int64

CurrentRate calculates requests/second value from circular list of rate

func (*RateThrottle) Throttle added in v1.2.0

func (r *RateThrottle) Throttle()

func (*RateThrottle) Tick added in v1.2.0

func (r *RateThrottle) Tick(start, end time.Time)

rateTick adds a new duration measurement tick to rate counter

type Request

type Request struct {
	Method   string
	Host     string
	Url      string
	Headers  map[string]string
	Data     []byte
	Input    map[string][]byte
	Position int
	Raw      string
}

Request holds the meaningful data that is passed for runner for making the query

func BaseRequest added in v1.4.0

func BaseRequest(conf *Config) Request

BaseRequest returns a base request struct populated from the main config

func CopyRequest added in v1.4.0

func CopyRequest(basereq *Request) Request

CopyRequest performs a deep copy of a request and returns a new struct

func NewRequest

func NewRequest(conf *Config) Request

func RecursionRequest added in v1.4.1

func RecursionRequest(conf *Config, path string) Request

RecursionRequest returns a base request for a recursion target

func SniperRequests added in v1.4.0

func SniperRequests(basereq *Request, template string) []Request

SniperRequests returns an array of requests, each with one of the templated locations replaced by a keyword

type Response

type Response struct {
	StatusCode    int64
	Headers       map[string][]string
	Data          []byte
	ContentLength int64
	ContentWords  int64
	ContentLines  int64
	ContentType   string
	Cancelled     bool
	Request       *Request
	Raw           string
	ResultFile    string
	Time          time.Duration
}

Response struct holds the meaningful data returned from request and is meant for passing to filters

func NewResponse

func NewResponse(httpresp *http.Response, req *Request) Response

func (*Response) GetRedirectLocation

func (resp *Response) GetRedirectLocation(absolute bool) string

GetRedirectLocation returns the redirect location for a 3xx redirect HTTP response

type Result added in v1.3.0

type Result struct {
	Input            map[string][]byte `json:"input"`
	Position         int               `json:"position"`
	StatusCode       int64             `json:"status"`
	ContentLength    int64             `json:"length"`
	ContentWords     int64             `json:"words"`
	ContentLines     int64             `json:"lines"`
	ContentType      string            `json:"content-type"`
	RedirectLocation string            `json:"redirectlocation"`
	Url              string            `json:"url"`
	Duration         time.Duration     `json:"duration"`
	ResultFile       string            `json:"resultfile"`
	Host             string            `json:"host"`
	HTMLColor        string            `json:"-"`
}

type RunnerProvider

type RunnerProvider interface {
	Prepare(input map[string][]byte, basereq *Request) (Request, error)
	Execute(req *Request) (Response, error)
}

RunnerProvider is an interface for request executors

type ValueRange

type ValueRange struct {
	Min, Max int64
}

func ValueRangeFromString

func ValueRangeFromString(instr string) (ValueRange, error)

Jump to

Keyboard shortcuts

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