fix: migrate RandomUA to httputils.GetRandomUA

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
M09IcandClaude Opus 4.6 committed 2026-07-04 12:44:37 -07:00
1 parent adf82d2759
commit c78ae4afef
2 files changed
+4 -22

No files matched your search

+2 -1
View File
@@ -7,6 +7,7 @@ import (
"strings"
"github.com/chainreactors/spray/pkg"
"github.com/chainreactors/utils/httputils"
"github.com/valyala/fasthttp"
)
@@ -105,7 +106,7 @@ func (rc *RequestConfig) Build(ctx context.Context, clientType int, base, path,
func (rc *RequestConfig) setHeadersWithFuzz(r *Request, word string) {
if rc.RandomUserAgent {
r.SetHeader("User-Agent", pkg.RandomUA())
r.SetHeader("User-Agent", httputils.GetRandomUA())
}
for k, vs := range rc.Headers {
+2 -21
View File
@@ -7,6 +7,7 @@ import (
"github.com/chainreactors/fingers"
"github.com/chainreactors/logs"
"github.com/chainreactors/utils"
"github.com/chainreactors/utils/httputils"
"github.com/chainreactors/utils/iutils"
"github.com/chainreactors/utils/parsers"
"github.com/chainreactors/words/mask"
@@ -79,23 +80,7 @@ var (
"image/x-icon": "ico",
}
// from feroxbuster
randomUserAgent = []string{
"Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; Microsoft; RM-1152) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Mobile Safari/537.36 Edge/15.15254",
"Mozilla/5.0 (Linux; Android 7.0; Pixel C Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246",
"Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36",
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1",
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
"Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)",
"Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)",
}
uacount = len(randomUserAgent)
DefaultUserAgent = randomUserAgent[rand.Intn(uacount)]
DefaultUserAgent = httputils.GetRandomUA()
)
func MatchContentType(contentType string) (string, bool) {
@@ -404,10 +389,6 @@ func BaseURL(u *url.URL) string {
return u.Scheme + "://" + u.Host
}
func RandomUA() string {
return randomUserAgent[rand.Intn(uacount)]
}
func CompareWithExpr(exp *vm.Program, params map[string]interface{}) bool {
res, err := expr.Run(exp, params)
if err != nil {