scapy
scapy copied to clipboard
DNSQR does not accept a list of strings
Brief description
In the past (ie; v2.4.5), DNSQR would accept a list of qname
values, which would then be iterated over when sending packets. It now raises a traceback as it tries to convert each item in the list to its ord
value (since it now expects the value to always be a string)
Scapy version
2.5.0
Python version
3.10
Operating system
Linux 6.1.5
Additional environment information
No response
How to reproduce
This stub script will show the error
from scapy.all import DNSQR
DNSQR(qname=["domain1.com", "domain2.com"], qtype="A")
Actual result
This traceback is generated:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/chand/src/scapy/scapy/base_classes.py", line 399, in __call__
i.__init__(*args, **kargs)
File "/home/chand/src/scapy/scapy/layers/dns.py", line 278, in __init__
Packet.__init__(self, _pkt=_pkt, *args, **kwargs)
File "/home/chand/src/scapy/scapy/packet.py", line 178, in __init__
self.get_field(fname).any2i(self, value)
File "/home/chand/src/scapy/scapy/fields.py", line 1392, in any2i
return super(_StrField, self).any2i(pkt, x) # type: ignore
File "/home/chand/src/scapy/scapy/fields.py", line 228, in any2i
return self.h2i(pkt, x)
File "/home/chand/src/scapy/scapy/layers/dns.py", line 292, in h2i
if x[-1:] != b"." and not _is_ptr(x):
File "/home/chand/src/scapy/scapy/layers/dns.py", line 151, in _is_ptr
(x and orb(x[-1]) == 0) or
File "/home/chand/src/scapy/scapy/compat.py", line 331, in orb
return ord(x)
TypeError: ord() expected a character, but string of length 11 found
Expected result
The object should be created and should look like this:
<DNSQR qname=['domain1.com', 'domain2.com'] qtype=A |>
Related resources
No response
@p-l- Is this still a valid issue up for grabs? If so, how can I assign this issue to myself?
Yep, that's a valid issue and you are more than welcome to work on it!
FTR, the DNS layer is being rewritten in #4012.