mirror of
https://github.com/chainreactors/spray.git
synced 2026-10-24 08:54:30 +00:00
chore: fix new statistor
This commit is contained in:
1 parent
5661a4acad
commit
9a0858fd3c
3 files changed
+28
-23
No files matched your search
+12
-10
@@ -334,6 +334,18 @@ func (opt *Option) Prepare() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewStatistor 在Option层面创建Statistor
|
||||
func (opt *Option) NewStatistor(url string, total int) *pkg.Statistor {
|
||||
stat := pkg.NewStatistor(url)
|
||||
stat.Total = total
|
||||
stat.Dictionaries = opt.Dictionaries
|
||||
stat.Word = opt.Word
|
||||
stat.Offset = opt.Offset
|
||||
stat.RuleFiles = opt.Rules
|
||||
stat.RuleFilter = opt.FilterRule
|
||||
return stat
|
||||
}
|
||||
|
||||
func (opt *Option) NewRunner() (*Runner, error) {
|
||||
var err error
|
||||
r := &Runner{
|
||||
@@ -410,16 +422,6 @@ func (opt *Option) NewRunner() (*Runner, error) {
|
||||
r.Threads = 1000
|
||||
}
|
||||
|
||||
pkg.DefaultStatistor = pkg.Statistor{
|
||||
Word: opt.Word,
|
||||
WordCount: len(r.Wordlist),
|
||||
Dictionaries: opt.Dictionaries,
|
||||
Offset: opt.Offset,
|
||||
RuleFiles: opt.Rules,
|
||||
RuleFilter: opt.FilterRule,
|
||||
Total: r.Total,
|
||||
}
|
||||
|
||||
r.Tasks, err = opt.BuildTasks(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
+7
-3
@@ -189,7 +189,7 @@ func (r *Runner) RunWithBrute(ctx context.Context) {
|
||||
}
|
||||
brutePool.Statistor.Total = t.origin.sum
|
||||
} else {
|
||||
brutePool.Statistor = pkg.NewStatistor(t.baseUrl)
|
||||
brutePool.Statistor = r.Option.NewStatistor(t.baseUrl, r.Total)
|
||||
brutePool.Worder = words.NewWorderWithList(r.Wordlist)
|
||||
brutePool.Worder.Fns = r.Fns
|
||||
brutePool.Worder.Rules = r.Rules.Expressions
|
||||
@@ -239,7 +239,7 @@ Loop:
|
||||
// 如果超过了deadline, 尚未开始的任务都将被记录到stat中
|
||||
if len(r.taskCh) > 0 {
|
||||
for t := range r.taskCh {
|
||||
stat := pkg.NewStatistor(t.baseUrl)
|
||||
stat := r.Option.NewStatistor(t.baseUrl, 0)
|
||||
r.saveStat(stat.Json())
|
||||
}
|
||||
}
|
||||
@@ -328,6 +328,10 @@ Loop:
|
||||
}
|
||||
|
||||
r.OutWg.Wait()
|
||||
|
||||
// 关闭 OutputCh,通知所有监听者没有更多结果了
|
||||
close(r.OutputCh)
|
||||
close(r.FuzzyCh)
|
||||
}
|
||||
|
||||
func (r *Runner) AddRecursive(bl *baseline.Baseline) {
|
||||
@@ -335,7 +339,7 @@ func (r *Runner) AddRecursive(bl *baseline.Baseline) {
|
||||
task := &Task{
|
||||
baseUrl: bl.UrlString,
|
||||
depth: bl.RecuDepth + 1,
|
||||
origin: NewOrigin(pkg.NewStatistor(bl.UrlString)),
|
||||
origin: NewOrigin(r.Option.NewStatistor(bl.UrlString, 0)),
|
||||
}
|
||||
|
||||
r.AddPool(task)
|
||||
|
||||
+9
-10
@@ -4,23 +4,22 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/chainreactors/logs"
|
||||
"github.com/chainreactors/parsers"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/chainreactors/logs"
|
||||
"github.com/chainreactors/parsers"
|
||||
)
|
||||
|
||||
var DefaultStatistor Statistor
|
||||
|
||||
func NewStatistor(url string) *Statistor {
|
||||
stat := DefaultStatistor
|
||||
stat.StartTime = time.Now().Unix()
|
||||
stat.Counts = make(map[int]int)
|
||||
stat.Sources = make(map[parsers.SpraySource]int)
|
||||
stat.BaseUrl = url
|
||||
return &stat
|
||||
return &Statistor{
|
||||
BaseUrl: url,
|
||||
StartTime: time.Now().Unix(),
|
||||
Counts: make(map[int]int),
|
||||
Sources: make(map[parsers.SpraySource]int),
|
||||
}
|
||||
}
|
||||
|
||||
func NewStatistorFromStat(origin *Statistor) *Statistor {
|
||||
|
||||
Reference in new issue
Block a user