mirror of https://github.com/daffainfo/nuclei.git
Added type to specify type of request
parent
f5435e6c9a
commit
4e48a5f147
|
@ -12,7 +12,7 @@ type Log interface {
|
|||
// Close closes the log interface flushing data
|
||||
Close()
|
||||
// Request writes a log the requests trace log
|
||||
Request(templateID, url string, err error)
|
||||
Request(templateID, url, Type string, err error)
|
||||
}
|
||||
|
||||
// NoopLogger is a noop logger that simply does nothing
|
||||
|
@ -22,7 +22,7 @@ type NoopLogger struct{}
|
|||
func (n *NoopLogger) Close() {}
|
||||
|
||||
// Request writes a log the requests trace log
|
||||
func (n *NoopLogger) Request(templateID, url string, err error) {}
|
||||
func (n *NoopLogger) Request(templateID, url, Type string, err error) {}
|
||||
|
||||
// FileLogger is a trace logger that writes request logs to a file.
|
||||
type FileLogger struct {
|
||||
|
@ -53,13 +53,15 @@ type JSONRequest struct {
|
|||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Error string `json:"error"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// Request writes a log the requests trace log
|
||||
func (f *FileLogger) Request(templateID, url string, err error) {
|
||||
func (f *FileLogger) Request(templateID, url, Type string, err error) {
|
||||
request := &JSONRequest{
|
||||
ID: templateID,
|
||||
URL: url,
|
||||
ID: templateID,
|
||||
URL: url,
|
||||
Type: Type,
|
||||
}
|
||||
if err != nil {
|
||||
request.Error = err.Error()
|
||||
|
|
|
@ -98,14 +98,14 @@ func (e *DNSExecuter) ExecuteDNS(p progress.IProgress, reqURL string) *Result {
|
|||
// Compile each request for the template based on the URL
|
||||
compiledRequest, err := e.dnsRequest.MakeDNSRequest(domain)
|
||||
if err != nil {
|
||||
e.traceLog.Request(e.template.ID, domain, err)
|
||||
e.traceLog.Request(e.template.ID, domain, "dns", err)
|
||||
result.Error = errors.Wrap(err, "could not make dns request")
|
||||
|
||||
p.Drop(1)
|
||||
|
||||
return result
|
||||
}
|
||||
e.traceLog.Request(e.template.ID, domain, nil)
|
||||
e.traceLog.Request(e.template.ID, domain, "dns", nil)
|
||||
|
||||
if e.debug {
|
||||
gologger.Infof("Dumped DNS request for %s (%s)\n\n", reqURL, e.template.ID)
|
||||
|
|
|
@ -176,11 +176,11 @@ func (e *HTTPExecuter) ExecuteParallelHTTP(p progress.IProgress, reqURL string)
|
|||
// If the request was built correctly then execute it
|
||||
err := e.handleHTTP(reqURL, httpRequest, dynamicvalues, result)
|
||||
if err != nil {
|
||||
e.traceLog.Request(e.template.ID, reqURL, err)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", err)
|
||||
result.Error = errors.Wrap(err, "could not handle http request")
|
||||
p.Drop(remaining)
|
||||
} else {
|
||||
e.traceLog.Request(e.template.ID, reqURL, nil)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", nil)
|
||||
}
|
||||
}(request)
|
||||
}
|
||||
|
@ -248,11 +248,11 @@ func (e *HTTPExecuter) ExecuteTurboHTTP(p progress.IProgress, reqURL string) *Re
|
|||
request.PipelineClient = pipeclient
|
||||
err = e.handleHTTP(reqURL, httpRequest, dynamicvalues, result)
|
||||
if err != nil {
|
||||
e.traceLog.Request(e.template.ID, reqURL, err)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", err)
|
||||
result.Error = errors.Wrap(err, "could not handle http request")
|
||||
p.Drop(remaining)
|
||||
} else {
|
||||
e.traceLog.Request(e.template.ID, reqURL, nil)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", nil)
|
||||
}
|
||||
request.PipelineClient = nil
|
||||
}(request)
|
||||
|
@ -305,9 +305,9 @@ func (e *HTTPExecuter) ExecuteHTTP(p progress.IProgress, reqURL string) *Result
|
|||
if err != nil {
|
||||
result.Error = errors.Wrap(err, "could not handle http request")
|
||||
p.Drop(remaining)
|
||||
e.traceLog.Request(e.template.ID, reqURL, err)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", err)
|
||||
} else {
|
||||
e.traceLog.Request(e.template.ID, reqURL, nil)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,10 +353,10 @@ func (e *HTTPExecuter) handleHTTP(reqURL string, request *requests.HTTPRequest,
|
|||
if resp != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
e.traceLog.Request(e.template.ID, reqURL, err)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", err)
|
||||
return err
|
||||
}
|
||||
e.traceLog.Request(e.template.ID, reqURL, nil)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", nil)
|
||||
} else if request.Unsafe {
|
||||
// rawhttp
|
||||
// burp uses "\r\n" as new line character
|
||||
|
@ -370,10 +370,10 @@ func (e *HTTPExecuter) handleHTTP(reqURL string, request *requests.HTTPRequest,
|
|||
if resp != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
e.traceLog.Request(e.template.ID, reqURL, err)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", err)
|
||||
return err
|
||||
}
|
||||
e.traceLog.Request(e.template.ID, reqURL, nil)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", nil)
|
||||
} else {
|
||||
// retryablehttp
|
||||
resp, err = e.httpClient.Do(request.Request)
|
||||
|
@ -381,10 +381,10 @@ func (e *HTTPExecuter) handleHTTP(reqURL string, request *requests.HTTPRequest,
|
|||
if resp != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
e.traceLog.Request(e.template.ID, reqURL, err)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", err)
|
||||
return err
|
||||
}
|
||||
e.traceLog.Request(e.template.ID, reqURL, nil)
|
||||
e.traceLog.Request(e.template.ID, reqURL, "http", nil)
|
||||
}
|
||||
|
||||
duration := time.Since(timeStart)
|
||||
|
|
Loading…
Reference in New Issue