From 88a350981fdc9ef4b6ae09267b9356472d46da98 Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Sat, 16 Jun 2018 19:09:28 +0530 Subject: [PATCH] Added Exclusive Sources to subfinder --- libsubfinder/engines/passive/passive.go | 57 +++++++++++++++++++++- libsubfinder/helper/state.go | 63 +++++++++++++------------ main.go | 1 + 3 files changed, 90 insertions(+), 31 deletions(-) diff --git a/libsubfinder/engines/passive/passive.go b/libsubfinder/engines/passive/passive.go index c5434f8..654ebc9 100644 --- a/libsubfinder/engines/passive/passive.go +++ b/libsubfinder/engines/passive/passive.go @@ -155,6 +155,57 @@ func (s *Source) enable(dataSources []string) { } } +func (s *Source) disable(dataSources []string) { + for _, source := range dataSources { + switch source { + case "ask": + s.Ask = false + case "baidu": + s.Baidu = false + case "bing": + s.Bing = false + case "censys": + s.Censys = false + case "certdb": + s.Certdb = false + case "certspotter": + s.Certspotter = false + case "crtsh": + s.Crtsh = false + case "dnsdb": + s.Dnsdb = false + case "dnsdumpster": + s.Dnsdumpster = false + case "findsubdomains": + s.Findsubdomains = false + case "hackertarget": + s.Hackertarget = false + case "netcraft": + s.Netcraft = false + case "passivetotal": + s.Passivetotal = false + case "ptrarchive": + s.Ptrarchive = false + case "riddler": + s.Riddler = false + case "securitytrails": + s.Securitytrails = false + case "threatcrowd": + s.Threatcrowd = false + case "threatminer": + s.Threatminer = false + case "virustotal": + s.Virustotal = false + case "waybackarchive": + s.Waybackarchive = false + case "certificatetransparency": + s.CertificateTransparency = false + case "ipv4info": + s.Ipv4Info = false + } + } +} + func (s *Source) printSummary() { if s.Ask { fmt.Printf("\nRunning Source: %sAsk%s", helper.Info, helper.Reset) @@ -442,7 +493,6 @@ func Enumerate(state *helper.State) []string { fmt.Printf("\n") if state.Sources == "all" { - // Search all data sources sourceConfig.enableAll() } else { // Check data sources and create a source configuration structure @@ -450,6 +500,11 @@ func Enumerate(state *helper.State) []string { sourceConfig.enable(dataSources) } + if state.ExcludeSource != "" { + dataSources := strings.Split(state.ExcludeSource, ",") + sourceConfig.disable(dataSources) + } + if !state.Silent { sourceConfig.printSummary() } diff --git a/libsubfinder/helper/state.go b/libsubfinder/helper/state.go index c324256..1ff5095 100644 --- a/libsubfinder/helper/state.go +++ b/libsubfinder/helper/state.go @@ -15,31 +15,32 @@ import ( // Holds the State read in from the CLI type State struct { - Color bool // Whether to use color or not - Threads int // Number of threads to use - Timeout int // Timeout for requests to different passive sources - Verbose bool // Show verbose information - Domain string // Domain name to find subdomains for - Recursive bool // Whether perform recursive subdomain discovery or not - Output string // Name of output file - Alive bool // Get only alive subdomains (x - no wildcards :-)) - IsJSON bool // Provide JSON output file - Wordlist string // Wordlist file for subdomains bruteforcing - Bruteforce bool // Flag to decide whether to bruteforce or not - WildcardIP []string // Wildcard IP Structure - IsWildcard bool // Does the host has wildcard subdomains, if yes parse them carefully - Sources string // Comma separated list of sources to use - Silent bool // Show only silent output or not - FinalResults []string // Contains final bruteforcing results - SetConfig string // Used for changing the current configuration file details - SetSetting string // Used for passing custom configuration to the application - DomainList string // List of domains to find subdomains for - OutputDir string // Directory to output results to if domain list is used - LoadResolver []string // Slice of resolvers to use - ComResolver string // Comma-separated list of resolvers to use - ListResolver string // File to load resolvers from - AquatoneJSON bool // Use aquatone style json format - OutputHandle *os.File // Handle to the output file used for output buffering + Color bool // Whether to use color or not + Threads int // Number of threads to use + Timeout int // Timeout for requests to different passive sources + Verbose bool // Show verbose information + Domain string // Domain name to find subdomains for + Recursive bool // Whether perform recursive subdomain discovery or not + Output string // Name of output file + Alive bool // Get only alive subdomains (x - no wildcards :-)) + IsJSON bool // Provide JSON output file + Wordlist string // Wordlist file for subdomains bruteforcing + Bruteforce bool // Flag to decide whether to bruteforce or not + WildcardIP []string // Wildcard IP Structure + IsWildcard bool // Does the host has wildcard subdomains, if yes parse them carefully + Sources string // Comma separated list of sources to use + Silent bool // Show only silent output or not + FinalResults []string // Contains final bruteforcing results + SetConfig string // Used for changing the current configuration file details + SetSetting string // Used for passing custom configuration to the application + DomainList string // List of domains to find subdomains for + OutputDir string // Directory to output results to if domain list is used + LoadResolver []string // Slice of resolvers to use + ComResolver string // Comma-separated list of resolvers to use + ListResolver string // File to load resolvers from + AquatoneJSON bool // Use aquatone style json format + ExcludeSource string // Sources to exclude + OutputHandle *os.File // Handle to the output file used for output buffering CurrentSettings Setting // Current application settings ConfigState Config // Current configuration file state @@ -61,10 +62,11 @@ type Config struct { } type Setting struct { - CensysPages string // Censys pages to check. For All, use "all" - AskPages string // Ask search pages to check - BaiduPages string // Ask search pages to check - BingPages string // Ask search pages to check + CensysPages string // Censys pages to check. For All, use "all" + AskPages string // Ask search pages to check + BaiduPages string // Ask search pages to check + BingPages string // Ask search pages to check + DogpilePages string } func InitializeSettings() (setting *Setting) { @@ -75,6 +77,7 @@ func InitializeSettings() (setting *Setting) { settings.AskPages = "15" settings.BaiduPages = "5" settings.BingPages = "50" + settings.DogpilePages = "16" return &settings } @@ -85,5 +88,5 @@ func InitState() (state State, err error) { setting := InitializeSettings() - return State{true, 10, 180, false, "", false, "", false, false, "", false, []string{}, true, "", false, []string{}, "", "", "", "", []string{}, "", "", false, nil, *setting, *config}, nil + return State{true, 10, 180, false, "", false, "", false, false, "", false, []string{}, true, "", false, []string{}, "", "", "", "", []string{}, "", "", false, "", nil, *setting, *config}, nil } diff --git a/main.go b/main.go index d468360..c700046 100644 --- a/main.go +++ b/main.go @@ -60,6 +60,7 @@ func ParseCmdLine() (state *helper.State, err error) { flag.StringVar(&s.OutputDir, "oD", "", "Directory to output results to ") flag.StringVar(&s.ComResolver, "r", "", "Comma-separated list of resolvers to use") flag.StringVar(&s.ListResolver, "rL", "", "Text file containing list of resolvers to use") + flag.StringVar(&s.ExcludeSource, "exclude-sources", "", "List of sources to exclude from enumeration") flag.BoolVar(&s.AquatoneJSON, "oT", false, "Use aquatone style json output format") flag.Parse()