diff --git a/internal/option.go b/internal/option.go index a4e6ce8..aad13f6 100644 --- a/internal/option.go +++ b/internal/option.go @@ -78,6 +78,7 @@ type ModeOptions struct { CheckOnly bool `long:"check-only" description:"Bool, check only"` 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"` + Active bool `long:"active" description:"Bool, enable active finger detect"` Crawl bool `long:"crawl" description:"Bool, enable crawl"` CrawlDepth int `long:"spider-depth" default:"3" description:"Int, crawl depth"` CheckPeriod int `long:"check-period" default:"200" description:"Int, check period when request"` @@ -127,6 +128,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) { ErrPeriod: opt.ErrPeriod, BreakThreshold: opt.BreakThreshold, Crawl: opt.Crawl, + Active: opt.Active, } err = pkg.LoadTemplates() diff --git a/internal/pool.go b/internal/pool.go index ff26ee3..d2fa208 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -135,7 +135,7 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) { case RedirectSource: bl.FrontURL = unit.frontUrl pool.tempCh <- bl - case CrawlSource: + case CrawlSource, ActiveSource: pool.tempCh <- bl } @@ -292,6 +292,10 @@ func (pool *Pool) Run(ctx context.Context, offset, limit int) { pool.reqPool.Invoke(unit) } }() + if pool.Active { + go pool.doActive() + } + Loop: for { select { @@ -466,16 +470,25 @@ func (pool *Pool) doCrawl(bl *pkg.Baseline) { } pool.wg.Add(1) pool.additionCh <- &Unit{ - path: parsed.Path, - source: CrawlSource, - frontUrl: bl.UrlString, - depth: bl.ReqDepth + 1, + path: parsed.Path, + source: CrawlSource, + depth: bl.ReqDepth + 1, } } } } } +func (pool *Pool) doActive() { + for _, u := range pkg.ActivePath { + pool.wg.Add(1) + pool.additionCh <- &Unit{ + path: u, + source: ActiveSource, + } + } +} + func (pool *Pool) doCheck() { if pool.failedCount > pool.BreakThreshold { // 当报错次数超过上限是, 结束任务 diff --git a/internal/runner.go b/internal/runner.go index 491312f..be6bfd3 100644 --- a/internal/runner.go +++ b/internal/runner.go @@ -73,6 +73,7 @@ type Runner struct { Force bool IgnoreWaf bool Crawl bool + Active bool } func (r *Runner) PrepareConfig() *pkg.Config { @@ -92,6 +93,7 @@ func (r *Runner) PrepareConfig() *pkg.Config { RecuExpr: r.RecursiveExpr, IgnoreWaf: r.IgnoreWaf, Crawl: r.Crawl, + Active: r.Active, } if config.Mod == pkg.PathSpray { config.ClientType = ihttp.FAST diff --git a/internal/types.go b/internal/types.go index 72937f6..1311601 100644 --- a/internal/types.go +++ b/internal/types.go @@ -52,6 +52,7 @@ const ( InitIndexSource RedirectSource CrawlSource + ActiveSource WordSource WafSource ) diff --git a/pkg/config.go b/pkg/config.go index 2b660c7..e017bd9 100644 --- a/pkg/config.go +++ b/pkg/config.go @@ -39,4 +39,5 @@ type Config struct { Fuzzy bool IgnoreWaf bool Crawl bool + Active bool }