2019-12-03 11:17:19 +00:00
|
|
|
package runner
|
|
|
|
|
2019-12-03 15:07:27 +00:00
|
|
|
import (
|
2022-04-04 16:33:08 +00:00
|
|
|
"errors"
|
|
|
|
"os"
|
|
|
|
|
2020-02-26 10:42:19 +00:00
|
|
|
"github.com/projectdiscovery/gologger"
|
2020-09-24 17:02:02 +00:00
|
|
|
"github.com/projectdiscovery/subfinder/v2/pkg/passive"
|
|
|
|
"github.com/projectdiscovery/subfinder/v2/pkg/resolve"
|
2019-12-03 15:07:27 +00:00
|
|
|
)
|
2019-12-03 11:17:19 +00:00
|
|
|
|
|
|
|
const banner = `
|
2021-04-23 10:41:29 +00:00
|
|
|
__ _____ __
|
|
|
|
_______ __/ /_ / __(_)___ ____/ /__ _____
|
|
|
|
/ ___/ / / / __ \/ /_/ / __ \/ __ / _ \/ ___/
|
|
|
|
(__ ) /_/ / /_/ / __/ / / / / /_/ / __/ /
|
2022-06-07 20:19:55 +00:00
|
|
|
/____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.5.2
|
2019-12-03 11:17:19 +00:00
|
|
|
`
|
|
|
|
|
2020-01-10 11:44:44 +00:00
|
|
|
// Version is the current version of subfinder
|
2022-06-07 20:19:55 +00:00
|
|
|
const Version = `v2.5.2`
|
2020-01-10 11:44:44 +00:00
|
|
|
|
2019-12-03 11:17:19 +00:00
|
|
|
// showBanner is used to show the banner to the user
|
|
|
|
func showBanner() {
|
2021-02-17 15:23:15 +00:00
|
|
|
gologger.Print().Msgf("%s\n", banner)
|
|
|
|
gologger.Print().Msgf("\t\tprojectdiscovery.io\n\n")
|
2019-12-03 11:17:19 +00:00
|
|
|
|
2021-02-17 15:23:15 +00:00
|
|
|
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")
|
2019-12-03 11:17:19 +00:00
|
|
|
}
|
|
|
|
|
2022-02-24 10:44:16 +00:00
|
|
|
// loadProvidersFrom runs the app with source config
|
|
|
|
func (options *Options) loadProvidersFrom(location string) {
|
|
|
|
if len(options.AllSources) == 0 {
|
|
|
|
options.AllSources = passive.DefaultAllSources
|
2019-12-03 11:17:19 +00:00
|
|
|
}
|
2022-02-24 10:44:16 +00:00
|
|
|
if len(options.Recursive) == 0 {
|
|
|
|
options.Recursive = passive.DefaultRecursiveSources
|
2020-08-11 17:20:58 +00:00
|
|
|
}
|
2022-02-24 10:44:16 +00:00
|
|
|
// todo: move elsewhere
|
|
|
|
if len(options.Resolvers) == 0 {
|
|
|
|
options.Recursive = resolve.DefaultResolvers
|
2019-12-03 15:07:27 +00:00
|
|
|
}
|
2022-02-24 10:44:16 +00:00
|
|
|
if len(options.Sources) == 0 {
|
|
|
|
options.Sources = passive.DefaultSources
|
2019-12-03 11:17:19 +00:00
|
|
|
}
|
|
|
|
|
2022-02-24 10:44:16 +00:00
|
|
|
options.Providers = &Providers{}
|
2022-04-04 16:33:08 +00:00
|
|
|
// We skip bailing out if file doesn't exist because we'll create it
|
|
|
|
// at the end of options parsing from default via goflags.
|
|
|
|
if err := options.Providers.UnmarshalFrom(location); isFatalErr(err) && !errors.Is(err, os.ErrNotExist) {
|
2022-02-24 10:44:16 +00:00
|
|
|
gologger.Fatal().Msgf("Could not read providers from %s: %s\n", location, err)
|
|
|
|
}
|
2019-12-03 11:17:19 +00:00
|
|
|
}
|