Skip to content

Commit

Permalink
Merge pull request #918 from projectdiscovery/fix_dns_correlation_id
Browse files Browse the repository at this point in the history
fix dns correlation id processing
  • Loading branch information
Mzack9999 authored Jul 15, 2024
2 parents 5e220f7 + 16ecd3f commit 43c5eca
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions pkg/server/dns_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,33 @@ func (h *DNSServer) handleInteraction(domain string, w dns.ResponseWriter, r *dn
}

if foundDomain != "" {
if h.options.ScanEverywhere {
chunks := stringsutil.SplitAny(requestMsg, ".\n\t\"'")
for _, chunk := range chunks {
for part := range stringsutil.SlideWithLength(chunk, h.options.GetIdLength()) {
normalizedPart := strings.ToLower(part)
if h.options.isCorrelationID(normalizedPart) {
uniqueID = normalizedPart
fullID = part
}
}
}
}
} else {
parts := strings.Split(domain, ".")
for i, part := range parts {
if h.options.isCorrelationID(part) {
uniqueID = part
fullID = part
if i+1 <= len(parts) {
fullID = strings.Join(parts[:i+1], ".")
for partChunk := range stringsutil.SlideWithLength(part, h.options.GetIdLength()) {
normalizedPartChunk := strings.ToLower(partChunk)
if h.options.isCorrelationID(normalizedPartChunk) {
fullID = part
if i+1 <= len(parts) {
fullID = strings.Join(parts[:i+1], ".")
}
uniqueID = normalizedPartChunk
}
}
}
}
uniqueID = strings.ToLower(uniqueID)

if uniqueID != "" {
correlationID := uniqueID[:h.options.CorrelationIdLength]
Expand Down

0 comments on commit 43c5eca

Please sign in to comment.