fix `domain` bug on dns resolver

#263 Declined
Repository
Recon-ng
Branch
staging
Author
  1. nil0x42
Reviewers
Description

fix domain bug on dns resolver

Comments (2)

  1. nil0x42 author

    recon-ng uses dns.resolver.get_default_resolver() as resolver. this resolver's configuration i fed by /etc/resolv.conf (unlike dns.resolver.Resolver(configure=False))

    this becomes a problem when resolv.conf contains a domain configuration option, and for DHCP users, it is not rare, as many ISP add a domain option to resolve local NAT hosts.

    this should not be a problem in normal circumstances, but python-dnslib will raises a NoNameservers() exception for any non-existent host when a domain is set. for example, if domain my-isp-domain.com is on resolv.conf, and we call resolver.query("somesubdomain.target.com"), it will first try to resolve somesubdomain.target.com.my-isp-domain.com, and immediately raise a NoNameservers exception.

    This exception is used by recon/domains-hosts/brute_hosts to abort plugin execution, so the plugin is unusable for anyone having a domain config option in it's resolv.conf, as first non-exsisting domain will throw an exception and exit the plugin.

    there are two way to get away this: 1 - creating a default resolver by ignoring resolv.conf (resolver = dns.resolver.Resolver(configure=False))

    2 - just override `resolver.domain` and set it to it's default value (`dns.name.Name(("",))`)
    

    second option has been chosen because on only adds a single line, so it's easy to understand what the patch does :p

  2. Tim Tomes repo owner

    Nice work!

    I actually prefer the other solution. I'll make the change and merge manually. Thank you for the in-depth explanation and your contribution.