(Partial) Python 3 implementation of a DNS message parser (supports A, AAAA and CNAME record types (qtypes) and IPv4/IPv6)
It prompts the user for an input (= binary hex stream; like: a01d81800001000100000000076578616d706c6503636f6d0000010001c00c0001000100001bbc00045db8d822
) and would print in the following format:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40989
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 7100 IN A 93.184.216.34
The tool returns similar (but less) output to dig
.
In order to add more implementations for Resource Records (QType) add the relevant functions to the _RDataProcessor
class and link it in the LUT _qtypeDispatchLUT
(LUT for processing function dispatch).