mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
添加url错误是的报错信息
This commit is contained in:
parent
0167f376db
commit
4b78503d64
@ -140,7 +140,7 @@ func (pool *CheckPool) Invoke(v interface{}) {
|
|||||||
UrlString: unit.path,
|
UrlString: unit.path,
|
||||||
IsValid: false,
|
IsValid: false,
|
||||||
ErrString: reqerr.Error(),
|
ErrString: reqerr.Error(),
|
||||||
Reason: ErrRequestFailed.Error(),
|
Reason: pkg.ErrRequestFailed.Error(),
|
||||||
ReqDepth: unit.depth,
|
ReqDepth: unit.depth,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ func (pool *Pool) Invoke(v interface{}) {
|
|||||||
UrlString: pool.base + unit.path,
|
UrlString: pool.base + unit.path,
|
||||||
IsValid: false,
|
IsValid: false,
|
||||||
ErrString: reqerr.Error(),
|
ErrString: reqerr.Error(),
|
||||||
Reason: ErrRequestFailed.Error(),
|
Reason: pkg.ErrRequestFailed.Error(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pool.failedBaselines = append(pool.failedBaselines, bl)
|
pool.failedBaselines = append(pool.failedBaselines, bl)
|
||||||
@ -475,7 +475,7 @@ func (pool *Pool) Handler() {
|
|||||||
if _, ok := pool.uniques[bl.Unique]; ok {
|
if _, ok := pool.uniques[bl.Unique]; ok {
|
||||||
bl.IsValid = false
|
bl.IsValid = false
|
||||||
bl.IsFuzzy = true
|
bl.IsFuzzy = true
|
||||||
bl.Reason = ErrFuzzyNotUnique.Error()
|
bl.Reason = pkg.ErrFuzzyNotUnique.Error()
|
||||||
} else {
|
} else {
|
||||||
pool.uniques[bl.Unique] = struct{}{}
|
pool.uniques[bl.Unique] = struct{}{}
|
||||||
}
|
}
|
||||||
@ -484,7 +484,7 @@ func (pool *Pool) Handler() {
|
|||||||
// 对通过所有对比的有效数据进行再次filter
|
// 对通过所有对比的有效数据进行再次filter
|
||||||
if bl.IsValid && pool.FilterExpr != nil && CompareWithExpr(pool.FilterExpr, params) {
|
if bl.IsValid && pool.FilterExpr != nil && CompareWithExpr(pool.FilterExpr, params) {
|
||||||
pool.Statistor.FilteredNumber++
|
pool.Statistor.FilteredNumber++
|
||||||
bl.Reason = ErrCustomFilter.Error()
|
bl.Reason = pkg.ErrCustomFilter.Error()
|
||||||
bl.IsValid = false
|
bl.IsValid = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -522,19 +522,19 @@ func (pool *Pool) PreCompare(resp *ihttp.Response) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if pool.random.Status != 200 && pool.random.Status == status {
|
if pool.random.Status != 200 && pool.random.Status == status {
|
||||||
return ErrSameStatus
|
return pkg.ErrSameStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
if iutils.IntsContains(BlackStatus, status) {
|
if iutils.IntsContains(BlackStatus, status) {
|
||||||
return ErrBadStatus
|
return pkg.ErrBadStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
if iutils.IntsContains(WAFStatus, status) {
|
if iutils.IntsContains(WAFStatus, status) {
|
||||||
return ErrWaf
|
return pkg.ErrWaf
|
||||||
}
|
}
|
||||||
|
|
||||||
if !pool.checkRedirect(resp.GetHeader("Location")) {
|
if !pool.checkRedirect(resp.GetHeader("Location")) {
|
||||||
return ErrRedirect
|
return pkg.ErrRedirect
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -547,7 +547,7 @@ func (pool *Pool) BaseCompare(bl *pkg.Baseline) bool {
|
|||||||
var status = -1
|
var status = -1
|
||||||
// 30x状态码的特殊处理
|
// 30x状态码的特殊处理
|
||||||
if bl.RedirectURL != "" && strings.HasSuffix(bl.RedirectURL, bl.Url.Path+"/") {
|
if bl.RedirectURL != "" && strings.HasSuffix(bl.RedirectURL, bl.Url.Path+"/") {
|
||||||
bl.Reason = ErrFuzzyRedirect.Error()
|
bl.Reason = pkg.ErrFuzzyRedirect.Error()
|
||||||
pool.putToFuzzy(bl)
|
pool.putToFuzzy(bl)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -568,7 +568,7 @@ func (pool *Pool) BaseCompare(bl *pkg.Baseline) bool {
|
|||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
if status = base.Compare(bl); status == 1 {
|
if status = base.Compare(bl); status == 1 {
|
||||||
bl.Reason = ErrCompareFailed.Error()
|
bl.Reason = pkg.ErrCompareFailed.Error()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -588,7 +588,7 @@ func (pool *Pool) BaseCompare(bl *pkg.Baseline) bool {
|
|||||||
|
|
||||||
if ok && status == 0 && base.FuzzyCompare(bl) {
|
if ok && status == 0 && base.FuzzyCompare(bl) {
|
||||||
pool.Statistor.FuzzyNumber++
|
pool.Statistor.FuzzyNumber++
|
||||||
bl.Reason = ErrFuzzyCompareFailed.Error()
|
bl.Reason = pkg.ErrFuzzyCompareFailed.Error()
|
||||||
pool.putToFuzzy(bl)
|
pool.putToFuzzy(bl)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -6,42 +6,6 @@ import (
|
|||||||
"github.com/chainreactors/words/rule"
|
"github.com/chainreactors/words/rule"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrorType uint
|
|
||||||
|
|
||||||
const (
|
|
||||||
NoErr ErrorType = iota
|
|
||||||
ErrBadStatus
|
|
||||||
ErrSameStatus
|
|
||||||
ErrRequestFailed
|
|
||||||
ErrWaf
|
|
||||||
ErrRedirect
|
|
||||||
ErrCompareFailed
|
|
||||||
ErrCustomCompareFailed
|
|
||||||
ErrCustomFilter
|
|
||||||
ErrFuzzyCompareFailed
|
|
||||||
ErrFuzzyRedirect
|
|
||||||
ErrFuzzyNotUnique
|
|
||||||
)
|
|
||||||
|
|
||||||
var ErrMap = map[ErrorType]string{
|
|
||||||
NoErr: "",
|
|
||||||
ErrBadStatus: "blacklist status",
|
|
||||||
ErrSameStatus: "same status with random baseline",
|
|
||||||
ErrRequestFailed: "request failed",
|
|
||||||
ErrWaf: "maybe banned by waf",
|
|
||||||
ErrRedirect: "duplicate redirect url",
|
|
||||||
ErrCompareFailed: "compare failed",
|
|
||||||
ErrCustomCompareFailed: "custom compare failed",
|
|
||||||
ErrCustomFilter: "custom filtered",
|
|
||||||
ErrFuzzyCompareFailed: "fuzzy compare failed",
|
|
||||||
ErrFuzzyRedirect: "fuzzy redirect",
|
|
||||||
ErrFuzzyNotUnique: "not unique",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e ErrorType) Error() string {
|
|
||||||
return ErrMap[e]
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CheckSource = iota + 1
|
CheckSource = iota + 1
|
||||||
InitRandomSource
|
InitRandomSource
|
||||||
|
@ -61,6 +61,8 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bl.IsValid = false
|
bl.IsValid = false
|
||||||
|
bl.Reason = ErrUrlError.Error()
|
||||||
|
bl.ErrString = err.Error()
|
||||||
}
|
}
|
||||||
bl.Unique = UniqueHash(bl)
|
bl.Unique = UniqueHash(bl)
|
||||||
return bl
|
return bl
|
||||||
|
39
pkg/types.go
Normal file
39
pkg/types.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package pkg
|
||||||
|
|
||||||
|
type ErrorType uint
|
||||||
|
|
||||||
|
const (
|
||||||
|
NoErr ErrorType = iota
|
||||||
|
ErrBadStatus
|
||||||
|
ErrSameStatus
|
||||||
|
ErrRequestFailed
|
||||||
|
ErrWaf
|
||||||
|
ErrRedirect
|
||||||
|
ErrCompareFailed
|
||||||
|
ErrCustomCompareFailed
|
||||||
|
ErrCustomFilter
|
||||||
|
ErrFuzzyCompareFailed
|
||||||
|
ErrFuzzyRedirect
|
||||||
|
ErrFuzzyNotUnique
|
||||||
|
ErrUrlError
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrMap = map[ErrorType]string{
|
||||||
|
NoErr: "",
|
||||||
|
ErrBadStatus: "blacklist status",
|
||||||
|
ErrSameStatus: "same status with random baseline",
|
||||||
|
ErrRequestFailed: "request failed",
|
||||||
|
ErrWaf: "maybe banned by waf",
|
||||||
|
ErrRedirect: "duplicate redirect url",
|
||||||
|
ErrCompareFailed: "compare failed",
|
||||||
|
ErrCustomCompareFailed: "custom compare failed",
|
||||||
|
ErrCustomFilter: "custom filtered",
|
||||||
|
ErrFuzzyCompareFailed: "fuzzy compare failed",
|
||||||
|
ErrFuzzyRedirect: "fuzzy redirect",
|
||||||
|
ErrFuzzyNotUnique: "not unique",
|
||||||
|
ErrUrlError: "url parse error",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrorType) Error() string {
|
||||||
|
return ErrMap[e]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user