1. 使用 go mod 创建项目

2. 使用 import 绝对路径,代替 相对路径
This commit is contained in:
v1xingyue
2020-11-17 10:35:27 +08:00
parent 33121ead42
commit 57349aab7b
20 changed files with 484 additions and 445 deletions
+26 -25
View File
@@ -1,7 +1,6 @@
package Plugins
import (
"../common"
"fmt"
"io/ioutil"
"net/http"
@@ -9,47 +8,48 @@ import (
"strings"
"sync"
"time"
"github.com/shadow1ng/fscan/common"
)
func WebTitle(info *common.HostInfo,ch chan int,wg *sync.WaitGroup) (err error, result string) {
info.Url = fmt.Sprintf("http://%s:%s",info.Host,info.Ports)
err,result = geturl(info)
wg.Done()
func WebTitle(info *common.HostInfo, ch chan int, wg *sync.WaitGroup) (err error, result string) {
info.Url = fmt.Sprintf("http://%s:%s", info.Host, info.Ports)
err, result = geturl(info)
wg.Done()
<-ch
return err, result
}
func geturl(info *common.HostInfo) (err error, result string) {
url := info.Url
var client = &http.Client{Timeout:time.Duration(info.Timeout)*time.Second }
res,err:=http.NewRequest("GET",url,nil)
if err==nil{
res.Header.Add("User-agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
res.Header.Add("Accept","*/*")
res.Header.Add("Accept-Language","zh-CN,zh;q=0.9")
res.Header.Add("Accept-Encoding","gzip, deflate")
res.Header.Add("Connection","close")
resp,err:=client.Do(res)
if err==nil{
var client = &http.Client{Timeout: time.Duration(info.Timeout) * time.Second}
res, err := http.NewRequest("GET", url, nil)
if err == nil {
res.Header.Add("User-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
res.Header.Add("Accept", "*/*")
res.Header.Add("Accept-Language", "zh-CN,zh;q=0.9")
res.Header.Add("Accept-Encoding", "gzip, deflate")
res.Header.Add("Connection", "close")
resp, err := client.Do(res)
if err == nil {
defer resp.Body.Close()
var title string
body, _ := ioutil.ReadAll(resp.Body)
re :=regexp.MustCompile("<title>(.*)</title>")
find := re.FindAllStringSubmatch(string(body),-1)
if len(find) > 0{
re := regexp.MustCompile("<title>(.*)</title>")
find := re.FindAllStringSubmatch(string(body), -1)
if len(find) > 0 {
title = find[0][1]
}else {
} else {
title = "None"
}
if len(title) > 50{
if len(title) > 50 {
title = title[:50]
}
if resp.StatusCode == 400 && string(url[5]) != "https"{
if resp.StatusCode == 400 && string(url[5]) != "https" {
info.Url = strings.Replace(url, "http://", "https://", 1)
return geturl(info)
}else {
result = fmt.Sprintf("WebTitle:%v %v %v",url,resp.StatusCode,title)
} else {
result = fmt.Sprintf("WebTitle:%v %v %v", url, resp.StatusCode, title)
common.LogSuccess(result)
}
return err, result
@@ -57,6 +57,7 @@ func geturl(info *common.HostInfo) (err error, result string) {
}
return err, ""
}
//var client = &http.Client{
// Transport:&http.Transport{
// DialContext:(&net.Dialer{
@@ -80,4 +81,4 @@ func geturl(info *common.HostInfo) (err error, result string) {
// for k,v:=range header{
// res.Header.Add(k,v)
// }
//}
//}