-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from projectdiscovery/add-chaos
Add chaos data API as an individual source
- Loading branch information
Showing
6 changed files
with
64 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ sources: | |
- censys | ||
- certspotter | ||
- certspotterold | ||
- chaos | ||
- commoncrawl | ||
- crtsh | ||
- dnsdumpster | ||
|
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,43 @@ | ||
package chaos | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/projectdiscovery/chaos-client/pkg/chaos" | ||
"github.com/projectdiscovery/subfinder/pkg/subscraping" | ||
) | ||
|
||
// Source is the passive scraping agent | ||
type Source struct{} | ||
|
||
// 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) | ||
|
||
go func() { | ||
defer close(results) | ||
|
||
if session.Keys.Chaos == "" { | ||
return | ||
} | ||
|
||
chaosClient := chaos.New(session.Keys.Chaos) | ||
for result := range chaosClient.GetSubdomains(&chaos.SubdomainsRequest{ | ||
Domain: domain, | ||
}) { | ||
if result.Error != nil { | ||
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: result.Error} | ||
break | ||
} | ||
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: fmt.Sprintf("%s.%s", result.Subdomain, domain)} | ||
} | ||
}() | ||
|
||
return results | ||
} | ||
|
||
// Name returns the name of the source | ||
func (s *Source) Name() string { | ||
return "chaos" | ||
} |
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