This commit is contained in:
M09Ic 2025-03-04 14:56:48 +08:00
parent b13903ea98
commit c746c26ff9
5 changed files with 18 additions and 12 deletions

View File

@ -31,18 +31,18 @@ type Request struct {
ClientType int ClientType int
} }
func (r *Request) SetHeaders(header map[string]string, RandomUA bool) { func (r *Request) SetHeaders(header http.Header, RandomUA bool) {
if RandomUA { if RandomUA {
r.SetHeader("User-Agent", pkg.RandomUA()) r.SetHeader("User-Agent", pkg.RandomUA())
} }
if r.StandardRequest != nil { if r.StandardRequest != nil {
for k, v := range header { r.StandardRequest.Header = header
r.StandardRequest.Header.Set(k, v)
}
} else if r.FastRequest != nil { } else if r.FastRequest != nil {
for k, v := range header { for k, v := range header {
r.FastRequest.Header.Set(k, v) for _, i := range v {
r.FastRequest.Header.Set(k, i)
}
} }
} }
} }

View File

@ -99,7 +99,7 @@ type OutputOptions struct {
type RequestOptions struct { type RequestOptions struct {
Method string `short:"X" long:"method" default:"GET" description:"String, request method, e.g.: --method POST" config:"method"` Method string `short:"X" long:"method" default:"GET" description:"String, request method, e.g.: --method POST" config:"method"`
Headers []string `long:"header" description:"Strings, custom headers, e.g.: --header 'Auth: example_auth'" config:"headers"` Headers []string `short:"H" long:"header" description:"Strings, custom headers, e.g.: --header 'Auth: example_auth'" config:"headers"`
UserAgent string `long:"user-agent" description:"String, custom user-agent, e.g.: --user-agent Custom" config:"useragent"` UserAgent string `long:"user-agent" description:"String, custom user-agent, e.g.: --user-agent Custom" config:"useragent"`
RandomUserAgent bool `long:"random-agent" description:"Bool, use random with default user-agent" config:"random-useragent"` RandomUserAgent bool `long:"random-agent" description:"Bool, use random with default user-agent" config:"random-useragent"`
Cookie []string `long:"cookie" description:"Strings, custom cookie" config:"cookies"` Cookie []string `long:"cookie" description:"Strings, custom cookie" config:"cookies"`

View File

@ -107,12 +107,12 @@ type BrutePool struct {
} }
func (pool *BrutePool) Init() error { func (pool *BrutePool) Init() error {
if pool.Headers["User-Agent"] == "" { if pool.Headers.Get("User-Agent") == "" {
pool.Headers["User-Agent"] = pkg.DefaultUserAgent pool.Headers.Set("User-Agent", pkg.DefaultUserAgent)
} }
if pool.Headers["Accept"] == "" { if pool.Headers.Get("Accept") == "" {
pool.Headers["Accept"] = "*/*" pool.Headers.Set("Accept", "*/*")
} }
pool.initwg.Add(2) pool.initwg.Add(2)

View File

@ -7,6 +7,7 @@ import (
"github.com/chainreactors/words" "github.com/chainreactors/words"
"github.com/chainreactors/words/rule" "github.com/chainreactors/words/rule"
"github.com/expr-lang/expr/vm" "github.com/expr-lang/expr/vm"
"net/http"
"sync" "sync"
"time" "time"
) )
@ -27,7 +28,7 @@ type Config struct {
BreakThreshold int32 BreakThreshold int32
Method string Method string
Mod SprayMod Mod SprayMod
Headers map[string]string Headers http.Header
ClientType int ClientType int
MatchExpr *vm.Program MatchExpr *vm.Program
FilterExpr *vm.Program FilterExpr *vm.Program

View File

@ -15,6 +15,7 @@ import (
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/vbauerster/mpb/v8" "github.com/vbauerster/mpb/v8"
"github.com/vbauerster/mpb/v8/decor" "github.com/vbauerster/mpb/v8/decor"
"net/http"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -67,7 +68,7 @@ func (r *Runner) PrepareConfig() *pool.Config {
Thread: r.Threads, Thread: r.Threads,
Timeout: time.Duration(r.Timeout) * time.Second, Timeout: time.Duration(r.Timeout) * time.Second,
RateLimit: r.RateLimit, RateLimit: r.RateLimit,
Headers: r.Headers, Headers: make(http.Header),
Method: r.Method, Method: r.Method,
Mod: pool.ModMap[r.Mod], Mod: pool.ModMap[r.Mod],
OutputCh: r.outputCh, OutputCh: r.outputCh,
@ -109,6 +110,10 @@ func (r *Runner) PrepareConfig() *pool.Config {
} }
} }
for k, v := range r.Headers {
config.Headers.Set(k, v)
}
return config return config
} }