Crypt0s / FakeDns

A regular-expression based python MITM DNS server with support for DNS Rebinding attacks
MIT License
547 stars 147 forks source link

dns.conf.example uses invalid syntax at L5 #42

Open ptnapoleon opened 3 years ago

ptnapoleon commented 3 years ago

Currently https://github.com/Crypt0s/FakeDns/blob/2123879d7e361c7198b486c684882d5e96fe6edd/dns.conf.example#L5 has a space between 1.1.1.1 and 2.2.2.2. This should be a ,.

While experimenting locally with the python script, I found that issuing a request with nslookup for rebind.com returns 1.1.1.1 as expected. However, future requests of rebind.com return ;; Warning: Message parser reports malformed message packet.

While watching the output of fakedns.py, I found that every request after the first generated this exception:

----------------------------------------
Exception happened during processing of request from ('10.244.0.8', 37657)
Traceback (most recent call last):
  File "/usr/lib/python3.8/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "fakedns.py", line 35, in handle
    respond(data, self.client_address, s)
  File "fakedns.py", line 632, in respond
    response = rules.match(p, addr[0])
  File "fakedns.py", line 600, in match
    response = CASE[query.type](query, response_data)
  File "fakedns.py", line 220, in __init__
    self.data = self.get_ip(record)
  File "fakedns.py", line 226, in get_ip
    return b''.join(int(x).to_bytes(1, 'little') for x in ip.split('.'))
  File "fakedns.py", line 226, in <genexpr>
    return b''.join(int(x).to_bytes(1, 'little') for x in ip.split('.'))
ValueError: invalid literal for int() with base 10: ''
----------------------------------------

After inserting a print(ip) immediately above the offending return statement, I found that 1.1.1.1 is printed while processing the first DNS request, but all future ones just print 2. After updating the conf file to use the correct syntax, the issue stopped happening. At first I thought this was a problem in the script, but it appears to be an issue with the example conf.