Add optional line number for file templates by default (#1966)

* Add optional line number for file templates by default

* updating docs

* misc flag update

Co-authored-by: mzack <marco.rivoli.nvh@gmail.com>
Co-authored-by: sandeep <sandeep@projectdiscovery.io>
This commit is contained in:
Ice3man 2022-06-02 17:06:50 +05:30 committed by GitHub
parent 4bcb94e4df
commit 2b631e8e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 10 deletions

View File

@ -151,6 +151,7 @@ CONFIGURATIONS:
-cc, -client-cert string client certificate file (PEM-encoded) used for authenticating against scanned hosts
-ck, -client-key string client key file (PEM-encoded) used for authenticating against scanned hosts
-ca, -client-ca string client certificate authority file (PEM-encoded) used for authenticating against scanned hosts
-sml, -show-match-line show match lines for file templates, works with extractors only
-ztls use ztls library with autofallback to standard one for tls13
-sni string tls sni hostname to use (default: input domain name)

View File

@ -154,6 +154,7 @@ on extensive configurability, massive extensibility and ease of use.`)
flagSet.StringVarP(&options.ClientCertFile, "client-cert", "cc", "", "client certificate file (PEM-encoded) used for authenticating against scanned hosts"),
flagSet.StringVarP(&options.ClientKeyFile, "client-key", "ck", "", "client key file (PEM-encoded) used for authenticating against scanned hosts"),
flagSet.StringVarP(&options.ClientCAFile, "client-ca", "ca", "", "client certificate authority file (PEM-encoded) used for authenticating against scanned hosts"),
flagSet.BoolVarP(&options.ShowMatchLine, "show-match-line", "sml", false, "show match lines for file templates, works with extractors only"),
flagSet.BoolVar(&options.ZTLS, "ztls", false, "use ztls library with autofallback to standard one for tls13"),
flagSet.StringVar(&options.SNI, "sni", "", "tls sni hostname to use (default: input domain name)"),
)

View File

@ -303,18 +303,21 @@ func (request *Request) buildEvent(input, filePath string, fileMatches []FileMat
}
event := eventcreator.CreateEventWithOperatorResults(request, internalEvent, operatorResult)
for _, result := range event.Results {
switch {
case result.MatcherName != "":
result.Lines = exprLines[result.MatcherName]
case result.ExtractorName != "":
result.Lines = exprLines[result.ExtractorName]
default:
for _, extractedResult := range result.ExtractedResults {
result.Lines = append(result.Lines, exprLines[extractedResult]...)
// Annotate with line numbers if asked by the user
if request.options.Options.ShowMatchLine {
for _, result := range event.Results {
switch {
case result.MatcherName != "":
result.Lines = exprLines[result.MatcherName]
case result.ExtractorName != "":
result.Lines = exprLines[result.ExtractorName]
default:
for _, extractedResult := range result.ExtractedResults {
result.Lines = append(result.Lines, exprLines[extractedResult]...)
}
}
result.Lines = sliceutil.DedupeInt(result.Lines)
}
result.Lines = sliceutil.DedupeInt(result.Lines)
}
return event
}

View File

@ -208,6 +208,8 @@ type Options struct {
ClientCAFile string
// Use ZTLS library
ZTLS bool
// ShowMatchLine enables display of match line number
ShowMatchLine bool
// EnablePprof enables exposing pprof runtime information with a webserver.
EnablePprof bool
// StoreResponse stores received response to output directory