spray/internal/types.go

81 lines
1.4 KiB
Go
Raw Normal View History

2022-09-15 19:27:07 +08:00
package internal
import (
"github.com/chainreactors/spray/pkg"
"github.com/chainreactors/words/rule"
)
2022-09-15 19:27:07 +08:00
type ErrorType uint
const (
ErrBadStatus ErrorType = iota
ErrSameStatus
ErrRequestFailed
2022-09-15 19:27:07 +08:00
ErrWaf
ErrRedirect
2022-11-17 05:53:04 +08:00
ErrCompareFailed
ErrFuzzyCompareFailed
ErrCustomCompareFailed
ErrCustomFilter
2022-09-15 19:27:07 +08:00
)
func (e ErrorType) Error() string {
switch e {
case ErrBadStatus:
2022-12-02 15:21:17 +08:00
return "blacklist status"
case ErrSameStatus:
2022-12-02 15:21:17 +08:00
return "same status with random baseline"
case ErrRequestFailed:
return "request failed"
2022-09-15 19:27:07 +08:00
case ErrWaf:
return "maybe banned by waf"
2022-09-15 19:27:07 +08:00
case ErrRedirect:
return "duplicate redirect url"
2022-11-17 05:53:04 +08:00
case ErrCompareFailed:
return "compare failed"
case ErrFuzzyCompareFailed:
return "fuzzy compare failed"
case ErrCustomCompareFailed:
return "custom compare failed"
case ErrCustomFilter:
return "custom filtered"
2022-09-15 19:27:07 +08:00
default:
return "unknown error"
}
}
2022-10-19 16:38:23 +08:00
const (
CheckSource = iota + 1
InitRandomSource
InitIndexSource
2022-11-29 21:55:27 +08:00
RedirectSource
2023-01-03 17:09:32 +08:00
CrawlSource
2023-01-03 17:16:55 +08:00
ActiveSource
2022-10-19 16:38:23 +08:00
WordSource
WafSource
RuleSource
BakSource
2022-10-19 16:38:23 +08:00
)
func newUnit(path string, source int) *Unit {
2022-10-19 16:38:23 +08:00
return &Unit{path: path, source: source}
}
func newUnitWithNumber(path string, source int, number int) *Unit {
2023-01-03 17:09:32 +08:00
return &Unit{path: path, source: source}
}
2022-10-19 16:38:23 +08:00
type Unit struct {
2022-11-29 21:55:27 +08:00
path string
source int
2022-11-29 21:55:27 +08:00
frontUrl string
2023-01-03 17:09:32 +08:00
depth int // redirect depth
2022-10-19 16:38:23 +08:00
}
type Task struct {
baseUrl string
depth int
rule []rule.Expression
origin *pkg.Statistor
}