Skip to content

Commit

Permalink
DNS wildcard detection fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Feb 18, 2019
1 parent db5aadd commit 3b2fc2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 0 additions & 2 deletions amass/dnssrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func (ds *DNSService) newSubdomain(req *core.Request, times int) {
}

func (ds *DNSService) processSubdomain(req *core.Request) {
ds.SetActive()
ds.basicQueries(req.Name, req.Domain)
ds.queryServiceNames(req.Name, req.Domain)
}
Expand Down Expand Up @@ -316,7 +315,6 @@ func (ds *DNSService) queryServiceNames(subdomain, domain string) {
}

func (ds *DNSService) dnsSweep(addr string, cidr *net.IPNet) {
ds.SetActive()
go ds.reverseDNSSweep(addr, cidr)
}

Expand Down
2 changes: 1 addition & 1 deletion amass/sources/bufferover.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (b *BufferOver) executeQuery(domain string) {
}

func (b *BufferOver) getURL(domain string) string {
format := "https://dns.bufferover.run/dns?q=%s"
format := "https://dns.bufferover.run/dns?q=.%s"

return fmt.Sprintf(format, domain)
}
17 changes: 13 additions & 4 deletions amass/wildcards.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ const (
maxDNSNameLen = 253
maxDNSLabelLen = 63
maxLabelLen = 24

// The hyphen has been removed
ldhChars = "abcdefghijklmnopqrstuvwxyz0123456789"
)

// Names for the different types of wildcards that can be detected.
Expand Down Expand Up @@ -163,9 +160,21 @@ func compareAnswers(ans1, ans2 []core.DNSAnswer) bool {
return false
}

// UnlikelyName takes a subdomain name and returns an unlikely DNS name within that subdomain
// UnlikelyName takes a subdomain name and returns an unlikely DNS name within that subdomain.
func UnlikelyName(sub string) string {
newlabel := uuid.New().String()

// Determine the max label length
l := maxDNSNameLen - (len(sub) + 1)
if l > maxLabelLen {
l = maxLabelLen
} else if l < 1 {
return ""
}
if len(newlabel) > l {
newlabel = newlabel[:l]
}
// Remove hyphens from the beginning and end of the label
newlabel = strings.Trim(newlabel, "-")
return newlabel + "." + sub
}

0 comments on commit 3b2fc2e

Please sign in to comment.