mirror of https://github.com/daffainfo/nuclei.git
Fixed a crash with http module (#1285)
parent
1851e37aef
commit
dfe284664c
|
@ -405,6 +405,7 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
|
||||||
}
|
}
|
||||||
|
|
||||||
var dumpedResponse []redirectedResponse
|
var dumpedResponse []redirectedResponse
|
||||||
|
var gotData []byte
|
||||||
// If the status code is HTTP 101, we should not proceed with reading body.
|
// If the status code is HTTP 101, we should not proceed with reading body.
|
||||||
if resp.StatusCode != http.StatusSwitchingProtocols {
|
if resp.StatusCode != http.StatusSwitchingProtocols {
|
||||||
var bodyReader io.Reader
|
var bodyReader io.Reader
|
||||||
|
@ -422,6 +423,7 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
|
||||||
return errors.Wrap(err, "could not read http body")
|
return errors.Wrap(err, "could not read http body")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gotData = data
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
|
||||||
dumpedResponse, err = dumpResponseWithRedirectChain(resp, data)
|
dumpedResponse, err = dumpResponseWithRedirectChain(resp, data)
|
||||||
|
@ -432,14 +434,17 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
|
||||||
dumpedResponse = []redirectedResponse{{fullResponse: dumpedResponseHeaders, headers: dumpedResponseHeaders}}
|
dumpedResponse = []redirectedResponse{{fullResponse: dumpedResponseHeaders, headers: dumpedResponseHeaders}}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, response := range dumpedResponse {
|
// if nuclei-project is enabled store the response if not previously done
|
||||||
// if nuclei-project is enabled store the response if not previously done
|
if request.options.ProjectFile != nil && !fromCache {
|
||||||
if request.options.ProjectFile != nil && !fromCache {
|
if err := request.options.ProjectFile.Set(dumpedRequest, resp, gotData); err != nil {
|
||||||
if err := request.options.ProjectFile.Set(dumpedRequest, resp, response.body); err != nil {
|
return errors.Wrap(err, "could not store in project file")
|
||||||
return errors.Wrap(err, "could not store in project file")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, response := range dumpedResponse {
|
||||||
|
if response.resp == nil {
|
||||||
|
continue // Skip nil responses
|
||||||
|
}
|
||||||
matchedURL := reqURL
|
matchedURL := reqURL
|
||||||
if generatedRequest.rawRequest != nil && generatedRequest.rawRequest.FullURL != "" {
|
if generatedRequest.rawRequest != nil && generatedRequest.rawRequest.FullURL != "" {
|
||||||
matchedURL = generatedRequest.rawRequest.FullURL
|
matchedURL = generatedRequest.rawRequest.FullURL
|
||||||
|
|
Loading…
Reference in New Issue