Skip to content

Commit e28f5ef

Browse files
committed
Replaced IPy library with built in ipaddress library
1 parent 6a04090 commit e28f5ef

File tree

7 files changed

+9
-18
lines changed

7 files changed

+9
-18
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Version 0.4
33
* Ported to Python 3.6+
44
* Made everything a bit more PEP8 compliant
55
* Improved logging
6+
* Removed IPy library (replaced with built-in ipaddress library)
67

78
Version 0.3
89

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2014 Peter Kacherginsky
1+
Copyright (C) 2014 Peter Kacherginsky, Marcello Salvati
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

Pipfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ verify_ssl = true
77

88
[packages]
99
dnslib = "*"
10-
ipy = "*"

Pipfile.lock

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ Internal architecture
335335

336336
Here is some information on the internals in case you need to adapt the tool for your needs. DNSChef is built on top of the SocketServer module and uses threading to help process multiple requests simultaneously. The tool is designed to listen on TCP or UDP ports (default is port 53) for incoming requests and forward those requests when necessary to a real DNS server over UDP.
337337

338-
The excellent [dnslib library](https://bitbucket.org/paulc/dnslib/wiki/Home) is used to dissect and reassemble DNS packets. It is particularly useful when generating response packets based on queries. [IPy](https://github.com/haypo/python-ipy/) is used for IPv6 addresses manipulation. Both libraries come bundled with DNSChef to ease installation.
338+
The excellent [dnslib library](https://bitbucket.org/paulc/dnslib/wiki/Home) is used to dissect and reassemble DNS packets. It is particularly useful when generating response packets based on queries.
339339

340340
DNSChef is capable of modifing queries for records of type "A", "AAAA", "MX", "CNAME", "NS", "TXT", "PTR", "NAPTR", "SOA", "ANY". It is very easy to expand or modify behavior for any record. Simply add another **if qtype == "RECORD TYPE")** entry and tell it what to reply with.
341341

dnschef.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from configparser import ConfigParser
3939

4040
from dnslib import *
41-
from IPy import IP
41+
from ipaddress import ip_address
4242

4343
import logging
4444
import threading
@@ -128,9 +128,7 @@ def parse(self, data):
128128

129129
# IPv6 needs additional work before inclusion:
130130
if qtype == "AAAA":
131-
ipv6 = IP(fake_record)
132-
ipv6_bin = ipv6.strBin()
133-
ipv6_hex_tuple = [int(ipv6_bin[i:i+8],2) for i in range(0,len(ipv6_bin),8)]
131+
ipv6_hex_tuple = list(map(int, ip_address(fake_record).packed))
134132
response.add_answer(RR(qname, getattr(QTYPE,qtype), rdata=RDMAP[qtype](ipv6_hex_tuple)))
135133

136134
elif qtype == "SOA":
@@ -203,9 +201,7 @@ def parse(self, data):
203201
# NOTE: RDMAP is a dictionary map of qtype strings to handling classses
204202
# IPv6 needs additional work before inclusion:
205203
if qtype == "AAAA":
206-
ipv6 = IP(fake_record)
207-
ipv6_bin = ipv6.strBin()
208-
fake_record = [int(ipv6_bin[i:i+8],2) for i in range(0,len(ipv6_bin),8)]
204+
fake_record = list(map(int, ip_address(fake_record).packed))
209205

210206
elif qtype == "SOA":
211207
mname,rname,t1,t2,t3,t4,t5 = fake_record.split(" ")

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-i https://pypi.org/simple
2+
dnslib==0.9.10

0 commit comments

Comments
 (0)