Skip to main content

A user-friendly DNS client and packet analyzer

Project description

[![PyPI Version][pypi-image]][pypi-url] License: MIT [pypi-image]: https://img.shields.io/pypi/v/kydns [pypi-url]: https://pypi.org/project/kydns

KYDNS

KYDNS (Know Your DNS) is a simple DNS client library written in Python 3. It allows sending DNS queries for A and AAAA 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.
To install KYDNS, simply clone the repository:

git clone https://github.com/eliaonceagain/kydns.git

Or

pip install kydns

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         +
/                               /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<--

Fixed length fields are represented with | and variable length fields with /. If the name field is an offset, | is used.

Packet Modification

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

kydns-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

kydns-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file kydns-0.1.0.tar.gz.

File metadata

  • Download URL: kydns-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 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

Hashes for kydns-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b5930c434e117edf99501b44c2ffcb1895c21f644529fa6dd1c37ddaa9db3db
MD5 6c2ea5bc9738bc554aac5190a89cab53
BLAKE2b-256 40efd22f190ea898825494c301877275e8215828c52f67b1b34e40b7110ee23a

See more details on using hashes here.

File details

Details for the file kydns-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kydns-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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

Hashes for kydns-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba3eb3fda9ce9251612bb7dee39dafeb82799010cff05bc613cfb0336fb9e878
MD5 99692cf3c47cd6dcc94ed6d9e6bd2731
BLAKE2b-256 325808b587bdfebf9e0c8b023f40aa642ba6f6eeb030caec485f2fbabbc5f358

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page