From 2c135f2b064d9775138781a31d21f22bea07adda Mon Sep 17 00:00:00 2001 From: M09Ic Date: Fri, 11 Nov 2022 01:12:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96compare=E9=80=BB=E8=BE=91,=20?= =?UTF-8?q?bodylength=E4=B9=8B=E5=B7=AE=E5=B0=8F=E4=BA=8E16,=20=E5=8D=B3?= =?UTF-8?q?=E6=9C=89=E5=8F=AF=E8=83=BD=E5=88=A4=E6=96=AD=E4=B8=BA0?= =?UTF-8?q?=E6=88=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/baseline.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/baseline.go b/pkg/baseline.go index 598df69..a32a301 100644 --- a/pkg/baseline.go +++ b/pkg/baseline.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/chainreactors/parsers" "github.com/chainreactors/spray/pkg/ihttp" + "math" "net/url" "strconv" "strings" @@ -90,14 +91,17 @@ func (bl *Baseline) Collect() { 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 { if other.RedirectURL != "" && bl.RedirectURL == other.RedirectURL { // 如果重定向url不为空, 且与base不相同, 则说明不是同一个页面 return 1 } - if bl.BodyLength == other.BodyLength { + if math.Abs(float64(bl.BodyLength-other.BodyLength)) < 16 { // 如果body length相等且md5相等, 则说明是同一个页面 if bl.BodyMd5 == parsers.Md5Hash(other.Body) { // 如果length相等, md5也相等, 则判断为全同 @@ -108,6 +112,7 @@ func (bl *Baseline) Compare(other *Baseline) int { } } else { if strings.Contains(string(other.Body), other.Path) { + // 如果包含路径本身, 可能是路径自身的随机值影响结果 return 0 } else { return -1