这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/passive/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/virustotal"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/waybackarchive"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/whoisxmlapi"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/windvane"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/zoomeyeapi"
mapsutil "github.com/projectdiscovery/utils/maps"
)
Expand Down Expand Up @@ -95,6 +96,7 @@ var AllSources = [...]subscraping.Source{
&virustotal.Source{},
&waybackarchive.Source{},
&whoisxmlapi.Source{},
&windvane.Source{},
&zoomeyeapi.Source{},
&facebook.Source{},
// &threatminer.Source{}, // failing api
Expand Down
2 changes: 2 additions & 0 deletions pkg/passive/sources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (
"virustotal",
"waybackarchive",
"whoisxmlapi",
"windvane",
"zoomeyeapi",
"hunter",
"leakix",
Expand Down Expand Up @@ -85,6 +86,7 @@ var (
"rsecloud",
"securitytrails",
"shodan",
"windvane",
"virustotal",
"whoisxmlapi",
"hunter",
Expand Down
145 changes: 145 additions & 0 deletions pkg/subscraping/sources/windvane/windvane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Package windvane logic
package windvane

import (
"bytes"
"context"
"encoding/json"
"net/http"
"strconv"
"time"

"github.com/projectdiscovery/subfinder/v2/pkg/subscraping"
)

type response struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data responseData `json:"data"`
}

type responseData struct {
List []domainEntry `json:"list"`
PageResponse pageInfo `json:"page_response"`
}

type domainEntry struct {
Domain string `json:"domain"`
}

type pageInfo struct {
Total string `json:"total"`
Count string `json:"count"`
TotalPage string `json:"total_page"`
}

type Source struct {
apiKeys []string
timeTaken time.Duration
errors int
results int
skipped bool
}

func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Session) <-chan subscraping.Result {
results := make(chan subscraping.Result)
s.errors = 0
s.results = 0

go func() {
defer func(startTime time.Time) {
s.timeTaken = time.Since(startTime)
close(results)
}(time.Now())

randomApiKey := subscraping.PickRandom(s.apiKeys, s.Name())
if randomApiKey == "" {
s.skipped = true
return
}

headers := map[string]string{"Content-Type": "application/json", "X-Api-Key": randomApiKey}

page := 1
count := 1000
for {
var resp *http.Response
var err error

requestBody, _ := json.Marshal(map[string]interface{}{"domain": domain, "page_request": map[string]int{"page": page, "count": count}})
resp, err = session.Post(ctx, "https://windvane.lichoin.com/trpc.backendhub.public.WindvaneService/ListSubDomain",
"", headers, bytes.NewReader(requestBody))

if err != nil {
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err}
s.errors++
session.DiscardHTTPResponse(resp)
return
}

defer session.DiscardHTTPResponse(resp)

var windvaneResponse response
err = json.NewDecoder(resp.Body).Decode(&windvaneResponse)
if err != nil {
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err}
s.errors++
session.DiscardHTTPResponse(resp)
return
}

for _, record := range windvaneResponse.Data.List {
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: record.Domain}
s.results++
}

pageInfo := windvaneResponse.Data.PageResponse
var totalRecords, recordsPerPage int

if totalRecords, err = strconv.Atoi(pageInfo.Total); err != nil {
break
}
if recordsPerPage, err = strconv.Atoi(pageInfo.Count); err != nil {
break
}

if (page-1)*recordsPerPage >= totalRecords {
break
}

page++
}

}()

return results
}

func (s *Source) Name() string {
return "windvane"
}

func (s *Source) IsDefault() bool {
return true
}

func (s *Source) HasRecursiveSupport() bool {
return false
}

func (s *Source) NeedsKey() bool {
return true
}

func (s *Source) AddApiKeys(keys []string) {
s.apiKeys = keys
}

func (s *Source) Statistics() subscraping.Statistics {
return subscraping.Statistics{
Errors: s.errors,
Results: s.results,
TimeTaken: s.timeTaken,
Skipped: s.skipped,
}
}
Loading