mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-26 13:11:53 +08:00
webtitle模块加入chardet
This commit is contained in:
+10
-4
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/saintfish/chardet"
|
||||||
"github.com/shadow1ng/fscan/WebScan"
|
"github.com/shadow1ng/fscan/WebScan"
|
||||||
"github.com/shadow1ng/fscan/WebScan/lib"
|
"github.com/shadow1ng/fscan/WebScan/lib"
|
||||||
"github.com/shadow1ng/fscan/common"
|
"github.com/shadow1ng/fscan/common"
|
||||||
@@ -51,7 +52,6 @@ func GOWebTitle(info *common.HostInfo) error {
|
|||||||
info.Url = fmt.Sprintf("http://%s", info.Url)
|
info.Url = fmt.Sprintf("http://%s", info.Url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err, result, CheckData := geturl(info, 1, CheckData)
|
err, result, CheckData := geturl(info, 1, CheckData)
|
||||||
if err != nil && !strings.Contains(err.Error(), "EOF") {
|
if err != nil && !strings.Contains(err.Error(), "EOF") {
|
||||||
return err
|
return err
|
||||||
@@ -173,9 +173,15 @@ func geturl(info *common.HostInfo, flag int, CheckData []WebScan.CheckDatas) (er
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
encoding := GetEncoding()
|
encode := GetEncoding()
|
||||||
_, charsetName, _ := charset.DetermineEncoding(body, "")
|
_, encode1, _ := charset.DetermineEncoding(body, "")
|
||||||
if encoding == "gbk" || encoding == "gb2312" || charsetName == "gbk" {
|
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)
|
titleGBK, err := Decodegbk(text)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
title = string(titleGBK)
|
title = string(titleGBK)
|
||||||
|
|||||||
Reference in New Issue
Block a user