@@ -22,11 +22,13 @@ def decode_q(self, dns):
2222 queried = ""
2323 if dns .qd [0 ].type == dpkt .dns .DNS_A :
2424 queried = queried + "A? %s" % (dns .qd [0 ].name )
25- if dns .qd [0 ].type == dpkt .dns .DNS_CNAME :
25+ elif dns .qd [0 ].type == dpkt .dns .DNS_CNAME :
2626 queried = queried + "CNAME? %s" % (dns .qd [0 ].name )
27- if dns .qd [0 ].type == dpkt .dns .DNS_AAAA :
27+ elif dns .qd [0 ].type == dpkt .dns .DNS_AAAA :
2828 queried = queried + "AAAA? %s" % (dns .qd [0 ].name )
29- if dns .qd [0 ].type == dpkt .dns .DNS_PTR :
29+ elif dns .qd [0 ].type == dpkt .dns .DNS_SOA :
30+ queried = queried + "SOA? %s" % (dns .qd [0 ].name )
31+ elif dns .qd [0 ].type == dpkt .dns .DNS_PTR :
3032 if dns .qd [0 ].name .endswith ('.in-addr.arpa' ):
3133 query_name = '.' .join (
3234 reversed (dns .qd [0 ].name .split ('.in-addr.arpa' )[0 ].split ('.' )))
@@ -39,11 +41,11 @@ def decode_q(self, dns):
3941
4042 if dns .qd [0 ].type == dpkt .dns .DNS_NS :
4143 queried = queried + "NS? %s" % (dns .qd [0 ].name )
42- if dns .qd [0 ].type == dpkt .dns .DNS_MX :
44+ elif dns .qd [0 ].type == dpkt .dns .DNS_MX :
4345 queried = queried + "MX? %s" % (dns .qd [0 ].name )
44- if dns .qd [0 ].type == dpkt .dns .DNS_TXT :
46+ elif dns .qd [0 ].type == dpkt .dns .DNS_TXT :
4547 queried = queried + "TXT? %s" % (dns .qd [0 ].name )
46- if dns .qd [0 ].type == dpkt .dns .DNS_SRV :
48+ elif dns .qd [0 ].type == dpkt .dns .DNS_SRV :
4749 queried = queried + "SRV? %s" % (dns .qd [0 ].name )
4850
4951 return queried
@@ -65,7 +67,7 @@ def DNSHandler(self, conn, request, response, **kwargs):
6567 conn .info (query = self .decode_q (dns ))
6668
6769 # DNS Answer with data and no errors
68- elif (dns .qr == dpkt . dns . DNS_A and dns . rcode == dpkt .dns .DNS_RCODE_NOERR and len (dns .an ) > 0 ):
70+ elif (dns .rcode == dpkt .dns .DNS_RCODE_NOERR and len (dns .an ) > 0 ):
6971
7072 queried = self .decode_q (dns )
7173
@@ -108,6 +110,16 @@ def DNSHandler(self, conn, request, response, **kwargs):
108110 if queried != '' :
109111 anstext = 'NXDOMAIN'
110112
113+ #SOA response
114+ elif dns .qd [0 ].type == dpkt .dns .DNS_SOA and len (dns .ns ):
115+ queried = self .decode_q (dns )
116+ answers = []
117+ for ns in dns .ns :
118+ if ns .type == dpkt .dns .DNS_SOA :
119+ answers .append ('SOA: ' + ns .mname )
120+ anstext = ", " .join (answers )
121+
122+
111123 # did we get an answer?
112124 if anstext and not self .only_noanswer and not self .only_norequest :
113125 self .alert (
0 commit comments