gera2ld / async_dns

DNS library based on asyncio
MIT License
70 stars 17 forks source link

thousands of queries if request ends in dot #11

Closed mutax closed 4 years ago

mutax commented 4 years ago

I am trying to do reverse lookups and during checking out how this might work I found async_dns making thousands of queries with this code:

import asyncio                                                                                                                         
from async_dns import types
from async_dns.resolver import ProxyResolver

loop = asyncio.get_event_loop()
resolver = ProxyResolver(proxies=['127.0.0.1',])
print(loop.run_until_complete(resolver.query('9.9.9.9.', types.PTR)))

executing yields:

# LOGLEVEL=DEBUG python3 testptr.py 2>&1 | grep -c  'get_remote'
12155

wireshark shows for the query:

Domain Name System (query)
    Transaction ID: 0x0001
    Flags: 0x0100 Standard query
    Questions: 1
    Answer RRs: 0
    Authority RRs: 0
    Additional RRs: 0
    Queries
        9.9.9.9: type Unused, class Unknown
            Name: 9.9.9.9
            [Name Length: 7]
            [Label Count: 4]
            Type: Unused (0)
            Class: Unknown (0x0c00)
    [Response In: 6]

and for the answer:

Domain Name System (response)
    Transaction ID: 0x0001
    Flags: 0x8105 Standard query response, Refused
    Questions: 1
    Answer RRs: 0
    Authority RRs: 0
    Additional RRs: 0
    Queries
        9.9.9.9: type Unused, class Unknown
            Name: 9.9.9.9
            [Name Length: 7]
            [Label Count: 4]
            Type: Unused (0)
            Class: Unknown (0x0c00)
    [Request In: 5]
    [Time: 0.000119773 seconds]
gera2ld commented 4 years ago

fixed in 36d1eff4fbe841f7ecd793ea9e42ef16b9ed7db0