Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions fakedns.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,27 @@ def __init__(self, query, txt_record):
# length field for this since it is already in the right spot
self.length += chr(len(txt_record))

# MX
class MX(DNSResponse):
def __init__(self, query, txt_record):
super(MX, self).__init__(query)
self.type = "\x00\x0f"
self.data = "\x00\x01" + self.get_domain(txt_record) +"\x00"
self.length = chr(len(txt_record) + 4)
if self.length < '\xff':
self.length = "\x00" + self.length

@staticmethod
def get_domain(dns_record):
domain = dns_record
ret_domain=[]
for x in domain.split('.'):
st = "{:02x}".format(len(x))
ret_domain.append( st.decode("hex"))
ret_domain.append(x)
return "".join(ret_domain)



class SOA(DNSResponse):
def __init__(self, query, config_location):
Expand Down Expand Up @@ -345,6 +366,7 @@ def convert(fqdn):
"\x00\x05": CNAME,
"\x00\x0c": PTR,
"\x00\x10": TXT,
"\x00\x0f": MX,
"\x00\x06": SOA,
}

Expand Down