-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
178 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |