mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 21:05:24 +00:00
Fix can't set user agent in templates
This commit is contained in:
parent
781a71e3d5
commit
7f82270ea7
@ -11,6 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/corpix/uarand"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/expressions"
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/expressions"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/generators"
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/generators"
|
||||||
@ -182,7 +183,7 @@ func (r *requestGenerator) fillRequest(req *http.Request, values map[string]inte
|
|||||||
if r.request.Body != "" {
|
if r.request.Body != "" {
|
||||||
req.Body = ioutil.NopCloser(strings.NewReader(r.request.Body))
|
req.Body = ioutil.NopCloser(strings.NewReader(r.request.Body))
|
||||||
}
|
}
|
||||||
setHeader(req, "User-Agent", "Nuclei - Open-source project (github.com/projectdiscovery/nuclei)")
|
setHeader(req, "User-Agent", uarand.GetRandom())
|
||||||
|
|
||||||
// Only set these headers on non raw requests
|
// Only set these headers on non raw requests
|
||||||
if len(r.request.Raw) == 0 {
|
if len(r.request.Raw) == 0 {
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package http
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/corpix/uarand"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
@ -102,10 +101,6 @@ func (r *Request) Compile(options *protocols.ExecuterOptions) error {
|
|||||||
}
|
}
|
||||||
r.customHeaders[parts[0]] = strings.TrimSpace(parts[1])
|
r.customHeaders[parts[0]] = strings.TrimSpace(parts[1])
|
||||||
}
|
}
|
||||||
// Add User-Agent value randomly to the customHeaders slice if `random-agent` flag is given
|
|
||||||
if _, ok := r.customHeaders["User-Agent"]; !ok {
|
|
||||||
r.customHeaders["User-Agent"] = uarand.GetRandom()
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.Body != "" && !strings.Contains(r.Body, "\r\n") {
|
if r.Body != "" && !strings.Contains(r.Body, "\r\n") {
|
||||||
r.Body = strings.ReplaceAll(r.Body, "\n", "\r\n")
|
r.Body = strings.ReplaceAll(r.Body, "\n", "\r\n")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user