From fed02126317de127076dad3ff6a4e381c55882cf Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 27 May 2012 10:03:02 +0000 Subject: [PATCH] now working with recursive queries too --- lib/request/dns.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/request/dns.py b/lib/request/dns.py index 645035a00..dcad5d987 100644 --- a/lib/request/dns.py +++ b/lib/request/dns.py @@ -46,11 +46,15 @@ class DNSQuery: retVal = "" if self._query: - retVal += self._raw[:2] + "\x81\x80" + retVal += self._raw[:2] # Transaction ID + retVal += "\x84\x00" # Flags (Standard query response, No error) retVal += self._raw[4:6] + self._raw[4:6] + "\x00\x00\x00\x00" # Questions and Answers Counts - retVal += self._raw[12:] # Original Domain Name Question + retVal += self._raw[12:(12 + self._raw[12:].find("\x00") + 5)] # Original Domain Name Query retVal += "\xc0\x0c" # Pointer to domain name - retVal += "\x00\x01\x00\x01\x00\x00\x00\x3c\x00\x04" # Response type, ttl and resource data length -> 4 bytes + retVal += "\x00\x01" # Type A + retVal += "\x00\x01" # Class IN + retVal += "\x00\x00\x01\x2c" # TTL + retVal += "\x00\x04" # Data length retVal += "".join(chr(int(_)) for _ in resolution.split('.')) # 4 bytes of IP return retVal