Skip to content

Commit

Permalink
fix GhostTroops#28 2022-07-22
Browse files Browse the repository at this point in the history
  • Loading branch information
x51pwn committed Jul 22, 2022
1 parent 2fbc932 commit 13e20ca
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions lib/HoneypotDetection.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var ipCIDS = regexp.MustCompile("^(\\d+\\.){3}\\d+\\/\\d+$")
// 添加蜜罐检测,并自动跳过目标,默认false跳过蜜罐检测
// 考虑内存缓存结果
func HoneyportDetection(host string) bool {
if 5 > len(host) || ipCIDS.MatchString(host) {
if !EnableHoneyportDetection || 5 > len(host) || ipCIDS.MatchString(host) {
return false
}
if "http" != strings.ToLower(host[0:4]) {
Expand All @@ -31,40 +31,40 @@ func HoneyportDetection(host string) bool {
return false
}
szK := oUrl.Scheme + "//" + oUrl.Hostname()
if EnableHoneyportDetection {
if v, ok := hdCache.Load(szK); ok {
return v.(bool)
}
if nil == err {
timeout := time.Duration(8 * time.Second)
var tr *http.Transport

tr = &http.Transport{
MaxIdleConnsPerHost: -1,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DisableKeepAlives: true,
}
client := http.Client{
Timeout: timeout,
Transport: tr,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse /* 不进入重定向 */
},
}
resp, err := client.Head(szK)
if err == nil {
defer resp.Body.Close()
if resp.StatusCode == 200 {
if a, ok := resp.Header["Server"]; ok {
if 50 < len(a[0]) || 3 < len(strings.Split(a[0], ",")) {
hdCache.Store(szK, true)
return true
}
if v, ok := hdCache.Load(szK); ok {
return v.(bool)
}
if nil == err {
timeout := time.Duration(8 * time.Second)
var tr *http.Transport

tr = &http.Transport{
MaxIdleConnsPerHost: -1,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DisableKeepAlives: true,
}
client := http.Client{
Timeout: timeout,
Transport: tr,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse /* 不进入重定向 */
},
}
resp, err := client.Head(szK)
if err == nil {
defer resp.Body.Close()
if resp.StatusCode == 200 {
if a, ok := resp.Header["Server"]; ok {
if 50 < len(a[0]) || 3 < len(strings.Split(a[0], ",")) {
hdCache.Store(szK, true)
return true
}
}
}
}
hdCache.Store(szK, false)
}
hdCache.Store(szK, false)

return false
}

0 comments on commit 13e20ca

Please sign in to comment.