mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 04:45:27 +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"
|
||||
"time"
|
||||
|
||||
"github.com/corpix/uarand"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/expressions"
|
||||
"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 != "" {
|
||||
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
|
||||
if len(r.request.Raw) == 0 {
|
||||
|
||||
@ -3,7 +3,6 @@ package http
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/corpix/uarand"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"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])
|
||||
}
|
||||
// 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") {
|
||||
r.Body = strings.ReplaceAll(r.Body, "\n", "\r\n")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user