mirror of
https://github.com/chainreactors/spray.git
synced 2025-07-12 09:23:19 +00:00
优化compare逻辑, bodylength之差小于16, 即有可能判断为0或1
This commit is contained in:
parent
9b99c2a0b2
commit
2c135f2b06
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/chainreactors/parsers"
|
"github.com/chainreactors/parsers"
|
||||||
"github.com/chainreactors/spray/pkg/ihttp"
|
"github.com/chainreactors/spray/pkg/ihttp"
|
||||||
|
"math"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -90,14 +91,17 @@ func (bl *Baseline) Collect() {
|
|||||||
bl.Frameworks = FingerDetect(string(bl.Raw))
|
bl.Frameworks = FingerDetect(string(bl.Raw))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare if this equal other return true
|
// Compare
|
||||||
|
// if totally equal return 1
|
||||||
|
// if maybe equal return 0
|
||||||
|
// not equal return -1
|
||||||
func (bl *Baseline) Compare(other *Baseline) int {
|
func (bl *Baseline) Compare(other *Baseline) int {
|
||||||
if other.RedirectURL != "" && bl.RedirectURL == other.RedirectURL {
|
if other.RedirectURL != "" && bl.RedirectURL == other.RedirectURL {
|
||||||
// 如果重定向url不为空, 且与base不相同, 则说明不是同一个页面
|
// 如果重定向url不为空, 且与base不相同, 则说明不是同一个页面
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if bl.BodyLength == other.BodyLength {
|
if math.Abs(float64(bl.BodyLength-other.BodyLength)) < 16 {
|
||||||
// 如果body length相等且md5相等, 则说明是同一个页面
|
// 如果body length相等且md5相等, 则说明是同一个页面
|
||||||
if bl.BodyMd5 == parsers.Md5Hash(other.Body) {
|
if bl.BodyMd5 == parsers.Md5Hash(other.Body) {
|
||||||
// 如果length相等, md5也相等, 则判断为全同
|
// 如果length相等, md5也相等, 则判断为全同
|
||||||
@ -108,6 +112,7 @@ func (bl *Baseline) Compare(other *Baseline) int {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if strings.Contains(string(other.Body), other.Path) {
|
if strings.Contains(string(other.Body), other.Path) {
|
||||||
|
// 如果包含路径本身, 可能是路径自身的随机值影响结果
|
||||||
return 0
|
return 0
|
||||||
} else {
|
} else {
|
||||||
return -1
|
return -1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user