mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-23 14:25:24 +00:00
final \r\n with body - Fixes #535
This commit is contained in:
parent
d08cd93838
commit
68b3ef8ffa
@ -114,7 +114,11 @@ func (r *requestGenerator) makeHTTPRequestFromModel(ctx context.Context, data st
|
|||||||
|
|
||||||
// makeHTTPRequestFromRaw creates a *http.Request from a raw request
|
// 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) {
|
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 !rawHasBody(data) {
|
||||||
data += "\r\n"
|
data += "\r\n"
|
||||||
|
}
|
||||||
|
|
||||||
return r.handleRawWithPaylods(ctx, data, baseURL, values, payloads)
|
return r.handleRawWithPaylods(ctx, data, baseURL, values, payloads)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
@ -116,3 +118,27 @@ func handleDecompression(resp *http.Response, bodyOrig []byte) (bodyDec []byte,
|
|||||||
}
|
}
|
||||||
return bodyOrig, nil
|
return bodyOrig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rawHasBody checks if a RFC compliant request has the body
|
||||||
|
func rawHasBody(data string) bool {
|
||||||
|
b := bufio.NewReader(strings.NewReader(data))
|
||||||
|
req, err := http.ReadRequest(b)
|
||||||
|
if err == io.EOF {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Body == http.NoBody {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's enough to read a chunk to check the presence of the body
|
||||||
|
body, err := ioutil.ReadAll(io.LimitReader(req.Body, 512))
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return len(body) > 0
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user