Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a trailing dot to DNS domains by default to speed up discovery when a search domain is configured #418

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/cmd/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func parseDNSOptions() (*libgobuster.Options, *gobusterdns.OptionsDNS, error) {
return nil, nil, fmt.Errorf("invalid value for resolver: %w", err)
}

pluginOpts.NoFQDN, err = cmdDNS.Flags().GetBool("no-fqdn")
if err != nil {
return nil, nil, fmt.Errorf("invalid value for no-fqdn: %w", err)
}

if pluginOpts.Resolver != "" && runtime.GOOS == "windows" {
return nil, nil, fmt.Errorf("currently can not set custom dns resolver on windows. See https://golang.org/pkg/net/#hdr-Name_Resolution")
}
Expand All @@ -96,6 +101,7 @@ func init() {
cmdDNS.Flags().BoolP("show-cname", "c", false, "Show CNAME records (cannot be used with '-i' option)")
cmdDNS.Flags().DurationP("timeout", "", time.Second, "DNS resolver timeout")
cmdDNS.Flags().BoolP("wildcard", "", false, "Force continued operation when wildcard found")
cmdDNS.Flags().BoolP("no-fqdn", "", false, "Do not automatically add a trailing dot to the domain, so the resolver uses the DNS search domain")
cmdDNS.Flags().StringP("resolver", "r", "", "Use custom DNS server (format server.com or server.com:port)")
if err := cmdDNS.MarkFlagRequired("domain"); err != nil {
log.Fatalf("error on marking flag as required: %v", err)
Expand Down
4 changes: 4 additions & 0 deletions gobusterdns/gobusterdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func (d *GobusterDNS) PreRun(ctx context.Context, progress *libgobuster.Progress
// ProcessWord is the process implementation of gobusterdns
func (d *GobusterDNS) ProcessWord(ctx context.Context, word string, progress *libgobuster.Progress) error {
subdomain := fmt.Sprintf("%s.%s", word, d.options.Domain)
if !d.options.NoFQDN && !strings.HasSuffix(subdomain, ".") {
subdomain += "."
}
ips, err := d.dnsLookup(ctx, subdomain)
if err == nil {
if !d.isWildcard || !d.wildcardIps.ContainsAny(ips) {
Expand All @@ -119,6 +122,7 @@ func (d *GobusterDNS) ProcessWord(ctx context.Context, word string, progress *li
Found: true,
ShowIPs: d.options.ShowIPs,
ShowCNAME: d.options.ShowCNAME,
NoFQDN: d.options.NoFQDN,
}
if d.options.ShowIPs {
result.IPs = ips
Expand Down
1 change: 1 addition & 0 deletions gobusterdns/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type OptionsDNS struct {
ShowCNAME bool
WildcardForced bool
Resolver string
NoFQDN bool
Timeout time.Duration
}

Expand Down
4 changes: 4 additions & 0 deletions gobusterdns/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Result struct {
ShowCNAME bool
Found bool
Subdomain string
NoFQDN bool
IPs []netip.Addr
CNAME string
}
Expand All @@ -29,6 +30,9 @@ func (r Result) ResultToString() (string, error) {

c := green

if !r.NoFQDN {
r.Subdomain = strings.TrimSuffix(r.Subdomain, ".")
}
if r.Found {
c(buf, "Found: ")
} else {
Expand Down