Update webtitle.go

This commit is contained in:
影舞者 2023-11-13 11:27:34 +08:00 committed by GitHub
parent 6cd1ee75f5
commit 268f7d2aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,23 +18,23 @@ import (
"golang.org/x/text/encoding/simplifiedchinese" "golang.org/x/text/encoding/simplifiedchinese"
) )
func WebTitle(info common.HostInfo, flags common.Flags) error { func WebTitle(info *common.HostInfo) error {
if flags.Scantype == "webpoc" { if common.Scantype == "webpoc" {
WebScan.WebScan(info, flags) WebScan.WebScan(info)
return nil return nil
} }
err, CheckData := GOWebTitle(info, flags) err, CheckData := GOWebTitle(info)
info.Infostr = WebScan.InfoCheck(info.Url, &CheckData) info.Infostr = WebScan.InfoCheck(info.Url, &CheckData)
if flags.IsWebCan && err == nil { if !common.NoWebCan && err == nil {
WebScan.WebScan(info, flags) WebScan.WebScan(info)
} else { } else {
errlog := fmt.Sprintf("[-] webtitle %v %v", info.Url, err) errlog := fmt.Sprintf("[-] webtitle %v %v", info.Url, err)
common.LogError(errlog) common.LogError(errlog)
} }
return err return err
} }
func GOWebTitle(info common.HostInfo, flags common.Flags) (err error, CheckData []WebScan.CheckDatas) { func GOWebTitle(info *common.HostInfo) (err error, CheckData []WebScan.CheckDatas) {
if info.Url == "" { if info.Url == "" {
switch info.Ports { switch info.Ports {
case "80": case "80":
@ -43,26 +43,26 @@ func GOWebTitle(info common.HostInfo, flags common.Flags) (err error, CheckData
info.Url = fmt.Sprintf("https://%s", info.Host) info.Url = fmt.Sprintf("https://%s", info.Host)
default: default:
host := fmt.Sprintf("%s:%s", info.Host, info.Ports) host := fmt.Sprintf("%s:%s", info.Host, info.Ports)
protocol := GetProtocol(host, common.Socks5{Address: flags.Socks5Proxy}, flags.Timeout) protocol := GetProtocol(host, common.Timeout)
info.Url = fmt.Sprintf("%s://%s:%s", protocol, info.Host, info.Ports) info.Url = fmt.Sprintf("%s://%s:%s", protocol, info.Host, info.Ports)
} }
} else { } else {
if !strings.Contains(info.Url, "://") { if !strings.Contains(info.Url, "://") {
host := strings.Split(info.Url, "/")[0] host := strings.Split(info.Url, "/")[0]
protocol := GetProtocol(host, common.Socks5{Address: flags.Socks5Proxy}, flags.Timeout) protocol := GetProtocol(host, common.Timeout)
info.Url = fmt.Sprintf("%s://%s", protocol, info.Url) info.Url = fmt.Sprintf("%s://%s", protocol, info.Url)
} }
} }
err, result, CheckData := geturl(info, flags, 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 return
} }
// there is a jump //有跳转
if strings.Contains(result, "://") { if strings.Contains(result, "://") {
info.Url = result info.Url = result
err, result, CheckData = geturl(info, flags, 3, CheckData) err, result, CheckData = geturl(info, 3, CheckData)
if err != nil { if err != nil {
return return
} }
@ -70,24 +70,25 @@ func GOWebTitle(info common.HostInfo, flags common.Flags) (err error, CheckData
if result == "https" && !strings.HasPrefix(info.Url, "https://") { if result == "https" && !strings.HasPrefix(info.Url, "https://") {
info.Url = strings.Replace(info.Url, "http://", "https://", 1) info.Url = strings.Replace(info.Url, "http://", "https://", 1)
err, result, CheckData = geturl(info, flags, 1, CheckData) err, result, CheckData = geturl(info, 1, CheckData)
// there is a jump //有跳转
if strings.Contains(result, "://") { if strings.Contains(result, "://") {
info.Url = result info.Url = result
err, _, CheckData = geturl(info, flags, 3, CheckData) err, _, CheckData = geturl(info, 3, CheckData)
if err != nil { if err != nil {
return return
} }
} }
} }
//是否访问图标
//err, _, CheckData = geturl(info, 2, CheckData)
if err != nil { if err != nil {
return return
} }
return return
} }
func geturl(info common.HostInfo, flags common.Flags, flag int, CheckData []WebScan.CheckDatas) (error, string, []WebScan.CheckDatas) { func geturl(info *common.HostInfo, flag int, CheckData []WebScan.CheckDatas) (error, string, []WebScan.CheckDatas) {
//flag 1 first try //flag 1 first try
//flag 2 /favicon.ico //flag 2 /favicon.ico
//flag 3 302 //flag 3 302
@ -112,7 +113,11 @@ func geturl(info common.HostInfo, flags common.Flags, flag int, CheckData []WebS
if common.Cookie != "" { if common.Cookie != "" {
req.Header.Set("Cookie", common.Cookie) req.Header.Set("Cookie", common.Cookie)
} }
//if common.Pocinfo.Cookie != "" {
// req.Header.Set("Cookie", "rememberMe=1;"+common.Pocinfo.Cookie)
//} else {
// req.Header.Set("Cookie", "rememberMe=1")
//}
req.Header.Set("Connection", "close") req.Header.Set("Connection", "close")
var client *http.Client var client *http.Client
if flag == 1 { if flag == 1 {
@ -149,7 +154,7 @@ func geturl(info common.HostInfo, flags common.Flags, flag int, CheckData []WebS
} }
result := fmt.Sprintf("[*] WebTitle: %-25v code:%-3v len:%-6v title:%v", resp.Request.URL, resp.StatusCode, length, title) result := fmt.Sprintf("[*] WebTitle: %-25v code:%-3v len:%-6v title:%v", resp.Request.URL, resp.StatusCode, length, title)
if reurl != "" { if reurl != "" {
result += fmt.Sprintf(" jump url: %s", reurl) result += fmt.Sprintf(" 跳转url: %s", reurl)
} }
common.LogSuccess(result) common.LogSuccess(result)
} }
@ -210,20 +215,21 @@ func gettitle(body []byte) (title string) {
return return
} }
func GetProtocol(host string, proxy common.Socks5, Timeout int64) (protocol string) { func GetProtocol(host string, Timeout int64) (protocol string) {
protocol = "http"
//如果端口是80或443,跳过Protocol判断
if strings.HasSuffix(host, ":80") || !strings.Contains(host, ":") { if strings.HasSuffix(host, ":80") || !strings.Contains(host, ":") {
return "http" return
} else if strings.HasSuffix(host, ":443") {
protocol = "https"
return
} }
if strings.HasSuffix(host, ":443") { socksconn, err := common.WrapperTcpWithTimeout("tcp", host, time.Duration(Timeout)*time.Second)
return "https"
}
socksconn, err := common.WrapperTcpWithTimeout("tcp", host, proxy, time.Duration(Timeout)*time.Second)
if err != nil { if err != nil {
return return
} }
conn := tls.Client(socksconn, &tls.Config{InsecureSkipVerify: true}) conn := tls.Client(socksconn, &tls.Config{MinVersion: tls.VersionTLS10, InsecureSkipVerify: true})
defer func() { defer func() {
if conn != nil { if conn != nil {
defer func() { defer func() {