Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

sfp_dnsresolve.py issue with multiple PTR records #1624

Open
quantumburnz opened this issue Jan 21, 2022 · 0 comments
Open

sfp_dnsresolve.py issue with multiple PTR records #1624

quantumburnz opened this issue Jan 21, 2022 · 0 comments
Labels

Comments

@quantumburnz
Copy link

quantumburnz commented Jan 21, 2022

I'm performing a scan on an IP block where some IPs have multiple PTR records. A simple nslookup of the IP space returned more hostnames than SpiderFoot with sfp_dnsresolve and other modules.

sfp_dnsresolve performs the following:

# Reverse resolve IP addresses
elif eventName in ["IP_ADDRESS", "IPV6_ADDRESS", "AFFILIATE_IPADDR", "AFFILIATE_IPV6_ADDRESS"]:
addrs = self.sf.resolveIP(eventData)

The resolveIP function uses socket.gethostbyaddr(ipaddr) as shown below:

spiderfoot/sflib.py

Lines 1074 to 1075 in f90f932

try:
addrs = self.normalizeDNS(socket.gethostbyaddr(ipaddr))

According to the Python docs:

Return a triple (hostname, aliaslist, ipaddrlist) where hostname is the primary host name responding to the given ip_address, aliaslist is a (possibly empty) list of alternative host names for the same address...

The primary host name seems to change if you run this function in succession multiple times. No results are ever returned for the aliaslist in the few cases I tested though.

A solution to this would be to use the dnspython library used elsewhere in SF. Here's some example code:

addr = dns.resversename.from_address("IP_ADDRESS")
results = dns.resolver.resolve(addr, "PTR")

The results variable will be populated with all PTR records.

What version of Python are you using? Python 3.8.10

What version of SpiderFoot are you using (stable release or Git master branch)? SpiderFoot stable v3.5.0

You may also wish to check if your issue has been posted previously: I did not see any similarly reported issues.

@smicallef smicallef added the bug label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants