Documentation
¶
Index ¶
- Variables
- func GetTargetsFromTemplateMetadata(ctx context.Context, templates []*templates.Template, outputFormat string, ...) chan string
- func GetTargetsFromUncover(ctx context.Context, outputFormat string, opts *uncover.Options) (chan string, error)
- type Concurrency
- type HeadlessOpts
- type InteractshOpts
- type NetworkConfig
- type NucleiEngine
- func (e *NucleiEngine) Close()
- func (e *NucleiEngine) Engine() *core.Engine
- func (e *NucleiEngine) ExecuteCallbackWithCtx(ctx context.Context, callback ...func(event *output.ResultEvent)) error
- func (e *NucleiEngine) ExecuteWithCallback(callback ...func(event *output.ResultEvent)) error
- func (e *NucleiEngine) GetAllClusterMappings() map[string][]string
- func (e *NucleiEngine) GetClusterTemplateIDs(clusterID string) []string
- func (e *NucleiEngine) GetExecuterOptions() *protocols.ExecutorOptions
- func (e *NucleiEngine) GetParser() *templates.Parser
- func (e *NucleiEngine) GetTemplates() []*templates.Template
- func (e *NucleiEngine) GetWorkflows() []*templates.Template
- func (e *NucleiEngine) LoadAllTemplates() error
- func (e *NucleiEngine) LoadTargets(targets []string, probeNonHttp bool)
- func (e *NucleiEngine) LoadTargetsFromReader(reader io.Reader, probeNonHttp bool)
- func (e *NucleiEngine) LoadTargetsWithHttpData(filePath string, filemode string) error
- func (e *NucleiEngine) Options() *types.Options
- func (e *NucleiEngine) ParseTemplate(data []byte) (*templates.Template, error)
- func (e *NucleiEngine) SignTemplate(tmplSigner *signer.TemplateSigner, data []byte) ([]byte, error)
- func (e *NucleiEngine) Store() *loader.Store
- type NucleiSDKOptions
- func DASTMode() NucleiSDKOptions
- func DisableTemplateCache() NucleiSDKOptions
- func DisableUpdateCheck() NucleiSDKOptions
- func EnableCodeTemplates() NucleiSDKOptions
- func EnableFileTemplates() NucleiSDKOptions
- func EnableGlobalMatchersTemplates() NucleiSDKOptions
- func EnableHeadlessWithOpts(hopts *HeadlessOpts) NucleiSDKOptions
- func EnableMatcherStatus() NucleiSDKOptions
- func EnablePassiveMode() NucleiSDKOptions
- func EnableSelfContainedTemplates() NucleiSDKOptions
- func EnableStatsWithOpts(opts StatsOptions) NucleiSDKOptions
- func LoadSecretsFromFile(files []string, prefetch bool) NucleiSDKOptions
- func SignedTemplatesOnly() NucleiSDKOptions
- func UseOutputWriter(writer OutputWriter) NucleiSDKOptions
- func UseStatsWriter(writer StatsWriter) NucleiSDKOptions
- func WithAuthProvider(provider authprovider.AuthProvider) NucleiSDKOptions
- func WithCatalog(cat catalog.Catalog) NucleiSDKOptions
- func WithConcurrency(opts Concurrency) NucleiSDKOptions
- func WithConfigBytes(data []byte) NucleiSDKOptions
- func WithConfigFile(path string) NucleiSDKOptions
- func WithGlobalRateLimit(maxTokens int, duration time.Duration) NucleiSDKOptions
- func WithGlobalRateLimitCtx(ctx context.Context, maxTokens int, duration time.Duration) NucleiSDKOptions
- func WithHeaders(headers []string) NucleiSDKOptions
- func WithInteractshOptions(opts InteractshOpts) NucleiSDKOptions
- func WithLogger(logger *gologger.Logger) NucleiSDKOptions
- func WithNetworkConfig(opts NetworkConfig) NucleiSDKOptions
- func WithOptions(opts *pkgtypes.Options) NucleiSDKOptions
- func WithPDCPUpload(scanID, teamID string) NucleiSDKOptions
- func WithProxy(proxy []string, proxyInternalRequests bool) NucleiSDKOptions
- func WithReportingConfigBytes(data []byte) NucleiSDKOptions
- func WithReportingConfigFile(path string) NucleiSDKOptions
- func WithResponseReadSize(responseReadSize int) NucleiSDKOptions
- func WithResultCallback(callback func(event *output.ResultEvent)) NucleiSDKOptions
- func WithResumeFile(file string) NucleiSDKOptions
- func WithSandboxOptions(allowLocalFileAccess bool, restrictLocalNetworkAccess bool) NucleiSDKOptions
- func WithScanStrategy(strategy string) NucleiSDKOptions
- func WithTemplateFilters(filters TemplateFilters) NucleiSDKOptions
- func WithTemplateUpdateCallback(disableTemplatesAutoUpgrade bool, callback func(newVersion string)) NucleiSDKOptions
- func WithTemplatesOrWorkflows(sources TemplateSources) NucleiSDKOptions
- func WithTemporaryDirectory(parentDir string) NucleiSDKOptions
- func WithVars(vars []string) NucleiSDKOptions
- func WithVerbosity(opts VerbosityOptions) NucleiSDKOptions
- type OutputWriter
- type RuntimeConfig
- type StatsOptions
- type StatsWriter
- type TemplateFilters
- type TemplateSources
- type ThreadSafeNucleiEngine
- func (e *ThreadSafeNucleiEngine) Close()
- func (e *ThreadSafeNucleiEngine) ExecuteNucleiWithOpts(targets []string, opts ...NucleiSDKOptions) error
- func (e *ThreadSafeNucleiEngine) ExecuteNucleiWithOptsCtx(ctx context.Context, targets []string, opts ...NucleiSDKOptions) error
- func (e *ThreadSafeNucleiEngine) GlobalLoadAllTemplates() error
- func (e *ThreadSafeNucleiEngine) GlobalResultCallback(callback func(event *output.ResultEvent))
- type VerbosityOptions
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotImplemented is returned when a feature is not implemented ErrNotImplemented = errkit.New("Not implemented") // ErrNoTemplatesAvailable is returned when no templates are available to execute ErrNoTemplatesAvailable = errkit.New("No templates available") // ErrNoTargetsAvailable is returned when no targets are available to scan ErrNoTargetsAvailable = errkit.New("No targets available") // ErrOptionsNotSupported is returned when an option is not supported in thread safe mode ErrOptionsNotSupported = errkit.New("Option not supported in thread safe mode") )
var DefaultConfig *config.Config
DefaultConfig is instance of default nuclei configs any mutations to this config will be reflected in all nuclei instances (saves some config to disk)
Functions ¶
func GetTargetsFromTemplateMetadata ¶
func GetTargetsFromTemplateMetadata(ctx context.Context, templates []*templates.Template, outputFormat string, opts *uncover.Options) chan string
GetTargetsFromTemplateMetadata returns all targets by querying engine metadata (ex: fofo-query,shodan-query) etc from given templates . supported formats are any string with [ip,host,port,url] placeholders
Types ¶
type Concurrency ¶
type Concurrency struct {
TemplateConcurrency int // number of templates to run concurrently (per host in host-spray mode)
HostConcurrency int // number of hosts to scan concurrently (per template in template-spray mode)
HeadlessHostConcurrency int // number of hosts to scan concurrently for headless templates (per template in template-spray mode)
HeadlessTemplateConcurrency int // number of templates to run concurrently for headless templates (per host in host-spray mode)
JavascriptTemplateConcurrency int // number of templates to run concurrently for javascript templates (per host in host-spray mode)
TemplatePayloadConcurrency int // max concurrent payloads to run for a template (a good default is 25)
ProbeConcurrency int // max concurrent http probes to run (a good default is 50)
}
Concurrency options
type HeadlessOpts ¶
type HeadlessOpts struct {
PageTimeout int // timeout for page load
ShowBrowser bool
HeadlessOptions []string
UseChrome bool
}
HeadlessOpts contains options for headless templates
type InteractshOpts ¶
type InteractshOpts interactsh.Options
InteractshOpts contains options for interactsh
type NetworkConfig ¶
type NetworkConfig struct {
DisableMaxHostErr bool // Disable max host error optimization (Hosts are not skipped even if they are not responding)
Interface string // Interface to use for network scan
InternalResolversList []string // Use a list of resolver
LeaveDefaultPorts bool // Leave default ports for http/https
MaxHostError int // Maximum number of host errors to allow before skipping that host
Retries int // Number of retries
SourceIP string // SourceIP sets custom source IP address for network requests
SystemResolvers bool // Use system resolvers
Timeout int // Timeout in seconds
TrackError []string // Adds given errors to max host error watchlist
}
NetworkConfig contains network config options ex: retries , httpx probe , timeout etc
type NucleiEngine ¶
type NucleiEngine struct {
// Logger instance for the engine
Logger *gologger.Logger
// contains filtered or unexported fields
}
NucleiEngine is the Engine/Client for nuclei which runs scans using templates and returns results
Example ¶
A very simple example on how to use nuclei engine
package main
import (
nuclei "github.com/projectdiscovery/nuclei/v3/lib"
)
func main() {
// create nuclei engine with options
ne, err := nuclei.NewNucleiEngine(
nuclei.WithTemplateFilters(nuclei.TemplateFilters{IDs: []string{"self-signed-ssl"}}), // only run self-signed-ssl template
)
if err != nil {
panic(err)
}
// load targets and optionally probe non http/https targets
ne.LoadTargets([]string{"scanme.sh"}, false)
// when callback is nil it nuclei will print JSON output to stdout
err = ne.ExecuteWithCallback(nil)
if err != nil {
panic(err)
}
defer ne.Close()
}
Output: [self-signed-ssl] scanme.sh:443
func NewNucleiEngine
deprecated
func NewNucleiEngine(options ...NucleiSDKOptions) (*NucleiEngine, error)
Deprecated: use NewNucleiEngineCtx instead
func NewNucleiEngineCtx ¶ added in v3.2.9
func NewNucleiEngineCtx(ctx context.Context, options ...NucleiSDKOptions) (*NucleiEngine, error)
NewNucleiEngineCtx creates a new nuclei engine instance with given context
func (*NucleiEngine) Close ¶
func (e *NucleiEngine) Close()
Close all resources used by nuclei engine
func (*NucleiEngine) Engine ¶ added in v3.2.5
func (e *NucleiEngine) Engine() *core.Engine
Engine returns core Executer of nuclei
func (*NucleiEngine) ExecuteCallbackWithCtx ¶ added in v3.2.7
func (e *NucleiEngine) ExecuteCallbackWithCtx(ctx context.Context, callback ...func(event *output.ResultEvent)) error
ExecuteCallbackWithCtx executes templates on targets and calls callback on each result(only if results are found) enable matcher-status option if you expect this callback to be called for all results regardless if it matched or not
func (*NucleiEngine) ExecuteWithCallback ¶
func (e *NucleiEngine) ExecuteWithCallback(callback ...func(event *output.ResultEvent)) error
ExecuteWithCallback is same as ExecuteCallbackWithCtx but with default context Note this is deprecated and will be removed in future major release
func (*NucleiEngine) GetAllClusterMappings ¶ added in v3.7.1
func (e *NucleiEngine) GetAllClusterMappings() map[string][]string
GetAllClusterMappings returns all cluster mappings Returns nil if engine hasn't executed yet
func (*NucleiEngine) GetClusterTemplateIDs ¶ added in v3.7.1
func (e *NucleiEngine) GetClusterTemplateIDs(clusterID string) []string
GetClusterTemplateIDs returns the template IDs for a given cluster ID Returns nil if the cluster ID doesn't exist or engine hasn't executed yet
func (*NucleiEngine) GetExecuterOptions ¶ added in v3.0.3
func (e *NucleiEngine) GetExecuterOptions() *protocols.ExecutorOptions
GetExecuterOptions returns the nuclei executor options
func (*NucleiEngine) GetParser ¶ added in v3.4.8
func (e *NucleiEngine) GetParser() *templates.Parser
GetParser returns the template parser with cache
func (*NucleiEngine) GetTemplates ¶
func (e *NucleiEngine) GetTemplates() []*templates.Template
GetTemplates returns all nuclei templates that are loaded
func (*NucleiEngine) GetWorkflows ¶ added in v3.3.6
func (e *NucleiEngine) GetWorkflows() []*templates.Template
GetWorkflows returns all nuclei workflows that are loaded
func (*NucleiEngine) LoadAllTemplates ¶
func (e *NucleiEngine) LoadAllTemplates() error
LoadAllTemplates loads all nuclei template based on given options
func (*NucleiEngine) LoadTargets ¶
func (e *NucleiEngine) LoadTargets(targets []string, probeNonHttp bool)
LoadTargets(urls/domains/ips only) adds targets to the nuclei engine
func (*NucleiEngine) LoadTargetsFromReader ¶
func (e *NucleiEngine) LoadTargetsFromReader(reader io.Reader, probeNonHttp bool)
LoadTargetsFromReader adds targets(urls/domains/ips only) from reader to the nuclei engine
func (*NucleiEngine) LoadTargetsWithHttpData ¶ added in v3.2.0
func (e *NucleiEngine) LoadTargetsWithHttpData(filePath string, filemode string) error
LoadTargetsWithHttpData loads targets that contain http data from file it currently supports multiple formats like burp xml,openapi,swagger,proxify json Note: this is mutually exclusive with LoadTargets and LoadTargetsFromReader
func (*NucleiEngine) Options ¶ added in v3.2.5
func (e *NucleiEngine) Options() *types.Options
Options return nuclei Type Options
func (*NucleiEngine) ParseTemplate ¶ added in v3.0.3
func (e *NucleiEngine) ParseTemplate(data []byte) (*templates.Template, error)
ParseTemplate parses a template from given data template verification status can be accessed from template.Verified
func (*NucleiEngine) SignTemplate ¶ added in v3.0.3
func (e *NucleiEngine) SignTemplate(tmplSigner *signer.TemplateSigner, data []byte) ([]byte, error)
SignTemplate signs the tempalate using given signer
func (*NucleiEngine) Store ¶ added in v3.3.6
func (e *NucleiEngine) Store() *loader.Store
Store returns store of nuclei
type NucleiSDKOptions ¶
type NucleiSDKOptions func(e *NucleiEngine) error
NucleiSDKOptions contains options for nuclei SDK
func DisableTemplateCache ¶ added in v3.4.8
func DisableTemplateCache() NucleiSDKOptions
DisableTemplateCache disables template caching
func DisableUpdateCheck ¶ added in v3.3.0
func DisableUpdateCheck() NucleiSDKOptions
DisableUpdateCheck disables nuclei update check
func EnableCodeTemplates ¶ added in v3.0.4
func EnableCodeTemplates() NucleiSDKOptions
EnableCodeTemplates allows loading/executing code protocol templates
func EnableFileTemplates ¶ added in v3.3.6
func EnableFileTemplates() NucleiSDKOptions
EnableFileTemplates allows loading/executing file protocol templates
func EnableGlobalMatchersTemplates ¶ added in v3.3.7
func EnableGlobalMatchersTemplates() NucleiSDKOptions
EnableGlobalMatchersTemplates allows loading/executing global-matchers templates
func EnableHeadlessWithOpts ¶
func EnableHeadlessWithOpts(hopts *HeadlessOpts) NucleiSDKOptions
EnableHeadless allows execution of headless templates
Warning: enabling headless mode may open up attack surface due to browser usage and can be prone to exploitation by custom unverified templates if not properly configured.
func EnableMatcherStatus ¶ added in v3.4.5
func EnableMatcherStatus() NucleiSDKOptions
EnableMatcherStatus allows enabling matcher status
func EnablePassiveMode ¶ added in v3.1.9
func EnablePassiveMode() NucleiSDKOptions
EnablePassiveMode allows enabling passive HTTP response processing mode
func EnableSelfContainedTemplates ¶ added in v3.3.6
func EnableSelfContainedTemplates() NucleiSDKOptions
EnableSelfContainedTemplates allows loading/executing self-contained templates
func EnableStatsWithOpts ¶
func EnableStatsWithOpts(opts StatsOptions) NucleiSDKOptions
EnableStats enables Stats collection with defined interval(in sec) and callback Note: callback is executed in a separate goroutine
func LoadSecretsFromFile ¶ added in v3.2.0
func LoadSecretsFromFile(files []string, prefetch bool) NucleiSDKOptions
LoadSecretsFromFile allows loading secrets from file
func SignedTemplatesOnly ¶ added in v3.2.3
func SignedTemplatesOnly() NucleiSDKOptions
SignedTemplatesOnly only run signed templates and disabled loading all unsigned templates
func UseOutputWriter ¶
func UseOutputWriter(writer OutputWriter) NucleiSDKOptions
UseOutputWriter allows setting custom output writer by default a mock writer is used with user defined callback if outputWriter is used callback will be ignored
func UseStatsWriter ¶
func UseStatsWriter(writer StatsWriter) NucleiSDKOptions
UseStatsWriter allows setting a custom stats writer which can be used to write stats somewhere (ex: send to webserver etc)
func WithAuthProvider ¶ added in v3.2.0
func WithAuthProvider(provider authprovider.AuthProvider) NucleiSDKOptions
WithAuthProvider allows setting a custom authprovider implementation
func WithCatalog ¶ added in v3.2.5
func WithCatalog(cat catalog.Catalog) NucleiSDKOptions
WithCatalog uses a supplied catalog
func WithConcurrency ¶
func WithConcurrency(opts Concurrency) NucleiSDKOptions
WithConcurrency sets concurrency options
func WithConfigBytes ¶ added in v3.9.0
func WithConfigBytes(data []byte) NucleiSDKOptions
WithConfigBytes is WithConfigFile from memory.
func WithConfigFile ¶ added in v3.9.0
func WithConfigFile(path string) NucleiSDKOptions
WithConfigFile decodes a RuntimeConfig YAML at path and merges it into the engine options. Matches the schema Aurora server emits.
Example ¶
ExampleWithConfigFile ingests a RuntimeConfig YAML (tags, severity, exclude-tags, headers, vars, etc.) and merges it into the engine options.
package main
import (
nuclei "github.com/projectdiscovery/nuclei/v3/lib"
)
func main() {
ne, err := nuclei.NewNucleiEngine(
nuclei.WithConfigFile("nuclei.yaml"),
nuclei.WithTemplateFilters(nuclei.TemplateFilters{IDs: []string{"self-signed-ssl"}}),
)
if err != nil {
panic(err)
}
defer ne.Close()
ne.LoadTargets([]string{"scanme.sh"}, false)
if err := ne.ExecuteWithCallback(nil); err != nil {
panic(err)
}
}
Output:
func WithGlobalRateLimit ¶
func WithGlobalRateLimit(maxTokens int, duration time.Duration) NucleiSDKOptions
WithGlobalRateLimit sets global rate (i.e all hosts combined) limit options Deprecated: will be removed in favour of WithGlobalRateLimitCtx in next release
func WithGlobalRateLimitCtx ¶ added in v3.2.9
func WithGlobalRateLimitCtx(ctx context.Context, maxTokens int, duration time.Duration) NucleiSDKOptions
WithGlobalRateLimitCtx allows setting a global rate limit for the entire engine
func WithHeaders ¶ added in v3.1.6
func WithHeaders(headers []string) NucleiSDKOptions
WithHeaders allows setting custom header/cookie to include in all http request in header:value format
func WithInteractshOptions ¶
func WithInteractshOptions(opts InteractshOpts) NucleiSDKOptions
WithInteractshOptions sets interactsh options
func WithLogger ¶ added in v3.4.8
func WithLogger(logger *gologger.Logger) NucleiSDKOptions
WithLogger allows setting a shared gologger instance
func WithNetworkConfig ¶
func WithNetworkConfig(opts NetworkConfig) NucleiSDKOptions
WithNetworkConfig allows setting network config options
func WithOptions ¶ added in v3.4.8
func WithOptions(opts *pkgtypes.Options) NucleiSDKOptions
WithOptions sets all options at once
func WithPDCPUpload ¶ added in v3.9.0
func WithPDCPUpload(scanID, teamID string) NucleiSDKOptions
WithPDCPUpload uploads findings to the PDCP dashboard, matching the CLI's `-dashboard -scan-id -team-id`. Credentials come from PDCP_API_KEY or ~/.config/nuclei/.pdcp/credentials.yaml; missing creds log a warning and scans continue. A non-empty scanID implicitly enables upload.
Example ¶
ExampleWithPDCPUpload uploads findings to the PDCP dashboard from SDK code, matching `-dashboard -scan-id -team-id` on the CLI. Pass an existing scanID to append; pass empty to let the server create a new scan.
package main
import (
nuclei "github.com/projectdiscovery/nuclei/v3/lib"
)
func main() {
ne, err := nuclei.NewNucleiEngine(
nuclei.WithTemplateFilters(nuclei.TemplateFilters{IDs: []string{"self-signed-ssl"}}),
nuclei.WithPDCPUpload("" /* scanID */, "" /* teamID, "" = personal */),
)
if err != nil {
panic(err)
}
defer ne.Close()
ne.LoadTargets([]string{"scanme.sh"}, false)
if err := ne.ExecuteWithCallback(nil); err != nil {
panic(err)
}
}
Output:
func WithProxy ¶
func WithProxy(proxy []string, proxyInternalRequests bool) NucleiSDKOptions
WithProxy allows setting proxy options
func WithReportingConfigBytes ¶ added in v3.9.0
func WithReportingConfigBytes(data []byte) NucleiSDKOptions
WithReportingConfigBytes is WithReportingConfigFile from memory. Passing nil/empty produces an empty reporting.Options (no-op).
func WithReportingConfigFile ¶ added in v3.9.0
func WithReportingConfigFile(path string) NucleiSDKOptions
WithReportingConfigFile loads a nuclei -report-config style YAML file (Jira/Linear/GitHub/etc. tracker configuration) into the engine's reporting options. Equivalent to -report-config <path> on the CLI.
func WithResponseReadSize ¶ added in v3.3.9
func WithResponseReadSize(responseReadSize int) NucleiSDKOptions
WithResponseReadSize sets the maximum size of response to read in bytes. A value of 0 means no limit. Recommended values: 1MB (1048576) to 10MB (10485760).
func WithResultCallback ¶ added in v3.11.1
func WithResultCallback(callback func(event *output.ResultEvent)) NucleiSDKOptions
WithResultCallback sets a result callback invoked for each finding.
When used with ThreadSafeNucleiEngine.ExecuteNucleiWithOpts / ExecuteNucleiWithOptsCtx, the callback is scoped to that execution only (combined with any GlobalResultCallback). When used at engine construction time, it behaves like the default result callback list.
func WithResumeFile ¶ added in v3.3.10
func WithResumeFile(file string) NucleiSDKOptions
WithResumeFile allows setting a resume file
func WithSandboxOptions ¶
func WithSandboxOptions(allowLocalFileAccess bool, restrictLocalNetworkAccess bool) NucleiSDKOptions
WithSandboxOptions allows setting supported sandbox options
func WithScanStrategy ¶
func WithScanStrategy(strategy string) NucleiSDKOptions
WithScanStrategy allows setting scan strategy options
func WithTemplateFilters ¶
func WithTemplateFilters(filters TemplateFilters) NucleiSDKOptions
WithTemplateFilters sets template filters and only templates matching the filters will be loaded and executed
func WithTemplateUpdateCallback ¶
func WithTemplateUpdateCallback(disableTemplatesAutoUpgrade bool, callback func(newVersion string)) NucleiSDKOptions
WithTemplateUpdateCallback allows setting a callback which will be called when nuclei templates are outdated Note: Nuclei-templates are crucial part of nuclei and using outdated templates or nuclei sdk is not recommended as it may cause unexpected results due to compatibility issues
func WithTemplatesOrWorkflows ¶
func WithTemplatesOrWorkflows(sources TemplateSources) NucleiSDKOptions
WithTemplatesOrWorkflows sets templates / workflows to use /load
func WithTemporaryDirectory ¶ added in v3.6.0
func WithTemporaryDirectory(parentDir string) NucleiSDKOptions
WithTemporaryDirectory allows setting a parent directory for SDK-managed temporary files. A temporary directory will be created inside the provided directory and cleaned up on engine close. If not set, a temporary directory will be automatically created in the system temp location. The parent directory is assumed to exist.
func WithVars ¶ added in v3.3.6
func WithVars(vars []string) NucleiSDKOptions
WithVars allows setting custom variables to use in templates/workflows context
func WithVerbosity ¶
func WithVerbosity(opts VerbosityOptions) NucleiSDKOptions
WithVerbosity allows setting verbosity options of (internal) nuclei engine and does not affect SDK output
type RuntimeConfig ¶ added in v3.9.0
type RuntimeConfig struct {
Authors []string `yaml:"author,omitempty"`
Tags []string `yaml:"tags,omitempty"`
ExcludeTags []string `yaml:"exclude-tags,omitempty"`
IncludeTags []string `yaml:"include-tags,omitempty"`
IncludeIds []string `yaml:"template-id,omitempty"`
ExcludeIds []string `yaml:"exclude-id,omitempty"`
IncludeTemplates []string `yaml:"include-templates,omitempty"`
ExcludedTemplates []string `yaml:"exclude-templates,omitempty"`
ExcludeMatchers []string `yaml:"exclude-matchers,omitempty"`
Severities []string `yaml:"severity,omitempty"`
ExcludeSeverities []string `yaml:"exclude-severity,omitempty"`
Protocols []string `yaml:"type,omitempty"`
ExcludeProtocols []string `yaml:"exclude-type,omitempty"`
IncludeConditions []string `yaml:"template-condition,omitempty"`
Headers []string `yaml:"header,omitempty"`
Variables []string `yaml:"var,omitempty"`
InteractshServer string `yaml:"interactsh-server,omitempty"`
InteractshToken string `yaml:"interactsh-token,omitempty"`
Socks5Proxy []string `yaml:"socks5-proxy,omitempty"`
// Scalar knobs use *int so omitted YAML keys preserve the engine's
// existing value instead of forcing it to zero.
RateLimit *int `yaml:"rate-limit,omitempty"`
BulkSize *int `yaml:"bulk-size,omitempty"`
Concurrency *int `yaml:"concurrency,omitempty"` // maps to opts.TemplateThreads
Timeout *int `yaml:"timeout,omitempty"`
Retries *int `yaml:"retries,omitempty"`
RateLimitHost *int `yaml:"rate-limit-host,omitempty"`
}
RuntimeConfig is the set of nuclei config options exposed via the SDK.
func (*RuntimeConfig) MergeOptions ¶ added in v3.9.0
func (s *RuntimeConfig) MergeOptions(opts *pkgtypes.Options)
MergeOptions appends/sets the configuration onto opts.
RateLimitHost is stored on the struct for downstream consumers but is NOT applied to *types.Options — there is no equivalent field on nuclei's runtime options today. Callers needing per-host rate limiting must wire it outside the engine.
type StatsOptions ¶
StatsOptions
type TemplateFilters ¶
type TemplateFilters struct {
Severity string // filter by severities (accepts CSV values of info, low, medium, high, critical)
ExcludeSeverities string // filter by excluding severities (accepts CSV values of info, low, medium, high, critical)
ProtocolTypes string // filter by protocol types
ExcludeProtocolTypes string // filter by excluding protocol types
Authors []string // filter by author
Tags []string // filter by tags present in template
ExcludeTags []string // filter by excluding tags present in template
IncludeTags []string // filter by including tags present in template
IDs []string // filter by template IDs
ExcludeIDs []string // filter by excluding template IDs
TemplateCondition []string // DSL condition/ expression
}
config contains all SDK configuration options
type TemplateSources ¶
type TemplateSources struct {
Templates []string // template file/directory paths
Workflows []string // workflow file/directory paths
RemoteTemplates []string // remote template urls
RemoteWorkflows []string // remote workflow urls
TrustedDomains []string // trusted domains for remote templates/workflows
}
TemplateSources contains template sources which define where to load templates from
type ThreadSafeNucleiEngine ¶
type ThreadSafeNucleiEngine struct {
// contains filtered or unexported fields
}
ThreadSafeNucleiEngine is a tweaked version of nuclei.Engine whose methods are thread-safe and can be used concurrently. Non-thread-safe methods start with Global prefix
Example ¶
package main
import (
nuclei "github.com/projectdiscovery/nuclei/v3/lib"
"github.com/remeh/sizedwaitgroup"
)
func main() {
// create nuclei engine with options
ne, err := nuclei.NewThreadSafeNucleiEngine()
if err != nil {
panic(err)
}
// setup sizedWaitgroup to handle concurrency
// here we are using sizedWaitgroup to limit concurrency to 1
// but can be anything in general
sg := sizedwaitgroup.New(1)
// scan 1 = run dns templates on scanme.sh
sg.Add()
go func() {
defer sg.Done()
err = ne.ExecuteNucleiWithOpts([]string{"scanme.sh"},
nuclei.WithTemplateFilters(nuclei.TemplateFilters{IDs: []string{"nameserver-fingerprint"}}), // only run self-signed-ssl template
)
if err != nil {
panic(err)
}
}()
// scan 2 = run dns templates on honey.scanme.sh
sg.Add()
go func() {
defer sg.Done()
err = ne.ExecuteNucleiWithOpts([]string{"honey.scanme.sh"}, nuclei.WithTemplateFilters(nuclei.TemplateFilters{ProtocolTypes: "dns"}))
if err != nil {
panic(err)
}
}()
// wait for all scans to finish
sg.Wait()
defer ne.Close()
}
Output: [nameserver-fingerprint] scanme.sh [caa-fingerprint] honey.scanme.sh
func NewThreadSafeNucleiEngine
deprecated
func NewThreadSafeNucleiEngine(opts ...NucleiSDKOptions) (*ThreadSafeNucleiEngine, error)
Deprecated: use NewThreadSafeNucleiEngineCtx instead
func NewThreadSafeNucleiEngineCtx ¶ added in v3.2.9
func NewThreadSafeNucleiEngineCtx(ctx context.Context, opts ...NucleiSDKOptions) (*ThreadSafeNucleiEngine, error)
NewThreadSafeNucleiEngine creates a new nuclei engine with given options whose methods are thread-safe and can be used concurrently Note: Non-thread-safe methods start with Global prefix
func (*ThreadSafeNucleiEngine) Close ¶
func (e *ThreadSafeNucleiEngine) Close()
Close all resources used by nuclei engine
func (*ThreadSafeNucleiEngine) ExecuteNucleiWithOpts ¶
func (e *ThreadSafeNucleiEngine) ExecuteNucleiWithOpts(targets []string, opts ...NucleiSDKOptions) error
ExecuteNucleiWithOpts is same as ExecuteNucleiWithOptsCtx but with default context This is a placeholder and will be deprecated in future major release
func (*ThreadSafeNucleiEngine) ExecuteNucleiWithOptsCtx ¶ added in v3.2.7
func (e *ThreadSafeNucleiEngine) ExecuteNucleiWithOptsCtx(ctx context.Context, targets []string, opts ...NucleiSDKOptions) error
ExecuteNucleiWithOptsCtx executes templates on targets and can be called concurrently. Pass WithResultCallback in opts for a per-execution result callback (combined with any GlobalResultCallback). Not all options are thread-safe.
func (*ThreadSafeNucleiEngine) GlobalLoadAllTemplates ¶
func (e *ThreadSafeNucleiEngine) GlobalLoadAllTemplates() error
GlobalLoadAllTemplates loads all templates from nuclei-templates repo This method will load all templates based on filters given at the time of nuclei engine creation in opts
func (*ThreadSafeNucleiEngine) GlobalResultCallback ¶
func (e *ThreadSafeNucleiEngine) GlobalResultCallback(callback func(event *output.ResultEvent))
GlobalResultCallback sets a callback function which will be called for each result across all ExecuteNucleiWithOpts invocations. For a callback scoped to a single execution, pass WithResultCallback in that call's opts instead.
type VerbosityOptions ¶
type VerbosityOptions struct {
Verbose bool // show verbose output
Silent bool // show only results
Debug bool // show debug output
DebugRequest bool // show request in debug output
DebugResponse bool // show response in debug output
ShowVarDump bool // show variable dumps in output
}
VerbosityOptions