From 80bec05573cfcfe3b2ef16253dd5a8f4374768aa Mon Sep 17 00:00:00 2001 From: zhangchengguo Date: Tue, 8 Mar 2022 16:22:50 +0800 Subject: [PATCH 1/3] fix readme golang demo for v2.5.0 --- README.md | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d6c91e316..2507cc482 100644 --- a/README.md +++ b/README.md @@ -242,23 +242,16 @@ import ( ) func main() { - config := runner.ConfigFile{ - // Use the default list of resolvers by marshaling it to the config - Resolvers: resolve.DefaultResolvers, - // Use the default list of passive sources - Sources: passive.DefaultSources, - // Use the default list of all passive sources - AllSources: passive.DefaultAllSources, - // Use the default list of recursive sources - Recursive: passive.DefaultRecursiveSources, - } - runnerInstance, err := runner.NewRunner(&runner.Options{ Threads: 10, // Thread controls the number of threads to use for active enumerations Timeout: 30, // Timeout is the seconds to wait for sources to respond MaxEnumerationTime: 10, // MaxEnumerationTime is the maximum amount of time in mins to wait for enumeration - YAMLConfig: config, - }) + Resolvers: resolve.DefaultResolvers, // Use the default list of resolvers by marshaling it to the config + Sources: passive.DefaultSources, // Use the default list of passive sources + AllSources: passive.DefaultAllSources, // Use the default list of all passive sources + Recursive: passive.DefaultRecursiveSources, // Use the default list of recursive sources + Providers: &runner.Providers{}, // Use empty api keys for all providers + }) buf := bytes.Buffer{} err = runnerInstance.EnumerateSingleDomain(context.Background(), "projectdiscovery.io", []io.Writer{&buf}) From 5157872cf9d9aae1d10b4c62b3849c1485317b69 Mon Sep 17 00:00:00 2001 From: Ignacio Feijoo Date: Thu, 24 Mar 2022 19:32:50 -0300 Subject: [PATCH 2/3] fix -silent switch still show banner --- v2/pkg/runner/banners.go | 10 +++++----- v2/pkg/runner/options.go | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index 7f11d2666..f15d9b3ad 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -12,6 +12,11 @@ const banner = ` / ___/ / / / __ \/ /_/ / __ \/ __ / _ \/ ___/ (__ ) /_/ / /_/ / __/ / / / / /_/ / __/ / /____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.5.0 + projectdiscovery.io + +Use with caution. You are responsible for your actions +Developers assume no liability and are not responsible for any misuse or damage. +By using subfinder, you also agree to the terms of the APIs used. ` // Version is the current version of subfinder @@ -20,11 +25,6 @@ const Version = `v2.5.0` // showBanner is used to show the banner to the user func showBanner() { gologger.Print().Msgf("%s\n", banner) - gologger.Print().Msgf("\t\tprojectdiscovery.io\n\n") - - gologger.Print().Msgf("Use with caution. You are responsible for your actions\n") - gologger.Print().Msgf("Developers assume no liability and are not responsible for any misuse or damage.\n") - gologger.Print().Msgf("By using subfinder, you also agree to the terms of the APIs used.\n\n") } // loadProvidersFrom runs the app with source config diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index ca20db7f8..7bed68f4a 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -65,7 +65,6 @@ type Options struct { // ParseOptions parses the command line flags provided by a user func ParseOptions() *Options { - showBanner() // Migrate config to provider config if fileutil.FileExists(defaultConfigLocation) && !fileutil.FileExists(defaultProviderConfigLocation) { @@ -80,9 +79,10 @@ func ParseOptions() *Options { } options := &Options{} + var err error flagSet := goflags.NewFlagSet() - flagSet.SetDescription(`Subfinder is a subdomain discovery tool that discovers subdomains for websites by using passive online sources.`) + flagSet.SetDescription(banner+"\nSubfinder is a subdomain discovery tool that discovers subdomains for websites by using passive online sources.") createGroup(flagSet, "input", "Input", flagSet.NormalizedStringSliceVarP(&options.Domain, "domain", "d", []string{}, "domains to find subdomains for"), @@ -131,7 +131,7 @@ func ParseOptions() *Options { flagSet.IntVar(&options.MaxEnumerationTime, "max-time", 10, "minutes to wait for enumeration results"), ) - if err := flagSet.Parse(); err != nil { + if err := flagSet.Parse(); err != nil { fmt.Println(err.Error()) os.Exit(1) } @@ -172,6 +172,10 @@ func ParseOptions() *Options { options.preProcessOptions() + if !options.Silent { + showBanner() + } + // Validate the options passed by the user and if any // invalid options have been used, exit. err = options.validateOptions() From 262226875bf541d87eddc7416e2c251fbafa7fa4 Mon Sep 17 00:00:00 2001 From: mzack Date: Wed, 30 Mar 2022 07:43:35 +0200 Subject: [PATCH 3/3] small refactor --- v2/pkg/runner/banners.go | 12 ++++++------ v2/pkg/runner/options.go | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index 6a024e653..f4448594a 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -11,12 +11,7 @@ const banner = ` _______ __/ /_ / __(_)___ ____/ /__ _____ / ___/ / / / __ \/ /_/ / __ \/ __ / _ \/ ___/ (__ ) /_/ / /_/ / __/ / / / / /_/ / __/ / -/____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.51-dev - projectdiscovery.io - -Use with caution. You are responsible for your actions -Developers assume no liability and are not responsible for any misuse or damage. -By using subfinder, you also agree to the terms of the APIs used. +/____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.5.1-dev ` // Version is the current version of subfinder @@ -25,6 +20,11 @@ const Version = `v2.5.1-dev` // showBanner is used to show the banner to the user func showBanner() { gologger.Print().Msgf("%s\n", banner) + gologger.Print().Msgf("\t\tprojectdiscovery.io\n\n") + + gologger.Print().Msgf("Use with caution. You are responsible for your actions\n") + gologger.Print().Msgf("Developers assume no liability and are not responsible for any misuse or damage.\n") + gologger.Print().Msgf("By using subfinder, you also agree to the terms of the APIs used.\n\n") } // loadProvidersFrom runs the app with source config diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index 771f29723..2ed3cac17 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -66,7 +66,6 @@ type Options struct { // ParseOptions parses the command line flags provided by a user func ParseOptions() *Options { - // Migrate config to provider config if fileutil.FileExists(defaultConfigLocation) && !fileutil.FileExists(defaultProviderConfigLocation) { gologger.Info().Msgf("Detected old %s config file, trying to migrate providers to %s\n", defaultConfigLocation, defaultProviderConfigLocation) @@ -83,7 +82,7 @@ func ParseOptions() *Options { var err error flagSet := goflags.NewFlagSet() - flagSet.SetDescription(banner+"\nSubfinder is a subdomain discovery tool that discovers subdomains for websites by using passive online sources.") + flagSet.SetDescription(`Subfinder is a subdomain discovery tool that discovers subdomains for websites by using passive online sources.`) createGroup(flagSet, "input", "Input", flagSet.NormalizedStringSliceVarP(&options.Domain, "domain", "d", []string{}, "domains to find subdomains for"), @@ -133,7 +132,7 @@ func ParseOptions() *Options { flagSet.IntVar(&options.MaxEnumerationTime, "max-time", 10, "minutes to wait for enumeration results"), ) - if err := flagSet.Parse(); err != nil { + if err := flagSet.Parse(); err != nil { fmt.Println(err.Error()) os.Exit(1) } @@ -174,9 +173,9 @@ func ParseOptions() *Options { options.preProcessOptions() - if !options.Silent { - showBanner() - } + if !options.Silent { + showBanner() + } // Validate the options passed by the user and if any // invalid options have been used, exit.