-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 610a5d4.
- Loading branch information
Showing
19 changed files
with
779 additions
and
1,109 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,139 +1,8 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/alecthomas/kong" | ||
"github.com/projectdiscovery/chaos-client/internal" | ||
"github.com/projectdiscovery/chaos-client/internal/dns" | ||
"github.com/projectdiscovery/chaos-client/internal/subdomains" | ||
"github.com/projectdiscovery/gologger" | ||
"github.com/projectdiscovery/gologger/levels" | ||
updateutils "github.com/projectdiscovery/utils/update" | ||
) | ||
|
||
var cli struct { | ||
Key string `help:"Chaos key for API" short:"k"` | ||
Silent bool `help:"Make the output silent"` | ||
Output string `help:"File to write output to (optional)" short:"o"` | ||
Version bool `help:"Show version of chaos"` | ||
Verbose bool `help:"Verbose" short:"v"` | ||
Update bool `help:"update Chaos to latest version" aliases:"up"` | ||
DisableUpdateCheck bool `help:"disable automatic Chaos update check" aliases:"duc"` | ||
Subdomains struct { | ||
Domain string `arg:"" help:"Domain to search for subdomains"` | ||
Count bool `help:"Show statistics for the specified domain"` | ||
JSON bool `help:"Print output as json"` | ||
} `cmd:"" help:"List subdomains"` | ||
SubdomainsBatch struct { | ||
File string `arg:"" help:"File containing domains to search for subdomains"` | ||
JSON bool `help:"Print output as json"` | ||
} `cmd:"" help:"List subdomains from file"` | ||
DNS struct { | ||
Domain string `arg:"" help:"Domain to search for DNS record"` | ||
Types []dns.RecordType `help:"DNS record type(s) (a,aaaa,caa,cname,mx,ns,soa,srv,txt)" short:"t"` | ||
} `cmd:"" help:"Get DNS record"` | ||
} | ||
|
||
func Run(url *string) error { | ||
if url != nil { | ||
internal.APIAddress = *url | ||
} | ||
ctx := kong.Parse(&cli, | ||
kong.Name("chaos"), | ||
kong.Description("Chaos client"), | ||
kong.UsageOnError(), | ||
kong.ConfigureHelp(kong.HelpOptions{ | ||
Compact: true, | ||
Summary: true, | ||
})) | ||
|
||
if cli.Silent { | ||
gologger.DefaultLogger.SetMaxLevel(levels.LevelSilent) | ||
} | ||
internal.ShowBanner() | ||
|
||
if cli.Version { | ||
gologger.Info().Msgf("Current Version: %s\n", internal.Version) | ||
return nil | ||
} | ||
|
||
if !cli.DisableUpdateCheck { | ||
latestVersion, err := updateutils.GetVersionCheckCallback("chaos-client")() | ||
if err != nil { | ||
if cli.Verbose { | ||
gologger.Error().Msgf("chaos version check failed: %v", err.Error()) | ||
} | ||
} else { | ||
gologger.Info().Msgf("Current chaos version %v %v", internal.Version, updateutils.GetVersionDescription(internal.Version, latestVersion)) | ||
} | ||
} | ||
|
||
switch ctx.Command() { | ||
case "subdomains <domain>": | ||
opts := &subdomains.Options{ | ||
APIKey: cli.Key, | ||
Domain: cli.Subdomains.Domain, | ||
Count: cli.Subdomains.Count, | ||
Silent: cli.Silent, | ||
Output: cli.Output, | ||
JSONOutput: cli.Subdomains.JSON, | ||
Version: cli.Version, | ||
Verbose: cli.Verbose, | ||
} | ||
err := opts.ValidateOptions() | ||
if err != nil { | ||
return err | ||
} | ||
err = subdomains.Run(opts) | ||
if err != nil { | ||
return err | ||
} | ||
case "subdomains-batch <file>": | ||
opts := &subdomains.Options{ | ||
APIKey: cli.Key, | ||
DomainsFile: cli.SubdomainsBatch.File, | ||
Silent: cli.Silent, | ||
Output: cli.Output, | ||
JSONOutput: cli.SubdomainsBatch.JSON, | ||
Version: cli.Version, | ||
Verbose: cli.Verbose, | ||
} | ||
err := opts.ValidateOptions() | ||
if err != nil { | ||
return err | ||
} | ||
err = subdomains.Run(opts) | ||
if err != nil { | ||
return err | ||
} | ||
case "dns <domain>": | ||
opts := dns.Options{ | ||
APIKey: cli.Key, | ||
Domain: cli.DNS.Domain, | ||
Types: cli.DNS.Types, | ||
} | ||
err := opts.ValidateOptions() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = dns.Run(&opts) | ||
if err != nil { | ||
return err | ||
} | ||
default: | ||
return fmt.Errorf("unexpected command: %s", ctx.Command()) | ||
} | ||
|
||
return nil | ||
} | ||
import "github.com/projectdiscovery/chaos-client/internal/runner" | ||
|
||
func main() { | ||
if err := Run(nil); err != nil { | ||
gologger.Fatal().Msg(err.Error()) | ||
} | ||
|
||
os.Exit(0) | ||
opts := runner.ParseOptions() | ||
runner.RunEnumeration(opts) | ||
} |
Oops, something went wrong.