A user-friendly DNS client and packet analyzer
Project description
KYDNS
KYDNS (Know Your DNS) is a simple DNS client library written in Python 3.
It allows sending DNS queries for A, AAAA, and NS records, easily modify any of the DNS packet fields, and provides an ASCII representation of the DNS packets.
The library is designed to be easy to use and can be used for learning, testing, or other purposes.
Installation
KYDNS uses Python 3 standard libs and has no 3rd party dependencies. Install using pip:
pip install kydns
Or git clone:
git clone https://github.com/eliaonceagain/kydns.git
cd kydns/
pip install .
Usage
Send a DNS query for the A record of google.com
and return the response
from kydns import Request
req = Request("google.com")
rsp = req.send(("1.1.1.1", 53))
>>> rsp
1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x382a |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1| 0x0 |0|0|1|1| 0 | 0x0 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0000 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0000 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<--
/ google.com /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<--
/ google.com /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ 80 +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0004 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ /
+ 172.217.18.14 +
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<--
Set Query Fields
KYDNS also allows you to easily modify any of the DNS packet fields before sending the query. Here is an example of how to set the DNS request ID:
from kydns import Request
req = Request('google.com') # or Request('google.com', id=0x1234)
req.header.id = 0x1234
rsp = req.send(("1.1.1.1", 53))
assert req.header.id == rsp.header.id == 0x1234
>>> req.header
1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x1234 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0| 0x0 |0|0|1|0| 0 | 0x0 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0000 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0000 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0000 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<--
>>> rsp.header
1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x1234 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1| 0x0 |0|0|1|1| 0 | 0x0 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0000 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x0000 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<--
License
KYDNS is licensed under the MIT license. See the LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kydns-0.1.4.tar.gz
.
File metadata
- Download URL: kydns-0.1.4.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.8.8 Linux/5.4.0-144-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e92315984d8836b7b4a377f2cae26ac6a95a3df616bc8c3a04adb873a66cef1 |
|
MD5 | 097cdd8feda854ebd137ecd0ab7e778d |
|
BLAKE2b-256 | 0246df40014f41f75e1f704cf7c89c5b647d917290296751e38608c8bdff7b4b |
File details
Details for the file kydns-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: kydns-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.8.8 Linux/5.4.0-144-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b51c19c8a3a1c6094000a636bfb725a8b1cfa2146eae0f9b2cdb8cc07038e386 |
|
MD5 | 4348a4259f5e10fce5dcb33f3c6d67d9 |
|
BLAKE2b-256 | f223119c6dba3fb700d75088269f6dd1f67ac64e478c72ea7a7e82a576541dd6 |