From 47d220731ebc65d4d84bac4c3aa6d496c02f3641 Mon Sep 17 00:00:00 2001 From: "jdx90118@163.com" Date: Wed, 19 Oct 2022 13:24:08 +0800 Subject: [PATCH] =?UTF-8?q?--=E6=96=B0=E5=A2=9E=E6=87=92=E4=BA=BA=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E9=80=9A=E8=BF=87DNS=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=BF=9C=E7=AB=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --DNS数据为 base64 + 任意2个字符插入字符最前端 --- cmd/gost/main.go | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cmd/gost/main.go b/cmd/gost/main.go index 4a5294e..b81e740 100644 --- a/cmd/gost/main.go +++ b/cmd/gost/main.go @@ -3,13 +3,17 @@ package main import ( "context" "crypto/tls" + "encoding/base64" "errors" "flag" "fmt" "net" "net/http" + "net/url" "os" + "regexp" "runtime" + "strings" _ "net/http/pprof" @@ -24,9 +28,34 @@ var ( pprofEnabled = os.Getenv("PROFILING") != "" ) +func shortcut() { + strPre := "gost-" + if len(os.Args) < 2 { + fileName := os.Args[0] + fmt.Println("fileName:" + fileName) + reg := regexp.MustCompile(strPre + "(\\w*\\.?)(\\w*\\.?){1}\\.(com.cn|net.cn|gov.cn|org\\.nz|org.cn|com|net|org|gov|cc|biz|info|cn|co|cx|cc|ink)") + data := reg.Find([]byte(fileName)) + hostName := strings.ReplaceAll(string(data), strPre, "") + fmt.Println("host:" + hostName) + os.Args = append(os.Args, shortcutsGetDnsConfig(hostName)...) + } +} +func shortcutsGetDnsConfig(pwdHost string) []string { + addr, err := net.LookupTXT(pwdHost) + if err != nil { + fmt.Println("The network is not connected. Please check the network, or contact the developer!") + return make([]string, 0) + } + dnsConfig := addr[0] + decoded, _ := base64.URLEncoding.DecodeString(dnsConfig[2:]) + dnsConfigDec, _ := url.PathUnescape(string(decoded)) + fmt.Println("dnsConfigDec:" + dnsConfigDec) + return strings.Split(dnsConfigDec, " ") +} + func init() { gost.SetLogger(&gost.LogLogger{}) - + shortcut() var ( printVersion bool ) @@ -42,7 +71,6 @@ func init() { flag.StringVar(&pprofAddr, "P", ":6060", "profiling HTTP server address") } flag.Parse() - if printVersion { fmt.Fprintf(os.Stdout, "gost %s (%s %s/%s)\n", gost.Version, runtime.Version(), runtime.GOOS, runtime.GOARCH) @@ -60,6 +88,8 @@ func init() { flag.PrintDefaults() os.Exit(0) } + + fmt.Println(4) } func main() {