subfinder/v2/pkg/runner/banners.go

76 lines
2.5 KiB
Go
Raw Normal View History

package runner
2019-12-03 15:07:27 +00:00
import (
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
)
const banner = `
2020-07-22 13:35:01 +00:00
_ __ _ _
____ _| |__ / _(_)_ _ __| |___ _ _
(_-< || | '_ \ _| | ' \/ _ / -_) '_|
2021-03-30 10:29:15 +00:00
/__/\_,_|_.__/_| |_|_||_\__,_\___|_| v2.4.7
`
2020-01-10 11:44:44 +00:00
// Version is the current version of subfinder
2021-03-30 10:29:15 +00:00
const Version = `2.4.7`
2020-01-10 11:44:44 +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")
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")
}
// normalRunTasks runs the normal startup tasks
func (options *Options) normalRunTasks() {
configFile, err := UnmarshalRead(options.ConfigFile)
if err != nil {
2021-02-17 15:23:15 +00:00
gologger.Fatal().Msgf("Could not read configuration file %s: %s\n", options.ConfigFile, err)
}
// If we have a different version of subfinder installed
// previously, use the new iteration of config file.
if configFile.Version != Version {
configFile.Sources = passive.DefaultSources
configFile.AllSources = passive.DefaultAllSources
configFile.Recursive = passive.DefaultRecursiveSources
configFile.Version = Version
err = configFile.MarshalWrite(options.ConfigFile)
if err != nil {
2021-02-17 15:23:15 +00:00
gologger.Fatal().Msgf("Could not update configuration file to %s: %s\n", options.ConfigFile, err)
}
}
options.YAMLConfig = configFile
}
// firstRunTasks runs some housekeeping tasks done
// when the program is ran for the first time
func (options *Options) firstRunTasks() {
// Create the configuration file and display information
// about it to the user.
2019-12-03 15:07:27 +00:00
config := ConfigFile{
2020-07-22 13:35:01 +00:00
// Use the default list of resolvers by marshaling it to the config
2019-12-03 15:07:27 +00:00
Resolvers: resolve.DefaultResolvers,
2019-12-03 18:12:45 +00:00
// 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,
2019-12-03 15:07:27 +00:00
}
err := config.MarshalWrite(options.ConfigFile)
if err != nil {
2021-02-17 15:23:15 +00:00
gologger.Fatal().Msgf("Could not write configuration file to %s: %s\n", options.ConfigFile, err)
}
2019-12-03 15:07:27 +00:00
options.YAMLConfig = config
2021-02-17 15:23:15 +00:00
gologger.Info().Msgf("Configuration file saved to %s\n", options.ConfigFile)
}