From 38917a3d1e2b405bd6b5ee644403cf44f1c3a90b Mon Sep 17 00:00:00 2001 From: shadowabi <50265741+shadowabi@users.noreply.github.com> Date: Wed, 15 May 2024 16:29:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Edaydaymap=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++- cmd/all/all.go | 2 ++ cmd/daydaymap/daydaymap.go | 49 ++++++++++++++++++++++++++++++++++++ cmd/fofa/fofa.go | 2 +- cmd/hunter/hunter.go | 2 +- cmd/netlas/netlas.go | 2 +- cmd/pulsedive/pulsedive.go | 2 +- cmd/quake/quake.go | 2 +- cmd/virustotal/virustotal.go | 2 +- cmd/zoomeye/zoomeye.go | 2 +- define/var.go | 1 + main/main.go | 1 + pkg/data.go | 8 +++--- pkg/daydaymap/data.go | 47 ++++++++++++++++++++++++++++++++++ pkg/daydaymap/output.go | 24 ++++++++++++++++++ pkg/daydaymap/req.go | 40 +++++++++++++++++++++++++++++ 16 files changed, 178 insertions(+), 12 deletions(-) create mode 100644 cmd/daydaymap/daydaymap.go create mode 100644 pkg/daydaymap/data.go create mode 100644 pkg/daydaymap/output.go create mode 100644 pkg/daydaymap/req.go diff --git a/README.md b/README.md index 6ae5af9..18c2889 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # AutoDomain -自动提取主域名/IP,并调用fofa、quake、hunter搜集子域名,可配合指纹扫描工具达到快速资产整理 +自动提取域名/IP,并调用fofa、quake、hunter等测绘工具搜集子域名,可配合指纹扫描工具达到快速资产整理 本项目所使用的fofa、quake API参考自https://github.com/EASY233/Finger hunter API参考自https://github.com/W01fh4cker/hunter-to-excel/ @@ -25,6 +25,7 @@ config.json的填写内容应该如下: "HunterKey": "", "ZoomeyeKey": "", "PulsediveKey": "" + "DaydaymapKey": "" } ``` 填入的对应内容可使用对应的指定模块 @@ -42,6 +43,7 @@ Usage: Available Commands: all search domain from all engine + daydaymap search domain from daydaymap fofa search domain from fofa help Help about any command hunter search domain from hunter diff --git a/cmd/all/all.go b/cmd/all/all.go index fe8f06f..3074fa8 100644 --- a/cmd/all/all.go +++ b/cmd/all/all.go @@ -2,6 +2,7 @@ package all import ( "github.com/shadowabi/AutoDomain_rebuild/cmd" + "github.com/shadowabi/AutoDomain_rebuild/cmd/daydaymap" "github.com/shadowabi/AutoDomain_rebuild/cmd/fofa" "github.com/shadowabi/AutoDomain_rebuild/cmd/hunter" "github.com/shadowabi/AutoDomain_rebuild/cmd/netlas" @@ -23,6 +24,7 @@ func init() { AllCmd.AddCommand(quake.QuakeCmd) AllCmd.AddCommand(virustotal.VirusTotalCmd) AllCmd.AddCommand(zoomeye.ZoomeyeCmd) + AllCmd.AddCommand(daydaymap.DaydayMapCmd) } var AllCmd = &cobra.Command{ diff --git a/cmd/daydaymap/daydaymap.go b/cmd/daydaymap/daydaymap.go new file mode 100644 index 0000000..e342004 --- /dev/null +++ b/cmd/daydaymap/daydaymap.go @@ -0,0 +1,49 @@ +package daydaymap + +import ( + "errors" + "fmt" + "github.com/shadowabi/AutoDomain_rebuild/cmd" + "github.com/shadowabi/AutoDomain_rebuild/config" + "github.com/shadowabi/AutoDomain_rebuild/define" + "github.com/shadowabi/AutoDomain_rebuild/pkg" + "github.com/shadowabi/AutoDomain_rebuild/pkg/daydaymap" + "github.com/spf13/cobra" +) + +func init() { + cmd.RootCmd.AddCommand(DaydayMapCmd) +} + +var DaydayMapCmd = &cobra.Command{ + Use: "daydaymap", + Short: "search domain from daydaymap", + PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + if config.C.DaydaymapKey == "" { + return errors.New("未配置 daydaymap 相关的凭证") + } + return nil + }, + Run: func(cmd *cobra.Command, args []string) { + define.Once.Do(pkg.GlobalRun) + fmt.Printf("[+] daydaymap is working...\n") + + client := pkg.GenerateHTTPClient(define.TimeOut) + reqString := daydaymap.MergeReqListToReqString(define.ReqIpList, define.ReqDomainList) + reqBody := daydaymap.DayDayMapRequest(client, reqString, 1) // find result total + reqResult := daydaymap.ParseDaydaymapResult(reqBody...) + reqBody = daydaymap.DayDayMapRequest(client, reqString, reqResult[0].Data.Total) // real query + reqResult = daydaymap.ParseDaydaymapResult(reqBody...) + + chanNum := cap(reqResult) + if chanNum != 0 { + resultChannel := make(chan []string, chanNum) + resultChannel <- daydaymap.PurgeDomainResult(reqResult...) + close(resultChannel) + + pkg.FetchResultFromChanel(resultChannel) + } + + fmt.Printf("[+] daydaymap search complete\n") + }, +} diff --git a/cmd/fofa/fofa.go b/cmd/fofa/fofa.go index 00669ed..c4a7d8f 100644 --- a/cmd/fofa/fofa.go +++ b/cmd/fofa/fofa.go @@ -41,7 +41,7 @@ var FofaCmd = &cobra.Command{ reqResult = append(reqResult, reqResult2...) } - chanNum := len(reqResult) + chanNum := cap(reqResult) if chanNum != 0 { resultChannel := make(chan []string, chanNum) resultChannel <- fofa.PurgeDomainResult(reqResult...) diff --git a/cmd/hunter/hunter.go b/cmd/hunter/hunter.go index 3d8cb0d..0c1048f 100644 --- a/cmd/hunter/hunter.go +++ b/cmd/hunter/hunter.go @@ -42,7 +42,7 @@ var HunterCmd = &cobra.Command{ reqResult = append(reqResult, reqResult2...) } - chanNum := len(reqResult) + chanNum := cap(reqResult) if chanNum != 0 { resultChannel := make(chan []string, chanNum) resultChannel <- hunter.PurgeDomainResult(reqResult...) diff --git a/cmd/netlas/netlas.go b/cmd/netlas/netlas.go index 279c69d..6473576 100644 --- a/cmd/netlas/netlas.go +++ b/cmd/netlas/netlas.go @@ -31,7 +31,7 @@ var NetlasCmd = &cobra.Command{ reqIpBody := netlas.NetlasIpRequest(client, define.ReqIpList...) reqIpResultList := netlas.ParseNetlasIpResult(reqIpBody...) - chanNum := len(reqDomainResultList) + len(reqIpResultList) + chanNum := cap(reqDomainResultList) + cap(reqIpResultList) if chanNum != 0 { resultChannel := make(chan []string, chanNum) if len(reqDomainResultList) != 0 { diff --git a/cmd/pulsedive/pulsedive.go b/cmd/pulsedive/pulsedive.go index b024fc7..2a602ad 100644 --- a/cmd/pulsedive/pulsedive.go +++ b/cmd/pulsedive/pulsedive.go @@ -33,7 +33,7 @@ var PulsediveCmd = &cobra.Command{ reqDomainBody := pulsedive.PulsediveDomainRequest(client, define.ReqDomainList...) reqDomainResultList := pulsedive.ParsePulsediveDomainResult(reqDomainBody...) - chanNum := len(reqDomainResultList) + chanNum := cap(reqDomainResultList) if chanNum != 0 { resultChannel := make(chan []string, chanNum) resultChannel <- pulsedive.PurgeDomainResult(reqDomainResultList...) diff --git a/cmd/quake/quake.go b/cmd/quake/quake.go index 3d0508f..7302675 100644 --- a/cmd/quake/quake.go +++ b/cmd/quake/quake.go @@ -42,7 +42,7 @@ var QuakeCmd = &cobra.Command{ reqResult = append(reqResult, reqResult2...) } - chanNum := len(reqResult) + chanNum := cap(reqResult) if chanNum != 0 { resultChannel := make(chan []string, chanNum) resultChannel <- quake.PurgeDomainResult(reqResult...) diff --git a/cmd/virustotal/virustotal.go b/cmd/virustotal/virustotal.go index 77bc236..fc4e526 100644 --- a/cmd/virustotal/virustotal.go +++ b/cmd/virustotal/virustotal.go @@ -28,7 +28,7 @@ var VirusTotalCmd = &cobra.Command{ reqDomainBody := virustotal.VirusTotalDomainRequest(client, define.ReqDomainList...) reqDomainResultList := virustotal.ParseVirusTotalDomainResult(reqDomainBody...) - chanNum := len(reqDomainResultList) + chanNum := cap(reqDomainResultList) if chanNum != 0 { resultChannel := make(chan []string, chanNum) resultChannel <- virustotal.PurgeDomainResult(reqDomainResultList...) diff --git a/cmd/zoomeye/zoomeye.go b/cmd/zoomeye/zoomeye.go index ace8090..ca6f0c8 100644 --- a/cmd/zoomeye/zoomeye.go +++ b/cmd/zoomeye/zoomeye.go @@ -36,7 +36,7 @@ var ZoomeyeCmd = &cobra.Command{ reqDomainBody := zoomeye.ZoomeyeDomainRequest(client, define.ReqDomainList...) reqDomainResultList := zoomeye.ParseZoomeyeDomainResult(reqDomainBody...) - chanNum := len(reqDomainResultList) + len(reqIpResultList) + chanNum := cap(reqDomainResultList) + cap(reqIpResultList) if chanNum != 0 { resultChannel := make(chan []string, chanNum) if len(reqDomainResultList) != 0 { diff --git a/define/var.go b/define/var.go index 872c9ec..78cbd4a 100644 --- a/define/var.go +++ b/define/var.go @@ -28,6 +28,7 @@ type Configure struct { HunterKey string `mapstructure:"HunterKey" json:"HunterKey" yaml:"HunterKey"` ZoomeyeKey string `mapstructure:"ZoomeyeKey" json:"ZoomeyeKey" yaml:"ZoomeyeKey"` PulsediveKey string `mapstructure:"PulsediveKey" json:"PulsediveKey" yaml:"PulsediveKey"` + DaydaymapKey string `mapstructure:"DaydaymapKey" json:"DaydaymapKey" yaml:"DaydaymapKey"` } var ModeToGrammar = map[string]string{ diff --git a/main/main.go b/main/main.go index ed9db4f..c7f2db3 100644 --- a/main/main.go +++ b/main/main.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/shadowabi/AutoDomain_rebuild/cmd" _ "github.com/shadowabi/AutoDomain_rebuild/cmd/all" + _ "github.com/shadowabi/AutoDomain_rebuild/cmd/daydaymap" _ "github.com/shadowabi/AutoDomain_rebuild/cmd/fofa" _ "github.com/shadowabi/AutoDomain_rebuild/cmd/hunter" _ "github.com/shadowabi/AutoDomain_rebuild/cmd/netlas" diff --git a/pkg/data.go b/pkg/data.go index 0ff0503..24a622e 100644 --- a/pkg/data.go +++ b/pkg/data.go @@ -69,11 +69,11 @@ func ConvertToReqDomainList(param ...string) (reqDomainList []string) { func MergeReqListToReqString(mode string, reqIpList []string, reqDomainList []string) (reqString string) { grammar := define.ModeToGrammar[mode] if grammar != "" { - for _, ip := range reqIpList { - reqString += "ip" + grammar + ip + " || " + for _, host := range reqIpList { + reqString += "ip" + grammar + host + " || " } - for _, ip := range reqDomainList { - reqString += "domain" + grammar + ip + " || " + for _, host := range reqDomainList { + reqString += "domain" + grammar + host + " || " } } reqString = strings.TrimSuffix(reqString, " || ") diff --git a/pkg/daydaymap/data.go b/pkg/daydaymap/data.go new file mode 100644 index 0000000..73a6b9a --- /dev/null +++ b/pkg/daydaymap/data.go @@ -0,0 +1,47 @@ +package daydaymap + +import ( + "encoding/base64" + "encoding/json" + "github.com/shadowabi/AutoDomain_rebuild/utils/Error" + "strings" +) + +func MergeReqListToReqString(reqIpList []string, reqDomainList []string) (reqString string) { + for _, host := range reqIpList { + reqString += "ip:" + "\"" + host + "\"" + " || " + } + for _, host := range reqDomainList { + reqString += "domain:" + "\"" + host + "\"" + " || " + } + reqString = strings.TrimSuffix(reqString, " || ") + reqString = base64.URLEncoding.EncodeToString([]byte(reqString)) + return reqString +} + +type ArrElement struct { + Domain string `json:"domain"` + Port int `json:"port"` + Ip string `json:"ip"` + Service string `json:"service"` +} + +type Data struct { + List []ArrElement `json:"list"` + Total int `json:"total"` +} + +type DaydaymapResponse struct { + Data Data `json:"data"` +} + +func ParseDaydaymapResult(reqBody ...string) (daydaymapRespList []DaydaymapResponse) { + if len(reqBody) != 0 { + for _, response := range reqBody { + var daydaymapResponse DaydaymapResponse + Error.HandleError(json.Unmarshal([]byte(response), &daydaymapResponse)) + daydaymapRespList = append(daydaymapRespList, daydaymapResponse) + } + } + return daydaymapRespList +} diff --git a/pkg/daydaymap/output.go b/pkg/daydaymap/output.go new file mode 100644 index 0000000..06bae21 --- /dev/null +++ b/pkg/daydaymap/output.go @@ -0,0 +1,24 @@ +package daydaymap + +import ( + "fmt" +) + +func PurgeDomainResult(daydaymapResponse ...DaydaymapResponse) (daydaymapDomainResult []string) { + if len(daydaymapResponse) != 0 { + for _, response := range daydaymapResponse { + for _, v := range response.Data.List { + if v.Service == "http" || v.Service == "https" { + result := "" + if v.Domain != "" { + result = fmt.Sprintf("%s://%s:%v", v.Service, v.Domain, v.Port) + } else { + result = fmt.Sprintf("%s://%v:%v", v.Service, v.Ip, v.Port) + } + daydaymapDomainResult = append(daydaymapDomainResult, result) + } + } + } + } + return daydaymapDomainResult +} diff --git a/pkg/daydaymap/req.go b/pkg/daydaymap/req.go new file mode 100644 index 0000000..e40555f --- /dev/null +++ b/pkg/daydaymap/req.go @@ -0,0 +1,40 @@ +package daydaymap + +import ( + "bytes" + "encoding/json" + "github.com/shadowabi/AutoDomain_rebuild/config" + "github.com/shadowabi/AutoDomain_rebuild/define" + "github.com/shadowabi/AutoDomain_rebuild/utils/Error" + net2 "github.com/shadowabi/AutoDomain_rebuild/utils/response" + "net/http" + "time" +) + +func DayDayMapRequest(client *http.Client, reqString string, totalList ...int) (respBody []string) { + if len(totalList) != 0 { + for _, total := range totalList { + data := struct { + Page int `json:"page"` + Size int `json:"page_size"` + Keyword string `json:"keyword"` + }{ + Page: 1, + Size: total, + Keyword: reqString, + } + dataJson, _ := json.Marshal(data) + dataReq := bytes.NewBuffer(dataJson) + req, _ := http.NewRequest("POST", "https://www.daydaymap.com/api/v1/raymap/search/all", dataReq) + req.Header.Set("User-Agent", define.UserAgent) + req.Header.Set("Content-Type", "application/json") + req.Header.Set("api-key", config.C.DaydaymapKey) + resp, err := client.Do(req) + time.Sleep(500 * time.Millisecond) + Error.HandleError(err) + respBody = append(respBody, net2.HandleResponse(resp)) + resp.Body.Close() + } + } + return respBody +}