-
Notifications
You must be signed in to change notification settings - Fork 2
/
remote_core.go
53 lines (49 loc) · 1.27 KB
/
remote_core.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"io/ioutil"
"net/http"
"regexp"
"strings"
"time"
"github.com/sirupsen/logrus"
)
func RunRemoteCore(domain, area string) (output []string) {
logrus.Info("[+]Finding ips remote core...")
resp, err := http.Get("http://en.ipip.net/dns.php?a=dig&host=" + domain + "&area%5B%5D=" + area)
if err != nil {
logrus.Error(err)
return
}
defer resp.Body.Close() //在回复后必须关闭回复的主体
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
logrus.Error(err)
return
}
r := regexp.MustCompile(`\d+\.\d+\.\d+\.\d+`)
iplist := r.FindAll(body, -1)
logrus.Infof("[+]Got domain! \n%s ", iplist)
for _, ip := range iplist {
output = append(output, string(ip[:]))
}
return output
}
func Delay(domain, ip string) time.Duration {
starttime := time.Now()
Client := &http.Client{Timeout: time.Duration(5 * time.Second)}
req, err := http.NewRequest("GET", "https://"+ip+"/", nil)
if err != nil {
logrus.Error(err)
return time.Duration(-1)
}
req.Host = domain
resp, err := Client.Do(req)
if err != nil && strings.Contains(err.Error(), "x509: cannot validate certificate ") {
return time.Since(starttime)
} else if err != nil {
logrus.Error(err)
return time.Duration(-1)
}
defer resp.Body.Close()
return time.Since(starttime)
}