mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-16 04:00:24 +00:00
commit
c82f0564f5
@ -31,26 +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 header["User-Agent"] == "" {
|
if RandomUA {
|
||||||
if RandomUA {
|
r.SetHeader("User-Agent", pkg.RandomUA())
|
||||||
header["User-Agent"] = pkg.RandomUA()
|
|
||||||
} else {
|
|
||||||
header["User-Agent"] = pkg.DefaultUserAgent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if header["Accept"] == "" {
|
|
||||||
header["Accept"] = "*/*"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"`
|
||||||
|
@ -394,7 +394,6 @@ func (pool *BrutePool) NoScopeInvoke(v interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.SetHeaders(pool.Headers, pool.RandomUserAgent)
|
req.SetHeaders(pool.Headers, pool.RandomUserAgent)
|
||||||
req.SetHeader("User-Agent", pkg.RandomUA())
|
|
||||||
resp, reqerr := pool.client.Do(req)
|
resp, reqerr := pool.client.Do(req)
|
||||||
if pool.ClientType == ihttp.FAST {
|
if pool.ClientType == ihttp.FAST {
|
||||||
defer fasthttp.ReleaseResponse(resp.FastResponse)
|
defer fasthttp.ReleaseResponse(resp.FastResponse)
|
||||||
|
@ -36,7 +36,7 @@ func NewCheckPool(ctx context.Context, config *Config) (*CheckPool, error) {
|
|||||||
processCh: make(chan *baseline.Baseline, config.Thread),
|
processCh: make(chan *baseline.Baseline, config.Thread),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pool.Headers = map[string]string{"Connection": "close"}
|
pool.Headers.Set("Connection", "close")
|
||||||
p, _ := ants.NewPoolWithFunc(config.Thread, pool.Invoke)
|
p, _ := ants.NewPoolWithFunc(config.Thread, pool.Invoke)
|
||||||
|
|
||||||
pool.Pool = p
|
pool.Pool = p
|
||||||
|
@ -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
|
||||||
|
@ -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,18 @@ func (r *Runner) PrepareConfig() *pool.Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for k, v := range r.Headers {
|
||||||
|
config.Headers.Set(k, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Headers.Get("User-Agent") == "" {
|
||||||
|
config.Headers.Set("User-Agent", pkg.DefaultUserAgent)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Headers.Get("Accept") == "" {
|
||||||
|
config.Headers.Set("Accept", "*/*")
|
||||||
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user