mirror of https://github.com/daffainfo/nuclei.git
parent
8a40fac305
commit
6a83e55e40
|
@ -91,8 +91,13 @@ func (p *Progress) IncrementMatched() {
|
|||
p.stats.IncrementCounter("matched", 1)
|
||||
}
|
||||
|
||||
// DecrementRequests decrements the number of requests from total.
|
||||
func (p *Progress) DecrementRequests(count int64) {
|
||||
// IncrementErrorsBy increments the error counter by count.
|
||||
func (p *Progress) IncrementErrorsBy(count int64) {
|
||||
p.stats.IncrementCounter("errors", 1)
|
||||
}
|
||||
|
||||
// IncrementFailedRequestsBy increments the number of requests counter by count along with errors.
|
||||
func (p *Progress) IncrementFailedRequestsBy(count int64) {
|
||||
// mimic dropping by incrementing the completed requests
|
||||
p.stats.IncrementCounter("requests", int(count))
|
||||
p.stats.IncrementCounter("errors", int(count))
|
||||
|
|
|
@ -25,7 +25,7 @@ func (r *Request) ExecuteWithResults(input string, metadata, previous output.Int
|
|||
compiledRequest, err := r.Make(domain)
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, domain, "dns", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not build request")
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ func (r *Request) ExecuteWithResults(input string, metadata, previous output.Int
|
|||
resp, err := r.dnsClient.Do(compiledRequest)
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, domain, "dns", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not send dns request")
|
||||
}
|
||||
r.options.Progress.IncrementRequests()
|
||||
|
|
|
@ -71,7 +71,7 @@ func (r *Request) ExecuteWithResults(input string, metadata, previous output.Int
|
|||
wg.Wait()
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, input, "file", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not send file request")
|
||||
}
|
||||
r.options.Progress.IncrementRequests()
|
||||
|
|
|
@ -18,7 +18,7 @@ func (r *Request) ExecuteWithResults(input string, metadata, previous output.Int
|
|||
instance, err := r.options.Browser.NewInstance()
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, input, "headless", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could get html element")
|
||||
}
|
||||
defer instance.Close()
|
||||
|
@ -26,13 +26,13 @@ func (r *Request) ExecuteWithResults(input string, metadata, previous output.Int
|
|||
parsed, err := url.Parse(input)
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, input, "headless", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could get html element")
|
||||
}
|
||||
out, page, err := instance.Run(parsed, r.Steps, time.Duration(r.options.Options.PageTimeout)*time.Second)
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, input, "headless", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could get html element")
|
||||
}
|
||||
defer page.Close()
|
||||
|
|
|
@ -68,7 +68,6 @@ func (r *Request) executeRaceRequest(reqURL string, previous output.InternalEven
|
|||
mutex.Lock()
|
||||
if err != nil {
|
||||
requestErr = multierr.Append(requestErr, err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
}
|
||||
mutex.Unlock()
|
||||
}(requests[i])
|
||||
|
@ -95,7 +94,7 @@ func (r *Request) executeParallelHTTP(reqURL string, dynamicValues, previous out
|
|||
break
|
||||
}
|
||||
if err != nil {
|
||||
r.options.Progress.DecrementRequests(int64(generator.Total()))
|
||||
r.options.Progress.IncrementFailedRequestsBy(int64(generator.Total()))
|
||||
return err
|
||||
}
|
||||
swg.Add()
|
||||
|
@ -107,7 +106,6 @@ func (r *Request) executeParallelHTTP(reqURL string, dynamicValues, previous out
|
|||
mutex.Lock()
|
||||
if err != nil {
|
||||
requestErr = multierr.Append(requestErr, err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
}
|
||||
mutex.Unlock()
|
||||
}(request)
|
||||
|
@ -154,7 +152,7 @@ func (r *Request) executeTurboHTTP(reqURL string, dynamicValues, previous output
|
|||
break
|
||||
}
|
||||
if err != nil {
|
||||
r.options.Progress.DecrementRequests(int64(generator.Total()))
|
||||
r.options.Progress.IncrementFailedRequestsBy(int64(generator.Total()))
|
||||
return err
|
||||
}
|
||||
request.pipelinedClient = pipeclient
|
||||
|
@ -167,7 +165,6 @@ func (r *Request) executeTurboHTTP(reqURL string, dynamicValues, previous output
|
|||
mutex.Lock()
|
||||
if err != nil {
|
||||
requestErr = multierr.Append(requestErr, err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
}
|
||||
mutex.Unlock()
|
||||
}(request)
|
||||
|
@ -203,7 +200,7 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
|||
break
|
||||
}
|
||||
if err != nil {
|
||||
r.options.Progress.DecrementRequests(int64(generator.Total()))
|
||||
r.options.Progress.IncrementFailedRequestsBy(int64(generator.Total()))
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -223,7 +220,7 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
|||
r.options.Progress.IncrementRequests()
|
||||
|
||||
if request.original.options.Options.StopAtFirstMatch && gotOutput {
|
||||
r.options.Progress.DecrementRequests(int64(generator.Total()))
|
||||
r.options.Progress.IncrementErrorsBy(int64(generator.Total()))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +297,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
|
|||
resp.Body.Close()
|
||||
}
|
||||
r.options.Output.Request(r.options.TemplateID, reqURL, "http", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementErrorsBy(1)
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
|
|
|
@ -23,7 +23,7 @@ func (r *Request) ExecuteWithResults(input string, metadata, previous output.Int
|
|||
address, err := getAddress(input)
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, input, "network", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not get address from url")
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse
|
|||
if !strings.Contains(actualAddress, ":") {
|
||||
err := errors.New("no port provided in network protocol request")
|
||||
r.options.Output.Request(r.options.TemplateID, address, "network", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse
|
|||
}
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, address, "network", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not connect to server request")
|
||||
}
|
||||
defer conn.Close()
|
||||
|
@ -92,7 +92,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse
|
|||
}
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, address, "network", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not write request to server")
|
||||
}
|
||||
reqBuilder.Grow(len(input.Data))
|
||||
|
@ -101,7 +101,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse
|
|||
_, err = conn.Write(data)
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, address, "network", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not write request to server")
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse
|
|||
}
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, address, "network", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not write request to server")
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, shouldUse
|
|||
n, err := conn.Read(final)
|
||||
if err != nil && err != io.EOF {
|
||||
r.options.Output.Request(r.options.TemplateID, address, "network", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not read from server")
|
||||
}
|
||||
responseBuilder.Write(final[:n])
|
||||
|
|
|
@ -98,7 +98,7 @@ func (r *Request) ExecuteWithResults(input string, metadata, previous output.Int
|
|||
wg.Wait()
|
||||
if err != nil {
|
||||
r.options.Output.Request(r.options.TemplateID, input, "file", err)
|
||||
r.options.Progress.DecrementRequests(1)
|
||||
r.options.Progress.IncrementFailedRequestsBy(1)
|
||||
return errors.Wrap(err, "could not send file request")
|
||||
}
|
||||
r.options.Progress.IncrementRequests()
|
||||
|
|
Loading…
Reference in New Issue