-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Brief description
We are running DNS queries using Scapy. The queries are run against more well known DNS providers - i.e. the error count should be very low. Lately we have noticed many log prints from scapy.runtime
containing multiple warnings about "DNS RR prematured end". We also see a much larger number of DNS queries failing than expected, usually directly following these log prints.
A possible explanation seems to be packet fragmentation (does the sr
function handle packet fragmentation?). Could this be it or are there any other possible explanations?
Environment
- Scapy version: 2.4.2, 2.4.3rc1, master (2019-04-26)
- Python version: 3.7.1
- Operating System: Ubuntu 18.04.2 LTS
How to reproduce
As an example, we have seen the issue occur for a DNS query against 198.206.14.241
for the A
record of netflix.com
.
ans, unans = sr(
IP(
dst="198.206.14.241"
)
/ UDP()
/ DNS(
id=RandShort(),
rd=1,
qd=DNSQR(
qname="netflix.com",
qtype="A"
)
),
retry=0,
timeout=5,
verbose=False
)
try:
query = ans[0][0] # type: IP
answer = ans[0][1] # type: IP
except IndexError:
raise TimeoutError(f"No response was received for job ({job})") from None
Actual result
2019-04-26 11:18:26 +0200 [WARNING](scapy.runtime): DNS RR prematured end (ofs=1494, len=1460)
2019-04-26 11:18:26 +0200 [WARNING](scapy.runtime): DNS RR prematured end (ofs=1630, len=1460)
2019-04-26 11:18:26 +0200 [WARNING](scapy.runtime): more DNS RR prematured end (ofs=1680, len=1460)
2019-04-26 11:18:27 +0200 [WARNING](worker#19181): Job (HoardJob(dns_server='198.206.14.241', host='netflix.com', record='A', timeout=datetime.timedelta(seconds=5))) failed
Traceback (most recent call last):
File "/home/felix/school/kandidat/DNSHoarder/src/hoarder.py", line 150, in __perform_hoard
raise TimeoutError(f"No response was received for job ({job})") from None
TimeoutError: No response was received for job (HoardJob(dns_server='198.206.14.241', host='netflix.com', record='A', timeout=datetime.timedelta(seconds=5)))
Expected result
No error
Related resources
#1846 #1849 discusses DNS RR prematured end
errors. However, using the merged code from the master branch does not yield any different results.
#1952 (in particular this and this comment) contains the code used by our program.