Skip to content

Commit

Permalink
Adding case-insensitive regex
Browse files Browse the repository at this point in the history
During a test I had an issue with an DNS resolver of my target host malforming the DNS queries (uppercase/lowercase). Beause of this, the dnscat2 server was unable to establish a session. I fixed this issue by adding case-insensitive regex modifiers (/i).
  • Loading branch information
Fox0x01 committed Aug 21, 2015
1 parent a5b80af commit bdd5f1a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/driver_dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ def DriverDNS.get_domain_regex(domain, identifier, required_prefix = nil)
def DriverDNS.figure_out_name(name, domains)
# Check if it's one of our domains
domains.each do |domain|
if(name =~ /^(.*)\.(#{domain})/)
if(name =~ /^(.*)\.(#{domain})/i)
return $1, $2
end
end

# Check if it starts with dnscat, which is used when
# the server is unknown
if(name =~ /^dnscat\.(.*)$/)
if(name =~ /^dnscat\.(.*)$/i)
return $1, nil
end

Expand Down Expand Up @@ -168,7 +168,7 @@ def recv()
domain_regex = "(^dnscat\\.|" + (domains.map { |x| "\\.#{x}$" }).join("|") + ")"

# Only match proper domains with proper record types
match(/#{domain_regex}/, RECORD_TYPES.keys) do |transaction|
match(/#{domain_regex}/i, RECORD_TYPES.keys) do |transaction|
begin
# Determine the type
type = transaction.resource_class
Expand Down

0 comments on commit bdd5f1a

Please sign in to comment.