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

Incorrect results for DNS based asn lookups when a local searchdomain is in effect #324

Open
MrSeccubus opened this issue Jan 22, 2024 · 2 comments

Comments

@MrSeccubus
Copy link

In net.py the cymru domain is set as follows

IPV4_DNS_ZONE = '{0}.origin.asn.cymru.com'

IPV6_DNS_ZONE = '{0}.origin6.asn.cymru.com'

It should be set to this:

IPV4_DNS_ZONE = '{0}.origin.asn.cymru.com.'

IPV6_DNS_ZONE = '{0}.origin6.asn.cymru.com.'

On my system there is a local search domain set which is appended after cymru.net and leads to the following error.

Traceback (most recent call last):
  File "/Users/fbreedijk/repos/scripts/venv/lib/python3.11/site-packages/ipwhois/asn.py", line 146, in parse_fields_dns
    ret = {'asn_registry': temp[3].strip(' \n')}
                           ~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/fbreedijk/repos/scripts/abuse2sqlite/./debug_whois.py", line 51, in <module>
    print(abuse_from_whois("160.50.220.0"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fbreedijk/repos/scripts/abuse2sqlite/./debug_whois.py", line 8, in abuse_from_whois
    rdap = obj.lookup_rdap(depth=2)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fbreedijk/repos/scripts/venv/lib/python3.11/site-packages/ipwhois/ipwhois.py", line 295, in lookup_rdap
    asn_data = self.ipasn.lookup(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/fbreedijk/repos/scripts/venv/lib/python3.11/site-packages/ipwhois/asn.py", line 464, in lookup
    asn_data_list.append(self.parse_fields_dns(
                         ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fbreedijk/repos/scripts/venv/lib/python3.11/site-packages/ipwhois/asn.py", line 167, in parse_fields_dns
    raise ASNParseError('Parsing failed for "{0}" with exception: {1}.'
ipwhois.exceptions.ASNParseError: Parsing failed for ""v=spf1 -all"" with exception: list index out of range.

I will make a PR for this change.

@MrSeccubus
Copy link
Author

The same mistake is present in line 260:

        zone = '{0}.asn.cymru.com'.format(asn)

Should be

        zone = '{0}.asn.cymru.com.'.format(asn)

@MrSeccubus
Copy link
Author

Line 74 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant