mirror of
				https://github.com/chainreactors/spray.git
				synced 2025-11-04 09:58:03 +00:00 
			
		
		
		
	修复多个bug
新增--force参数, 将忽略报错数量
This commit is contained in:
		
							parent
							
								
									9f2223aeca
								
							
						
					
					
						commit
						c94a4c4d10
					
				@ -49,6 +49,8 @@ func NewInvalidBaseline(u, host string, resp *ihttp.Response) *baseline {
 | 
				
			|||||||
		bl.Host = host
 | 
							bl.Host = host
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bl.Body = resp.Body()
 | 
				
			||||||
 | 
						bl.BodyLength = resp.ContentLength()
 | 
				
			||||||
	bl.RedirectURL = string(resp.GetHeader("Location"))
 | 
						bl.RedirectURL = string(resp.GetHeader("Location"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return bl
 | 
						return bl
 | 
				
			||||||
 | 
				
			|||||||
@ -48,6 +48,7 @@ type RequestOptions struct {
 | 
				
			|||||||
	Headers []string `long:"header"`
 | 
						Headers []string `long:"header"`
 | 
				
			||||||
	Method  string   `long:"method"`
 | 
						Method  string   `long:"method"`
 | 
				
			||||||
	Cookie  string   `long:"cookie"`
 | 
						Cookie  string   `long:"cookie"`
 | 
				
			||||||
 | 
						Force   bool     `long:"force"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type MiscOptions struct {
 | 
					type MiscOptions struct {
 | 
				
			||||||
@ -73,7 +74,6 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
 | 
				
			|||||||
		PoolSize: opt.PoolSize,
 | 
							PoolSize: opt.PoolSize,
 | 
				
			||||||
		Mod:      opt.Mod,
 | 
							Mod:      opt.Mod,
 | 
				
			||||||
		Timeout:  opt.Timeout,
 | 
							Timeout:  opt.Timeout,
 | 
				
			||||||
		Probes:   strings.Split(opt.OutputProbe, ","),
 | 
					 | 
				
			||||||
		Deadline: opt.Deadline,
 | 
							Deadline: opt.Deadline,
 | 
				
			||||||
		Offset:   opt.Offset,
 | 
							Offset:   opt.Offset,
 | 
				
			||||||
		Limit:    opt.Limit,
 | 
							Limit:    opt.Limit,
 | 
				
			||||||
@ -94,6 +94,10 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
 | 
				
			|||||||
		logs.Log.Writer = r.Progress.Bypass()
 | 
							logs.Log.Writer = r.Progress.Bypass()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if opt.Force {
 | 
				
			||||||
 | 
							breakThreshold = 999999
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// prepare url
 | 
						// prepare url
 | 
				
			||||||
	var urls []string
 | 
						var urls []string
 | 
				
			||||||
	var file *os.File
 | 
						var file *os.File
 | 
				
			||||||
@ -217,6 +221,9 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if opt.OutputProbe != "" {
 | 
				
			||||||
 | 
							r.Probes = strings.Split(opt.OutputProbe, ",")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return r, nil
 | 
						return r, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,7 @@ var (
 | 
				
			|||||||
	CheckWaf        func([]byte) bool
 | 
						CheckWaf        func([]byte) bool
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var breakThreshold int = 10
 | 
					var breakThreshold int = 20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewPool(ctx context.Context, config *pkg.Config, outputCh chan *baseline) (*Pool, error) {
 | 
					func NewPool(ctx context.Context, config *pkg.Config, outputCh chan *baseline) (*Pool, error) {
 | 
				
			||||||
	pctx, cancel := context.WithCancel(ctx)
 | 
						pctx, cancel := context.WithCancel(ctx)
 | 
				
			||||||
@ -35,6 +35,8 @@ func NewPool(ctx context.Context, config *pkg.Config, outputCh chan *baseline) (
 | 
				
			|||||||
		initwg:      sync.WaitGroup{},
 | 
							initwg:      sync.WaitGroup{},
 | 
				
			||||||
		checkPeriod: 100,
 | 
							checkPeriod: 100,
 | 
				
			||||||
		errPeriod:   10,
 | 
							errPeriod:   10,
 | 
				
			||||||
 | 
							reqCount:    1,
 | 
				
			||||||
 | 
							failedCount: 1,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch config.Mod {
 | 
						switch config.Mod {
 | 
				
			||||||
@ -87,6 +89,7 @@ func NewPool(ctx context.Context, config *pkg.Config, outputCh chan *baseline) (
 | 
				
			|||||||
		if reqerr != nil && reqerr != fasthttp.ErrBodyTooLarge {
 | 
							if reqerr != nil && reqerr != fasthttp.ErrBodyTooLarge {
 | 
				
			||||||
			pool.failedCount++
 | 
								pool.failedCount++
 | 
				
			||||||
			bl = &baseline{Url: pool.BaseURL + unit.path, Err: reqerr}
 | 
								bl = &baseline{Url: pool.BaseURL + unit.path, Err: reqerr}
 | 
				
			||||||
 | 
								pool.failedBaselines = append(pool.failedBaselines, bl)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if err = pool.PreCompare(resp); err == nil || unit.source == CheckSource || unit.source == InitSource {
 | 
								if err = pool.PreCompare(resp); err == nil || unit.source == CheckSource || unit.source == InitSource {
 | 
				
			||||||
				// 通过预对比跳过一些无用数据, 减少性能消耗
 | 
									// 通过预对比跳过一些无用数据, 减少性能消耗
 | 
				
			||||||
@ -271,8 +274,8 @@ func (p *Pool) ResetFailed() {
 | 
				
			|||||||
func (p *Pool) Recover() {
 | 
					func (p *Pool) Recover() {
 | 
				
			||||||
	logs.Log.Errorf("failed request exceeds the threshold , task will exit. Breakpoint %d", p.reqCount)
 | 
						logs.Log.Errorf("failed request exceeds the threshold , task will exit. Breakpoint %d", p.reqCount)
 | 
				
			||||||
	logs.Log.Error("collecting failed check")
 | 
						logs.Log.Error("collecting failed check")
 | 
				
			||||||
	for _, bl := range p.failedBaselines {
 | 
						for i, bl := range p.failedBaselines {
 | 
				
			||||||
		logs.Log.Error(bl.String())
 | 
							logs.Log.Errorf("[failed.%d] %s", i, bl.String())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -113,15 +113,22 @@ Loop:
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *Runner) Outputting() {
 | 
					func (r *Runner) Outputting() {
 | 
				
			||||||
 | 
						var outFunc func(baseline2 *baseline)
 | 
				
			||||||
 | 
						if len(r.Probes) > 0 {
 | 
				
			||||||
 | 
							outFunc = func(bl *baseline) {
 | 
				
			||||||
 | 
								logs.Log.Console("[+] " + bl.Format(r.Probes) + "\n")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							outFunc = func(bl *baseline) {
 | 
				
			||||||
 | 
								logs.Log.Console("[+] " + bl.String() + "\n")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
		select {
 | 
							select {
 | 
				
			||||||
		case bl := <-r.OutputCh:
 | 
							case bl := <-r.OutputCh:
 | 
				
			||||||
			if bl.IsValid {
 | 
								if bl.IsValid {
 | 
				
			||||||
				if len(r.Probes) > 0 {
 | 
									outFunc(bl)
 | 
				
			||||||
					logs.Log.Console("[+]" + bl.Format(r.Probes) + "\n")
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					logs.Log.Console("[+] " + bl.String() + "\n")
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				logs.Log.Debug(bl.String())
 | 
									logs.Log.Debug(bl.String())
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user