2020-12-21 09:01:32 +00:00
|
|
|
package protocols
|
|
|
|
|
2020-12-23 15:16:42 +00:00
|
|
|
import (
|
2020-12-25 15:03:52 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/internal/progress"
|
2021-02-26 07:43:11 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog"
|
2021-02-05 19:06:43 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
2020-12-24 15:17:41 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
2020-12-23 15:16:42 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
2020-12-28 20:00:07 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/projectfile"
|
2021-02-21 11:01:34 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/headless/engine"
|
2021-02-02 06:40:47 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/issues"
|
2020-12-23 15:16:42 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
2020-12-23 20:12:04 +00:00
|
|
|
"go.uber.org/ratelimit"
|
2020-12-23 15:16:42 +00:00
|
|
|
)
|
2020-12-23 10:46:16 +00:00
|
|
|
|
2020-12-25 15:03:52 +00:00
|
|
|
// Executer is an interface implemented any protocol based request executer.
|
2020-12-23 15:16:42 +00:00
|
|
|
type Executer interface {
|
2020-12-25 15:03:52 +00:00
|
|
|
// Compile compiles the execution generators preparing any requests possible.
|
2020-12-25 15:09:09 +00:00
|
|
|
Compile() error
|
2020-12-21 22:24:55 +00:00
|
|
|
// Requests returns the total number of requests the rule will perform
|
2020-12-29 10:08:14 +00:00
|
|
|
Requests() int
|
2020-12-25 15:03:52 +00:00
|
|
|
// Execute executes the protocol group and returns true or false if results were found.
|
2020-12-23 15:16:42 +00:00
|
|
|
Execute(input string) (bool, error)
|
|
|
|
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
2021-01-01 14:06:21 +00:00
|
|
|
ExecuteWithResults(input string, callback OutputEventCallback) error
|
2020-12-21 09:01:32 +00:00
|
|
|
}
|
2020-12-23 10:46:16 +00:00
|
|
|
|
2020-12-23 15:16:42 +00:00
|
|
|
// ExecuterOptions contains the configuration options for executer clients
|
|
|
|
type ExecuterOptions struct {
|
2020-12-24 20:54:55 +00:00
|
|
|
// TemplateID is the ID of the template for the request
|
|
|
|
TemplateID string
|
2020-12-29 06:38:46 +00:00
|
|
|
// TemplatePath is the path of the template for the request
|
|
|
|
TemplatePath string
|
2020-12-24 20:54:55 +00:00
|
|
|
// TemplateInfo contains information block of the template request
|
2021-02-03 19:39:29 +00:00
|
|
|
TemplateInfo map[string]interface{}
|
2020-12-23 15:16:42 +00:00
|
|
|
// Output is a writer interface for writing output events from executer.
|
|
|
|
Output output.Writer
|
2020-12-23 20:12:04 +00:00
|
|
|
// Options contains configuration options for the executer.
|
2020-12-23 15:16:42 +00:00
|
|
|
Options *types.Options
|
2021-02-02 06:40:47 +00:00
|
|
|
// IssuesClient is a client for nuclei issue tracker reporting
|
|
|
|
IssuesClient *issues.Client
|
2020-12-25 15:03:52 +00:00
|
|
|
// Progress is a progress client for scan reporting
|
|
|
|
Progress *progress.Progress
|
2020-12-23 20:12:04 +00:00
|
|
|
// RateLimiter is a rate-limiter for limiting sent number of requests.
|
|
|
|
RateLimiter ratelimit.Limiter
|
2021-02-26 07:43:11 +00:00
|
|
|
// Catalog is a template catalog implementation for nuclei
|
|
|
|
Catalog *catalog.Catalog
|
2020-12-28 20:00:07 +00:00
|
|
|
// ProjectFile is the project file for nuclei
|
|
|
|
ProjectFile *projectfile.ProjectFile
|
2021-02-21 11:01:34 +00:00
|
|
|
// Browser is a browser engine for running headless templates
|
|
|
|
Browser *engine.Browser
|
2021-02-05 19:06:43 +00:00
|
|
|
|
|
|
|
Operators []*operators.Operators // only used by offlinehttp module
|
2020-12-23 10:46:16 +00:00
|
|
|
}
|
2020-12-25 15:03:52 +00:00
|
|
|
|
|
|
|
// Request is an interface implemented any protocol based request generator.
|
|
|
|
type Request interface {
|
|
|
|
// Compile compiles the request generators preparing any requests possible.
|
2020-12-25 15:09:09 +00:00
|
|
|
Compile(options *ExecuterOptions) error
|
2020-12-25 15:03:52 +00:00
|
|
|
// Requests returns the total number of requests the rule will perform
|
2020-12-29 10:08:14 +00:00
|
|
|
Requests() int
|
2021-01-16 08:40:24 +00:00
|
|
|
// GetID returns the ID for the request if any. IDs are used for multi-request
|
|
|
|
// condition matching. So, two requests can be sent and their match can
|
|
|
|
// be evaluated from the third request by using the IDs for both requests.
|
|
|
|
GetID() string
|
2020-12-25 15:03:52 +00:00
|
|
|
// Match performs matching operation for a matcher on model and returns true or false.
|
|
|
|
Match(data map[string]interface{}, matcher *matchers.Matcher) bool
|
|
|
|
// Extract performs extracting operation for a extractor on model and returns true or false.
|
|
|
|
Extract(data map[string]interface{}, matcher *extractors.Extractor) map[string]struct{}
|
|
|
|
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
2021-01-16 08:40:24 +00:00
|
|
|
ExecuteWithResults(input string, dynamicValues, previous output.InternalEvent, callback OutputEventCallback) error
|
2020-12-25 15:03:52 +00:00
|
|
|
}
|
2021-01-01 14:06:21 +00:00
|
|
|
|
|
|
|
// OutputEventCallback is a callback event for any results found during scanning.
|
|
|
|
type OutputEventCallback func(result *output.InternalWrappedEvent)
|