mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-11-07 17:43:04 -10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ec818ba3d | ||
|
|
a9286653fe | ||
|
|
aeaad62d28 |
No files matched your search
@@ -316,6 +316,7 @@ on extensive configurability, massive extensibility and ease of use.`)
|
||||
flagSet.RuntimeMapVarP(&options.Vars, "var", "V", nil, "custom vars in key=value format"),
|
||||
flagSet.StringVarP(&options.ResolversFile, "resolvers", "r", "", "file containing resolver list for nuclei"),
|
||||
flagSet.BoolVarP(&options.SystemResolvers, "system-resolvers", "sr", false, "use system DNS resolving as error fallback"),
|
||||
flagSet.BoolVarP(&options.DisableDefaultResolvers, "disable-default-resolvers", "dfr", false, "disable default resolvers"),
|
||||
flagSet.BoolVarP(&options.DisableClustering, "disable-clustering", "dc", false, "disable clustering of requests"),
|
||||
flagSet.BoolVar(&options.OfflineHTTP, "passive", false, "enable passive HTTP response processing mode"),
|
||||
flagSet.BoolVarP(&options.ForceAttemptHTTP2, "force-http2", "fh2", false, "force http2 connection on requests"),
|
||||
|
||||
+43
-11
@@ -72,7 +72,10 @@ type StandardWriter struct {
|
||||
omitTemplate bool
|
||||
DisableStdout bool
|
||||
AddNewLinesOutputFile bool // by default this is only done for stdout
|
||||
KeysToRedact []string
|
||||
keysToRedact []*regexp.Regexp
|
||||
|
||||
RequestCallback func(templateID, url, requestType string, err error)
|
||||
WriteCallback func(o *ResultEvent)
|
||||
}
|
||||
|
||||
var decolorizerRegex = regexp.MustCompile(`\x1B\[[0-9;]*[a-zA-Z]`)
|
||||
@@ -265,8 +268,27 @@ func NewStandardWriter(options *types.Options) (*StandardWriter, error) {
|
||||
storeResponse: options.StoreResponse,
|
||||
storeResponseDir: options.StoreResponseDir,
|
||||
omitTemplate: options.OmitTemplate,
|
||||
KeysToRedact: options.Redact,
|
||||
}
|
||||
for _, key := range options.Redact {
|
||||
keyPattern := regexp.MustCompile(fmt.Sprintf(`(?i)(%s\s*[:=]\s*["']?)[^"'\r\n&]+(["'\r\n]?)`, regexp.QuoteMeta(key)))
|
||||
writer.keysToRedact = append(writer.keysToRedact, keyPattern)
|
||||
}
|
||||
|
||||
return writer, nil
|
||||
}
|
||||
|
||||
func NewStandardWriterWithHooks(
|
||||
options *types.Options,
|
||||
requestCallback func(templateID, url, requestType string, err error),
|
||||
writeCallback func(o *ResultEvent),
|
||||
) (*StandardWriter, error) {
|
||||
writer, err := NewStandardWriter(options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
writer.RequestCallback = requestCallback
|
||||
writer.WriteCallback = writeCallback
|
||||
|
||||
return writer, nil
|
||||
}
|
||||
|
||||
@@ -277,11 +299,12 @@ func (w *StandardWriter) Write(event *ResultEvent) error {
|
||||
event.Template, event.TemplateURL = utils.TemplatePathURL(types.ToString(event.TemplatePath), types.ToString(event.TemplateID), event.TemplateVerifier)
|
||||
}
|
||||
|
||||
if len(w.KeysToRedact) > 0 {
|
||||
event.Request = redactKeys(event.Request, w.KeysToRedact)
|
||||
event.Response = redactKeys(event.Response, w.KeysToRedact)
|
||||
event.CURLCommand = redactKeys(event.CURLCommand, w.KeysToRedact)
|
||||
event.Matched = redactKeys(event.Matched, w.KeysToRedact)
|
||||
if len(w.keysToRedact) > 0 {
|
||||
event.URL = w.redactKeys(event.URL)
|
||||
event.Request = w.redactKeys(event.Request)
|
||||
event.Response = w.redactKeys(event.Response)
|
||||
event.CURLCommand = w.redactKeys(event.CURLCommand)
|
||||
event.Matched = w.redactKeys(event.Matched)
|
||||
}
|
||||
|
||||
event.Timestamp = time.Now()
|
||||
@@ -319,12 +342,15 @@ func (w *StandardWriter) Write(event *ResultEvent) error {
|
||||
_, _ = w.outputFile.Write([]byte("\n"))
|
||||
}
|
||||
}
|
||||
|
||||
if w.WriteCallback != nil {
|
||||
w.WriteCallback(event)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func redactKeys(data string, keysToRedact []string) string {
|
||||
for _, key := range keysToRedact {
|
||||
keyPattern := regexp.MustCompile(fmt.Sprintf(`(?i)(%s\s*[:=]\s*["']?)[^"'\r\n&]+(["'\r\n]?)`, regexp.QuoteMeta(key)))
|
||||
func (w *StandardWriter) redactKeys(data string) string {
|
||||
for _, keyPattern := range w.keysToRedact {
|
||||
data = keyPattern.ReplaceAllString(data, `$1***$2`)
|
||||
}
|
||||
return data
|
||||
@@ -344,7 +370,11 @@ type JSONLogRequest struct {
|
||||
|
||||
// Request writes a log the requests trace log
|
||||
func (w *StandardWriter) Request(templatePath, input, requestType string, requestErr error) {
|
||||
if w.traceFile == nil && w.errorFile == nil {
|
||||
if w.traceFile == nil && w.errorFile == nil && w.RequestCallback == nil {
|
||||
return
|
||||
}
|
||||
if w.RequestCallback != nil {
|
||||
w.RequestCallback(templatePath, input, requestType, requestErr)
|
||||
return
|
||||
}
|
||||
request := &JSONLogRequest{
|
||||
@@ -393,6 +423,7 @@ func (w *StandardWriter) Request(templatePath, input, requestType string, reques
|
||||
if val := errkit.GetAttrValue(requestErr, "address"); val.Any() != nil {
|
||||
request.Address = val.String()
|
||||
}
|
||||
|
||||
data, err := jsoniter.Marshal(request)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -405,6 +436,7 @@ func (w *StandardWriter) Request(templatePath, input, requestType string, reques
|
||||
if requestErr != nil && w.errorFile != nil {
|
||||
_, _ = w.errorFile.Write(data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Colorizer returns the colorizer instance for writer
|
||||
|
||||
@@ -43,6 +43,10 @@ func Init(options *types.Options) error {
|
||||
|
||||
lfaAllowed = options.AllowLocalFileAccess
|
||||
opts := fastdialer.DefaultOptions
|
||||
if options.DisableDefaultResolvers {
|
||||
opts.HostsFile = false
|
||||
opts.ResolversFile = false
|
||||
}
|
||||
opts.DialerTimeout = options.GetTimeouts().DialTimeout
|
||||
if options.DialerKeepAlive > 0 {
|
||||
opts.DialerKeepAlive = options.DialerKeepAlive
|
||||
@@ -134,6 +138,7 @@ func Init(options *types.Options) error {
|
||||
if options.SystemResolvers {
|
||||
opts.ResolversFile = true
|
||||
opts.EnableFallback = true
|
||||
opts.HostsFile = true
|
||||
}
|
||||
if len(options.InternalResolversList) > 0 {
|
||||
opts.BaseResolvers = options.InternalResolversList
|
||||
|
||||
+11
-12
@@ -89,17 +89,17 @@ type TemplateInfo struct {
|
||||
func NewMockExecuterOptions(options *types.Options, info *TemplateInfo) *protocols.ExecutorOptions {
|
||||
progressImpl, _ := progress.NewStatsTicker(0, false, false, false, 0)
|
||||
executerOpts := &protocols.ExecutorOptions{
|
||||
TemplateID: info.ID,
|
||||
TemplateInfo: info.Info,
|
||||
TemplatePath: info.Path,
|
||||
Output: NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
TemplateID: info.ID,
|
||||
TemplateInfo: info.Info,
|
||||
TemplatePath: info.Path,
|
||||
Output: NewMockOutputWriter(options.OmitTemplate),
|
||||
Options: options,
|
||||
Progress: progressImpl,
|
||||
ProjectFile: nil,
|
||||
IssuesClient: nil,
|
||||
Browser: nil,
|
||||
Catalog: disk.NewCatalog(config.DefaultConfig.TemplatesDirectory),
|
||||
RateLimiter: ratelimit.New(context.Background(), uint(options.RateLimit), time.Second),
|
||||
}
|
||||
executerOpts.CreateTemplateCtxStore()
|
||||
return executerOpts
|
||||
@@ -116,7 +116,6 @@ type MockOutputWriter struct {
|
||||
aurora aurora.Aurora
|
||||
omitTemplate bool
|
||||
RequestCallback func(templateID, url, requestType string, err error)
|
||||
FailureCallback func(result *output.InternalEvent)
|
||||
WriteCallback func(o *output.ResultEvent)
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,8 @@ type Options struct {
|
||||
UseInstalledChrome bool
|
||||
// SystemResolvers enables override of nuclei's DNS client opting to use system resolver stack.
|
||||
SystemResolvers bool
|
||||
// DisableDNSResolvers disables default DNS resolvers for nuclei
|
||||
DisableDefaultResolvers bool
|
||||
// ShowActions displays a list of all headless actions
|
||||
ShowActions bool
|
||||
// Deprecated: Enabled by default through clistats . Metrics enables display of metrics via an http endpoint
|
||||
|
||||
Reference in new issue
Block a user