mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-16 04:00:24 +00:00
commit
63b39cead1
4
.github/workflows/gorelease.yml
vendored
4
.github/workflows/gorelease.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{secrets.TOKEN}}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
-
|
-
|
||||||
name: Set up Go
|
name: Set up Go
|
||||||
@ -30,6 +30,6 @@ jobs:
|
|||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist --skip-validate
|
args: release --rm-dist --skip-validate
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
GOPATH: "/home/runner/go"
|
GOPATH: "/home/runner/go"
|
||||||
|
|
||||||
|
@ -47,6 +47,10 @@
|
|||||||
|
|
||||||
`spray --resume stat.json`
|
`spray --resume stat.json`
|
||||||
|
|
||||||
|
被动url收集
|
||||||
|
|
||||||
|
参见: https://github.com/chainreactors/urlfounder
|
||||||
|
|
||||||
## Wiki
|
## Wiki
|
||||||
|
|
||||||
详细用法请见[wiki](https://chainreactors.github.io/wiki/spray/)
|
详细用法请见[wiki](https://chainreactors.github.io/wiki/spray/)
|
||||||
|
@ -194,7 +194,7 @@ func (pool *CheckPool) doRedirect(bl *pkg.Baseline, depth int) {
|
|||||||
}
|
}
|
||||||
reURL = bl.RedirectURL
|
reURL = bl.RedirectURL
|
||||||
} else {
|
} else {
|
||||||
reURL = bl.BaseURL() + FormatURL(bl.BaseURL(), bl.RedirectURL)
|
reURL = BaseURL(bl.Url) + FormatURL(BaseURL(bl.Url), bl.RedirectURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
pool.wg.Add(1)
|
pool.wg.Add(1)
|
||||||
|
@ -105,6 +105,8 @@ type ModeOptions struct {
|
|||||||
Scope []string `long:"scope" description:"String, custom scope, e.g.: --scope *.example.com"`
|
Scope []string `long:"scope" description:"String, custom scope, e.g.: --scope *.example.com"`
|
||||||
Recursive string `long:"recursive" default:"current.IsDir()" description:"String,custom recursive rule, e.g.: --recursive current.IsDir()"`
|
Recursive string `long:"recursive" default:"current.IsDir()" description:"String,custom recursive rule, e.g.: --recursive current.IsDir()"`
|
||||||
Depth int `long:"depth" default:"0" description:"Int, recursive depth"`
|
Depth int `long:"depth" default:"0" description:"Int, recursive depth"`
|
||||||
|
Index string `long:"index" default:"" description:"String, custom index path"`
|
||||||
|
Random string `long:"random" default:"" description:"String, custom random path"`
|
||||||
CheckPeriod int `long:"check-period" default:"200" description:"Int, check period when request"`
|
CheckPeriod int `long:"check-period" default:"200" description:"Int, check period when request"`
|
||||||
ErrPeriod int `long:"error-period" default:"10" description:"Int, check period when error"`
|
ErrPeriod int `long:"error-period" default:"10" description:"Int, check period when error"`
|
||||||
BreakThreshold int `long:"error-threshold" default:"20" description:"Int, break when the error exceeds the threshold "`
|
BreakThreshold int `long:"error-threshold" default:"20" description:"Int, break when the error exceeds the threshold "`
|
||||||
@ -164,6 +166,8 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
|||||||
Common: opt.Common,
|
Common: opt.Common,
|
||||||
RetryCount: opt.RetryCount,
|
RetryCount: opt.RetryCount,
|
||||||
RandomUserAgent: opt.RandomUserAgent,
|
RandomUserAgent: opt.RandomUserAgent,
|
||||||
|
Random: opt.Random,
|
||||||
|
Index: opt.Index,
|
||||||
}
|
}
|
||||||
|
|
||||||
// log and bar
|
// log and bar
|
||||||
@ -505,7 +509,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
|||||||
logs.Log.Importantf("Loaded %d dictionaries and %d decorators", len(opt.Dictionaries), len(r.Fns))
|
logs.Log.Importantf("Loaded %d dictionaries and %d decorators", len(opt.Dictionaries), len(r.Fns))
|
||||||
|
|
||||||
if opt.Match != "" {
|
if opt.Match != "" {
|
||||||
exp, err := expr.Compile(opt.Match)
|
exp, err := expr.Compile(opt.Match, expr.Patch(&bytesPatcher{}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -513,7 +517,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opt.Filter != "" {
|
if opt.Filter != "" {
|
||||||
exp, err := expr.Compile(opt.Filter)
|
exp, err := expr.Compile(opt.Filter, expr.Patch(&bytesPatcher{}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -535,7 +539,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if express != "" {
|
if express != "" {
|
||||||
exp, err := expr.Compile(express)
|
exp, err := expr.Compile(express, expr.Patch(&bytesPatcher{}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,20 @@ func (pool *Pool) genReq(mod pkg.SprayMod, s string) (*ihttp.Request, error) {
|
|||||||
func (pool *Pool) Init() error {
|
func (pool *Pool) Init() error {
|
||||||
// 分成两步是为了避免闭包的线程安全问题
|
// 分成两步是为了避免闭包的线程安全问题
|
||||||
pool.initwg.Add(2)
|
pool.initwg.Add(2)
|
||||||
|
if pool.Index != "" {
|
||||||
|
logs.Log.Importantf("custom index url: %s", BaseURL(pool.url)+FormatURL(BaseURL(pool.url), pool.Index))
|
||||||
|
pool.reqPool.Invoke(newUnit(pool.Index, InitIndexSource))
|
||||||
|
} else {
|
||||||
pool.reqPool.Invoke(newUnit(pool.url.Path, InitIndexSource))
|
pool.reqPool.Invoke(newUnit(pool.url.Path, InitIndexSource))
|
||||||
|
}
|
||||||
|
|
||||||
|
if pool.Random != "" {
|
||||||
|
logs.Log.Importantf("custom random url: %s", BaseURL(pool.url)+FormatURL(BaseURL(pool.url), pool.Random))
|
||||||
|
pool.reqPool.Invoke(newUnit(pool.Random, InitRandomSource))
|
||||||
|
} else {
|
||||||
pool.reqPool.Invoke(newUnit(pool.safePath(pkg.RandPath()), InitRandomSource))
|
pool.reqPool.Invoke(newUnit(pool.safePath(pkg.RandPath()), InitRandomSource))
|
||||||
|
}
|
||||||
|
|
||||||
pool.initwg.Wait()
|
pool.initwg.Wait()
|
||||||
if pool.index.ErrString != "" {
|
if pool.index.ErrString != "" {
|
||||||
logs.Log.Error(pool.index.String())
|
logs.Log.Error(pool.index.String())
|
||||||
|
@ -82,6 +82,8 @@ type Runner struct {
|
|||||||
Common bool
|
Common bool
|
||||||
RetryCount int
|
RetryCount int
|
||||||
RandomUserAgent bool
|
RandomUserAgent bool
|
||||||
|
Random string
|
||||||
|
Index string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runner) PrepareConfig() *pkg.Config {
|
func (r *Runner) PrepareConfig() *pkg.Config {
|
||||||
@ -110,6 +112,8 @@ func (r *Runner) PrepareConfig() *pkg.Config {
|
|||||||
Retry: r.RetryCount,
|
Retry: r.RetryCount,
|
||||||
ClientType: r.ClientType,
|
ClientType: r.ClientType,
|
||||||
RandomUserAgent: r.RandomUserAgent,
|
RandomUserAgent: r.RandomUserAgent,
|
||||||
|
Random: r.Random,
|
||||||
|
Index: r.Index,
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.ClientType == ihttp.Auto {
|
if config.ClientType == ihttp.Auto {
|
||||||
|
@ -3,6 +3,7 @@ package internal
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/antonmedv/expr"
|
"github.com/antonmedv/expr"
|
||||||
|
"github.com/antonmedv/expr/ast"
|
||||||
"github.com/antonmedv/expr/vm"
|
"github.com/antonmedv/expr/vm"
|
||||||
"github.com/chainreactors/logs"
|
"github.com/chainreactors/logs"
|
||||||
"github.com/chainreactors/spray/pkg"
|
"github.com/chainreactors/spray/pkg"
|
||||||
@ -212,7 +213,6 @@ func Dir(u string) string {
|
|||||||
// /a/ /a/
|
// /a/ /a/
|
||||||
// a/ a/
|
// a/ a/
|
||||||
// aaa /
|
// aaa /
|
||||||
|
|
||||||
if strings.HasSuffix(u, "/") {
|
if strings.HasSuffix(u, "/") {
|
||||||
return u
|
return u
|
||||||
} else if i := strings.LastIndex(u, "/"); i == -1 {
|
} else if i := strings.LastIndex(u, "/"); i == -1 {
|
||||||
@ -250,6 +250,10 @@ func FormatURL(base, u string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BaseURL(u *url.URL) string {
|
||||||
|
return u.Scheme + "://" + u.Host
|
||||||
|
}
|
||||||
|
|
||||||
func RandomUA() string {
|
func RandomUA() string {
|
||||||
return randomUserAgent[rand.Intn(uacount)]
|
return randomUserAgent[rand.Intn(uacount)]
|
||||||
}
|
}
|
||||||
@ -276,3 +280,18 @@ func MatchWithGlobs(u string, globs []string) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type bytesPatcher struct{}
|
||||||
|
|
||||||
|
func (p *bytesPatcher) Visit(node *ast.Node) {
|
||||||
|
switch (*node).(type) {
|
||||||
|
case *ast.MemberNode:
|
||||||
|
ast.Patch(node, &ast.CallNode{
|
||||||
|
Callee: &ast.MemberNode{
|
||||||
|
Node: *node,
|
||||||
|
Name: "String",
|
||||||
|
Property: &ast.StringNode{Value: "String"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -105,9 +105,9 @@ type Baseline struct {
|
|||||||
Url *url.URL `json:"-"`
|
Url *url.URL `json:"-"`
|
||||||
Dir bool `json:"-"`
|
Dir bool `json:"-"`
|
||||||
Chunked bool `json:"-"`
|
Chunked bool `json:"-"`
|
||||||
Body []byte `json:"-"`
|
Body BS `json:"-"`
|
||||||
Header []byte `json:"-"`
|
Header BS `json:"-"`
|
||||||
Raw []byte `json:"-"`
|
Raw BS `json:"-"`
|
||||||
Recu bool `json:"-"`
|
Recu bool `json:"-"`
|
||||||
RecuDepth int `json:"-"`
|
RecuDepth int `json:"-"`
|
||||||
URLs []string `json:"-"`
|
URLs []string `json:"-"`
|
||||||
@ -122,10 +122,6 @@ func (bl *Baseline) IsDir() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bl *Baseline) BaseURL() string {
|
|
||||||
return bl.Url.Scheme + "://" + bl.Url.Host
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collect 深度收集信息
|
// Collect 深度收集信息
|
||||||
func (bl *Baseline) Collect() {
|
func (bl *Baseline) Collect() {
|
||||||
if bl.ContentType == "html" || bl.ContentType == "json" || bl.ContentType == "txt" {
|
if bl.ContentType == "html" || bl.ContentType == "json" || bl.ContentType == "txt" {
|
||||||
|
@ -47,4 +47,6 @@ type Config struct {
|
|||||||
Common bool
|
Common bool
|
||||||
Retry int
|
Retry int
|
||||||
RandomUserAgent bool
|
RandomUserAgent bool
|
||||||
|
Random string
|
||||||
|
Index string
|
||||||
}
|
}
|
||||||
|
@ -37,3 +37,9 @@ var ErrMap = map[ErrorType]string{
|
|||||||
func (e ErrorType) Error() string {
|
func (e ErrorType) Error() string {
|
||||||
return ErrMap[e]
|
return ErrMap[e]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BS []byte
|
||||||
|
|
||||||
|
func (b BS) String() string {
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user