Skip to content

Commit

Permalink
Revert "DNS feature and refactoring for V2 (#205)" (#206)
Browse files Browse the repository at this point in the history
This reverts commit 610a5d4.
  • Loading branch information
ravlio committed Nov 7, 2023
1 parent 610a5d4 commit bee8ea3
Show file tree
Hide file tree
Showing 19 changed files with 779 additions and 1,109 deletions.
5 changes: 0 additions & 5 deletions .gitignore

This file was deleted.

39 changes: 0 additions & 39 deletions .golangci.yml

This file was deleted.

111 changes: 26 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,51 @@ Chaos Client
<a href="https://twitter.com/pdchaos"><img src="https://img.shields.io/twitter/follow/pdchaos.svg?logo=twitter"></a>
</p>


## Installation

```bash
go install -v github.com/projectdiscovery/chaos-client/cmd/chaos@latest
```

## General usage
## Usage

```bash
chaos -h
```

This will display help for the tool. Here are all the switches it supports.

```bash
chaos <command>
```

| Flag | Description | Example |
|--------------------------|---------------------------------------|--------------------------------|
| `-h`,`--help` | Show help | `chaos -h` |
| `--key` | Chaos key for API | `chaos <command> -key API_KEY` |
| `--silent` | Make the output silent | `chaos <command> -silent` |
| `-o`,`--output` | File to write output to (optional) | `chaos <command> -o uber.txt` |
| `-version` | Print current version of chaos client | `chaos -version` |
| `-v`,`--verbose` | Show verbose output | `chaos -verbose` |
| `--update` | updates to latest version | `chaos -up` |
| `--disable-update-check` | disables automatic update check | `chaos -duc` |

### Subdomains

Get subdomains for a domain.
| Flag | Description | Example |
|----------------------------|------------------------------------------|------------------------------------------------------------|
| `-d` | Domain to find subdomains for | `chaos -d uber.com` |
| `-count` | Show statistics for the specified domain | `chaos -d uber.com -count` |
| `-o` | File to write output to (optional) | `chaos -d uber.com -o uber.txt` |
| `-json` | Print output as json | `chaos -d uber.com -json` |
| `-key` | Chaos key for API | `chaos -key API_KEY` |
| `-dL` | File with list of domains (optional) | `chaos -dL domains.txt` |
| `-silent` | Make the output silent | `chaos -d uber.com -silent` |
| `-version` | Print current version of chaos client | `chaos -version` |
| `-verbose` | Show verbose output | `chaos -verbose` |
| `-update` | updates to latest version | `chaos -up` |
| `-disable-update-check` | disables automatic update check | `chaos -duc` |

You can also set the API key as an environment variable in your bash profile.

```bash
chaos subdomains <domain>
export CHAOS_KEY=CHAOS_API_KEY
```

Take a domain name and return subdomains for it.
### How to avail `API_KEY`

Chaos DNS API is in beta and only available to people who have been invited to use it. You can request an invite at [chaos.projectdiscovery.io](https://chaos.projectdiscovery.io).

| Flag | Description | Example |
|-----------|------------------------------------------|---------------------------------------|
| `--count` | Show statistics for the specified domain | `chaos subdomains google.com --count` |
| `--json` | Print output as json | `chaos subdomains google.com --json` |
## Running chaos

Example:
In order to get subdomains for a domain, use the following command.

```bash
chaos subdomains uber.com -silent
chaos -d uber.com -silent

restaurants.uber.com
testcdn.uber.com
Expand All @@ -80,62 +77,6 @@ guest.uber.com
kiosk-home-staging.uber.com
```

### Batch subdomains

Get subdomains from list of domains.

```bash
chaos subdomains-batch <path-to-files>
```

| Flag | Description | Example |
|----------|----------------------|------------------------------------------|
| `--json` | Print output as json | `chaos subdomains-batch subs.txt --json` |

Take domains from a file and return subdomains for each domain.

### DNS Records

Lookup DNS records for a domain.

```bash
chaos dns <domain>
```

| Flag | Description | Example |
|---------------------------|---------------------------------------------------------|-------------------------------------|
| `-t`, `--types=TYPES,...` | DNS record type(s) (a,aaaa,caa,cname,mx,ns,soa,srv,txt) | `chaos dns hackerone.com -t a,aaaa` |

Example:

```bash
chaos dns uber.com -t a,soa | jq

{
"a": [
"34.98.127.226"
],
"soa": [
"edns126.ultradns.com",
"edns126.ultradns.com",
"edns126.ultradns.com",
"edns126.ultradns.com",
"edns126.ultradns.com"
]
}
```

### How to avail `API_KEY`

Chaos DNS API is in beta and only available to people who have been invited to use it. You can request an invite
at [chaos.projectdiscovery.io](https://chaos.projectdiscovery.io).

You can also set the API key as an environment variable in your bash profile.

```bash
export CHAOS_KEY=CHAOS_API_KEY
```

💡 Notes
-----

Expand All @@ -145,7 +86,7 @@ export CHAOS_KEY=CHAOS_API_KEY
👨‍💻 Community
-----

You are welcomed to join our [Discord Community](https://discord.gg/projectdiscovery). You can also follow us
on [Twitter](https://twitter.com/pdchaos) to keep up with everything related to chaos project.
You are welcomed to join our [Discord Community](https://discord.gg/projectdiscovery). You can also follow us on [Twitter](https://twitter.com/pdchaos) to keep up with everything related to chaos project.


Thanks again for your contribution and keeping the community vibrant. :heart:
137 changes: 3 additions & 134 deletions cmd/chaos/chaos.go
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)
}

0 comments on commit bee8ea3

Please sign in to comment.