diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 79346cbf5..02e1df74a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -51,7 +51,6 @@ jobs: HUNTER_API_KEY: ${{secrets.HUNTER_API_KEY}} INTELX_API_KEY: ${{secrets.INTELX_API_KEY}} LEAKIX_API_KEY: ${{secrets.LEAKIX_API_KEY}} - PASSIVETOTAL_API_KEY: ${{secrets.PASSIVETOTAL_API_KEY}} QUAKE_API_KEY: ${{secrets.QUAKE_API_KEY}} ROBTEX_API_KEY: ${{secrets.ROBTEX_API_KEY}} SECURITYTRAILS_API_KEY: ${{secrets.SECURITYTRAILS_API_KEY}} diff --git a/v2/pkg/passive/sources.go b/v2/pkg/passive/sources.go index b8ce15472..3b581b594 100644 --- a/v2/pkg/passive/sources.go +++ b/v2/pkg/passive/sources.go @@ -34,7 +34,6 @@ import ( "github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/intelx" "github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/leakix" "github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/netlas" - "github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/passivetotal" "github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/quake" "github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/rapiddns" "github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/redhuntlabs" @@ -75,7 +74,6 @@ var AllSources = [...]subscraping.Source{ &intelx.Source{}, &netlas.Source{}, &leakix.Source{}, - &passivetotal.Source{}, &quake.Source{}, &rapiddns.Source{}, &redhuntlabs.Source{}, @@ -97,9 +95,7 @@ var AllSources = [...]subscraping.Source{ } var sourceWarnings = mapsutil.NewSyncLockMap[string, string]( - mapsutil.WithMap(mapsutil.Map[string, string]{ - "passivetotal": "New API credentials for PassiveTotal can't be generated, but existing user account credentials are still functional. Please ensure your integrations are using valid credentials.", - })) + mapsutil.WithMap(mapsutil.Map[string, string]{})) var NameSourceMap = make(map[string]subscraping.Source, len(AllSources)) diff --git a/v2/pkg/passive/sources_test.go b/v2/pkg/passive/sources_test.go index 3223117e3..916e6c82a 100644 --- a/v2/pkg/passive/sources_test.go +++ b/v2/pkg/passive/sources_test.go @@ -33,7 +33,6 @@ var ( "hackertarget", "intelx", "netlas", - "passivetotal", "quake", "rapiddns", "redhuntlabs", @@ -74,7 +73,6 @@ var ( "fullhunt", "hackertarget", "intelx", - "passivetotal", "quake", "redhuntlabs", "robtex", @@ -100,7 +98,6 @@ var ( "dnsdb", "digitorus", "hackertarget", - "passivetotal", "securitytrails", "virustotal", "leakix", diff --git a/v2/pkg/subscraping/sources/passivetotal/passivetotal.go b/v2/pkg/subscraping/sources/passivetotal/passivetotal.go deleted file mode 100644 index 1492d0d2a..000000000 --- a/v2/pkg/subscraping/sources/passivetotal/passivetotal.go +++ /dev/null @@ -1,126 +0,0 @@ -// Package passivetotal logic -package passivetotal - -import ( - "bytes" - "context" - "regexp" - "time" - - jsoniter "github.com/json-iterator/go" - - "github.com/projectdiscovery/subfinder/v2/pkg/subscraping" -) - -var passiveTotalFilterRegex = regexp.MustCompile(`^(?:\d{1,3}\.){3}\d{1,3}\\032`) - -type response struct { - Subdomains []string `json:"subdomains"` -} - -// Source is the passive scraping agent -type Source struct { - apiKeys []apiKey - timeTaken time.Duration - errors int - results int - skipped bool -} - -type apiKey struct { - username string - password string -} - -// Run function returns all subdomains found with the service -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.username == "" || randomApiKey.password == "" { - s.skipped = true - return - } - - // Create JSON Get body - var request = []byte(`{"query":"` + domain + `"}`) - - resp, err := session.HTTPRequest( - ctx, - "GET", - "https://api.passivetotal.org/v2/enrichment/subdomains", - "", - map[string]string{"Content-Type": "application/json"}, - bytes.NewBuffer(request), - subscraping.BasicAuth{Username: randomApiKey.username, Password: randomApiKey.password}, - ) - if err != nil { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err} - s.errors++ - session.DiscardHTTPResponse(resp) - return - } - - var data response - err = jsoniter.NewDecoder(resp.Body).Decode(&data) - if err != nil { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err} - s.errors++ - resp.Body.Close() - return - } - resp.Body.Close() - - for _, subdomain := range data.Subdomains { - // skip entries like xxx.xxx.xxx.xxx\032domain.tld - if passiveTotalFilterRegex.MatchString(subdomain) { - continue - } - finalSubdomain := subdomain + "." + domain - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: finalSubdomain} - s.results++ - } - }() - - return results -} - -// Name returns the name of the source -func (s *Source) Name() string { - return "passivetotal" -} - -func (s *Source) IsDefault() bool { - return true -} - -func (s *Source) HasRecursiveSupport() bool { - return true -} - -func (s *Source) NeedsKey() bool { - return true -} - -func (s *Source) AddApiKeys(keys []string) { - s.apiKeys = subscraping.CreateApiKeys(keys, func(k, v string) apiKey { - return apiKey{k, v} - }) -} - -func (s *Source) Statistics() subscraping.Statistics { - return subscraping.Statistics{ - Errors: s.errors, - Results: s.results, - TimeTaken: s.timeTaken, - Skipped: s.skipped, - } -}