2020-12-21 14:31:32 +05:30
|
|
|
package protocols
|
|
|
|
|
|
2020-12-23 20:46:42 +05:30
|
|
|
import (
|
2020-12-25 20:33:52 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/internal/progress"
|
2020-12-29 18:02:45 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalogue"
|
2020-12-24 20:47:41 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
2020-12-23 20:46:42 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
2020-12-29 01:30:07 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/projectfile"
|
2020-12-23 20:46:42 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
2020-12-24 01:42:04 +05:30
|
|
|
"go.uber.org/ratelimit"
|
2020-12-23 20:46:42 +05:30
|
|
|
)
|
2020-12-23 16:16:16 +05:30
|
|
|
|
2020-12-25 20:33:52 +05:30
|
|
|
// Executer is an interface implemented any protocol based request executer.
|
2020-12-23 20:46:42 +05:30
|
|
|
type Executer interface {
|
2020-12-25 20:33:52 +05:30
|
|
|
// Compile compiles the execution generators preparing any requests possible.
|
2020-12-25 20:39:09 +05:30
|
|
|
Compile() error
|
2020-12-22 03:54:55 +05:30
|
|
|
// Requests returns the total number of requests the rule will perform
|
2020-12-29 15:38:14 +05:30
|
|
|
Requests() int
|
2020-12-25 20:33:52 +05:30
|
|
|
// Execute executes the protocol group and returns true or false if results were found.
|
2020-12-23 20:46:42 +05:30
|
|
|
Execute(input string) (bool, error)
|
|
|
|
|
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
2021-01-01 19:36:21 +05:30
|
|
|
ExecuteWithResults(input string, callback OutputEventCallback) error
|
2020-12-21 14:31:32 +05:30
|
|
|
}
|
2020-12-23 16:16:16 +05:30
|
|
|
|
2020-12-23 20:46:42 +05:30
|
|
|
// ExecuterOptions contains the configuration options for executer clients
|
|
|
|
|
type ExecuterOptions struct {
|
2020-12-25 02:24:55 +05:30
|
|
|
// TemplateID is the ID of the template for the request
|
|
|
|
|
TemplateID string
|
2020-12-29 12:08:46 +05:30
|
|
|
// TemplatePath is the path of the template for the request
|
|
|
|
|
TemplatePath string
|
2020-12-25 02:24:55 +05:30
|
|
|
// TemplateInfo contains information block of the template request
|
|
|
|
|
TemplateInfo map[string]string
|
2020-12-23 20:46:42 +05:30
|
|
|
// Output is a writer interface for writing output events from executer.
|
|
|
|
|
Output output.Writer
|
2020-12-24 01:42:04 +05:30
|
|
|
// Options contains configuration options for the executer.
|
2020-12-23 20:46:42 +05:30
|
|
|
Options *types.Options
|
2020-12-25 20:33:52 +05:30
|
|
|
// Progress is a progress client for scan reporting
|
|
|
|
|
Progress *progress.Progress
|
2020-12-24 01:42:04 +05:30
|
|
|
// RateLimiter is a rate-limiter for limiting sent number of requests.
|
|
|
|
|
RateLimiter ratelimit.Limiter
|
2020-12-29 18:02:45 +05:30
|
|
|
// Catalogue is a template catalogue implementation for nuclei
|
|
|
|
|
Catalogue *catalogue.Catalogue
|
2020-12-29 01:30:07 +05:30
|
|
|
// ProjectFile is the project file for nuclei
|
|
|
|
|
ProjectFile *projectfile.ProjectFile
|
2020-12-23 16:16:16 +05:30
|
|
|
}
|
2020-12-25 20:33:52 +05:30
|
|
|
|
|
|
|
|
// 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 20:39:09 +05:30
|
|
|
Compile(options *ExecuterOptions) error
|
2020-12-25 20:33:52 +05:30
|
|
|
// Requests returns the total number of requests the rule will perform
|
2020-12-29 15:38:14 +05:30
|
|
|
Requests() int
|
2021-01-16 14:10:24 +05:30
|
|
|
// 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 20:33:52 +05:30
|
|
|
// 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 14:10:24 +05:30
|
|
|
ExecuteWithResults(input string, dynamicValues, previous output.InternalEvent, callback OutputEventCallback) error
|
2020-12-25 20:33:52 +05:30
|
|
|
}
|
2021-01-01 19:36:21 +05:30
|
|
|
|
|
|
|
|
// OutputEventCallback is a callback event for any results found during scanning.
|
|
|
|
|
type OutputEventCallback func(result *output.InternalWrappedEvent)
|