Merge branch 'master' into fix-175-results-highlight

dev
Manuel Bua 2020-07-29 01:24:14 +02:00
commit 7d22f6cfb4
5 changed files with 45 additions and 20 deletions

View File

@ -11,7 +11,7 @@ const banner = `
`
// Version is the current version of nuclei
const Version = `2.0.4`
const Version = `2.0.5`
// showBanner is used to show the banner to the user
func showBanner() {

View File

@ -148,8 +148,10 @@ func New(options *Options) (*Runner, error) {
runner.output = output
}
// Creates the progress tracking object
runner.progress = progress.NewProgress(runner.options.NoColor)
if !options.Silent {
// Creates the progress tracking object
runner.progress = progress.NewProgress(runner.options.NoColor)
}
runner.limiter = make(chan struct{}, options.Threads)
@ -337,8 +339,10 @@ func (r *Runner) RunEnumeration() {
} else if totalRequests > 0 || hasWorkflows {
// track global progress
p.InitProgressbar(r.inputCount, templateCount, totalRequests)
p.StartStdCapture()
if p != nil {
p.InitProgressbar(r.inputCount, templateCount, totalRequests)
p.StartStdCapture()
}
for _, match := range allTemplates {
wgtemplates.Add(1)
@ -364,11 +368,14 @@ func (r *Runner) RunEnumeration() {
}
wgtemplates.Wait()
p.Wait()
p.StopStdCapture()
p.ShowStdErr()
p.ShowStdOut()
if p != nil {
p.Wait()
p.StopStdCapture()
p.ShowStdErr()
p.ShowStdOut()
}
}
if !results.Get() {
@ -434,7 +441,9 @@ func (r *Runner) processTemplateWithList(p *progress.Progress, template *templat
})
}
if err != nil {
p.Drop(request.(*requests.BulkHTTPRequest).GetRequestCount())
if p != nil {
p.Drop(request.(*requests.BulkHTTPRequest).GetRequestCount())
}
gologger.Warningf("Could not create http client: %s\n", err)
return false
}

View File

@ -3,14 +3,14 @@ package executer
import (
"bufio"
"fmt"
"github.com/logrusorgru/aurora"
"github.com/projectdiscovery/nuclei/v2/internal/progress"
"os"
"regexp"
"sync"
"github.com/logrusorgru/aurora"
"github.com/pkg/errors"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v2/internal/progress"
"github.com/projectdiscovery/nuclei/v2/pkg/matchers"
"github.com/projectdiscovery/nuclei/v2/pkg/requests"
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
@ -89,7 +89,9 @@ func (e *DNSExecuter) ExecuteDNS(p *progress.Progress, URL string) (result Resul
compiledRequest, err := e.dnsRequest.MakeDNSRequest(domain)
if err != nil {
result.Error = errors.Wrap(err, "could not make dns request")
p.Drop(1)
if p != nil {
p.Drop(1)
}
return
}
@ -102,11 +104,15 @@ func (e *DNSExecuter) ExecuteDNS(p *progress.Progress, URL string) (result Resul
resp, err := e.dnsClient.Do(compiledRequest)
if err != nil {
result.Error = errors.Wrap(err, "could not send dns request")
p.Drop(1)
if p != nil {
p.Drop(1)
}
return
}
p.Update()
if p != nil {
p.Update()
}
gologger.Verbosef("Sent DNS request to %s\n", "dns-request", URL)

View File

@ -137,12 +137,16 @@ func (e *HTTPExecuter) ExecuteHTTP(p *progress.Progress, URL string) (result Res
err = e.handleHTTP(p, URL, httpRequest, dynamicvalues, &result)
if err != nil {
result.Error = errors.Wrap(err, "could not handle http request")
p.Drop(remaining)
if p != nil {
p.Drop(remaining)
}
return
}
e.bulkHttpRequest.Increment(URL)
p.Update()
if p != nil {
p.Update()
}
remaining--
}

View File

@ -57,7 +57,9 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
for _, template := range n.Templates {
p := template.Progress
if template.HTTPOptions != nil {
p.AddToTotal(template.HTTPOptions.Template.GetHTTPRequestCount())
if p != nil {
p.AddToTotal(template.HTTPOptions.Template.GetHTTPRequestCount())
}
for _, request := range template.HTTPOptions.Template.BulkRequestsHTTP {
// apply externally supplied payloads if any
request.Headers = generators.MergeMapsWithStrings(request.Headers, headers)
@ -66,7 +68,9 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
template.HTTPOptions.BulkHttpRequest = request
httpExecuter, err := executer.NewHTTPExecuter(template.HTTPOptions)
if err != nil {
p.Drop(request.GetRequestCount())
if p != nil {
p.Drop(request.GetRequestCount())
}
gologger.Warningf("Could not compile request for template '%s': %s\n", template.HTTPOptions.Template.ID, err)
continue
}
@ -84,7 +88,9 @@ func (n *NucleiVar) Call(args ...tengo.Object) (ret tengo.Object, err error) {
}
if template.DNSOptions != nil {
p.AddToTotal(template.DNSOptions.Template.GetDNSRequestCount())
if p != nil {
p.AddToTotal(template.DNSOptions.Template.GetDNSRequestCount())
}
for _, request := range template.DNSOptions.Template.RequestsDNS {
template.DNSOptions.DNSRequest = request
dnsExecuter := executer.NewDNSExecuter(template.DNSOptions)