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