mirror of https://github.com/daffainfo/nuclei.git
Fixed raw http newline formatting
parent
d541b09928
commit
a86bc9e586
|
@ -114,12 +114,6 @@ func (r *requestGenerator) makeHTTPRequestFromModel(ctx context.Context, data st
|
|||
|
||||
// makeHTTPRequestFromRaw creates a *http.Request from a raw request
|
||||
func (r *requestGenerator) makeHTTPRequestFromRaw(ctx context.Context, baseURL, data string, values, payloads map[string]interface{}) (*generatedRequest, error) {
|
||||
// Add "\r\n" only to RCF compliant requests without body
|
||||
if !r.request.Unsafe && !rawHasBody(data) {
|
||||
data += "\r\n"
|
||||
} else {
|
||||
data = strings.TrimSuffix(data, "\r\n")
|
||||
}
|
||||
return r.handleRawWithPaylods(ctx, data, baseURL, values, payloads)
|
||||
}
|
||||
|
||||
|
@ -178,6 +172,9 @@ func (r *requestGenerator) handleRawWithPaylods(ctx context.Context, rawRequest,
|
|||
return nil, err
|
||||
}
|
||||
for key, value := range rawRequestData.Headers {
|
||||
if key == "" {
|
||||
continue
|
||||
}
|
||||
req.Header[key] = []string{value}
|
||||
}
|
||||
request, err := r.fillRequest(req, values)
|
||||
|
|
|
@ -49,6 +49,7 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) {
|
|||
// Set the request Method
|
||||
rawRequest.Method = parts[0]
|
||||
|
||||
var mutlipartRequest bool
|
||||
// Accepts all malformed headers
|
||||
var key, value string
|
||||
for {
|
||||
|
@ -66,6 +67,9 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) {
|
|||
if len(p) > 1 {
|
||||
value = p[1]
|
||||
}
|
||||
if strings.Contains(key, "Content-Type") && strings.Contains(value, "multipart/") {
|
||||
mutlipartRequest = true
|
||||
}
|
||||
|
||||
// in case of unsafe requests multiple headers should be accepted
|
||||
// therefore use the full line as key
|
||||
|
@ -127,5 +131,8 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) {
|
|||
return nil, fmt.Errorf("could not read request body: %s", err)
|
||||
}
|
||||
rawRequest.Data = string(b)
|
||||
if !mutlipartRequest {
|
||||
rawRequest.Data = strings.TrimSuffix(rawRequest.Data, "\r\n")
|
||||
}
|
||||
return rawRequest, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue