https://github.com/holzkohlengrill/dns_message_parser
(Partial) Python 3 implementation of a DNS message parser (supports A, AAAA and CNAME record types (qtypes) and IPv4/IPv6)
https://github.com/holzkohlengrill/dns_message_parser
cname dns dns-record ipv4 ipv6 python python3
Last synced: 8 months ago
JSON representation
(Partial) Python 3 implementation of a DNS message parser (supports A, AAAA and CNAME record types (qtypes) and IPv4/IPv6)
- Host: GitHub
- URL: https://github.com/holzkohlengrill/dns_message_parser
- Owner: holzkohlengrill
- License: mit
- Created: 2024-04-17T14:31:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-05T08:34:45.000Z (about 2 years ago)
- Last Synced: 2025-10-03T19:49:39.036Z (9 months ago)
- Topics: cname, dns, dns-record, ipv4, ipv6, python, python3
- Language: Python
- Homepage:
- Size: 155 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DNS message parser
(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`](https://linux.die.net/man/1/dig).
# Extension
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).
# Based on RFCs:
* [Domain Names – Concepts and Facilities](https://datatracker.ietf.org/doc/html/rfc1035)
* [Domain Names – Implementation and Specification](https://datatracker.ietf.org/doc/html/rfc1034)
* [DNS Extensions to Support IP Version 6](https://datatracker.ietf.org/doc/html/rfc3596)