From 4f3ff608abdd2706e2830973736256f6d9f04a0c Mon Sep 17 00:00:00 2001 From: shadow1ng Date: Tue, 18 May 2021 16:23:50 +0800 Subject: [PATCH] =?UTF-8?q?webtitle=E6=A8=A1=E5=9D=97=E5=8A=A0=E5=85=A5cha?= =?UTF-8?q?rdet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plugins/webtitle.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Plugins/webtitle.go b/Plugins/webtitle.go index 6aec724..38cb547 100644 --- a/Plugins/webtitle.go +++ b/Plugins/webtitle.go @@ -4,6 +4,7 @@ import ( "bytes" "compress/gzip" "fmt" + "github.com/saintfish/chardet" "github.com/shadow1ng/fscan/WebScan" "github.com/shadow1ng/fscan/WebScan/lib" "github.com/shadow1ng/fscan/common" @@ -51,7 +52,6 @@ func GOWebTitle(info *common.HostInfo) error { info.Url = fmt.Sprintf("http://%s", info.Url) } } - err, result, CheckData := geturl(info, 1, CheckData) if err != nil && !strings.Contains(err.Error(), "EOF") { return err @@ -173,9 +173,15 @@ func geturl(info *common.HostInfo, flag int, CheckData []WebScan.CheckDatas) (er } return "" } - encoding := GetEncoding() - _, charsetName, _ := charset.DetermineEncoding(body, "") - if encoding == "gbk" || encoding == "gb2312" || charsetName == "gbk" { + encode := GetEncoding() + _, encode1, _ := charset.DetermineEncoding(body, "") + var encode2 string + detector := chardet.NewTextDetector() + detectorstr, _ := detector.DetectBest(body) + if detectorstr != nil { + encode2 = detectorstr.Charset + } + if encode == "gbk" || encode == "gb2312" || encode1 == "gbk" || strings.Contains(strings.ToLower(encode2), "gb") { titleGBK, err := Decodegbk(text) if err == nil { title = string(titleGBK)