Merge pull request #52 from Mitochondrion2/patch-1

Set qd to None instead of deleting it
This commit is contained in:
Kevin Bock 2023-01-24 21:00:39 -05:00 committed by GitHub
commit 1655fb1a3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -164,7 +164,9 @@ class DNSLayer(Layer):
# Next, we must rebuild the DNS packet itself. If we try to have scapy parse either dns_qr1 or dns_qr2, they
# will look malformed, since neither contains a complete request. Therefore, we must build the entire
# DNS packet at once. First, we must remove the original DNSQR, since this contains the original request
del packet["DNS"].qd
# Need to set qd field to None instead of deleting it to be compatible with scapy 2.5.0
# deleting the qd field in scapy 2.5.0 causes the qd field to be populated with a question record for example.com
packet["DNS"].qd = None
# Once the DNSQR is removed, scapy automatically sets the qdcount to 0. Adjust it to 2
packet["DNS"].qdcount = 2
@ -186,4 +188,4 @@ class DNSLayer(Layer):
del packet["UDP"].chksum
del packet["UDP"].len
return packet
return packet