(self, resolution)
return retVal
Crafts raw DNS resolution response packet
Crafts raw DNS resolution response packet
Crafts raw DNS resolution response packet
def response(self, resolution):
        """
        Crafts raw DNS resolution response packet
        """

        retVal = ""

        if self._query:
            retVal += self._raw[:2]                                             # Transaction ID
            retVal += "\x85\x80"                                                # 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:(12 + self._raw[12:].find("\x00") + 5)]      # Original Domain Name Query
            retVal += "\xc0\x0c"                                                # Pointer to domain name
            retVal += "\x00\x01"                                                # Type A
            retVal += "\x00\x01"                                                # Class IN
            retVal += "\x00\x00\x00\x20"                                        # TTL (32 seconds)
            retVal += "\x00\x04"                                                # Data length
            retVal += "".join(chr(int(_)) for _ in resolution.split('.'))       # 4 bytes of IP

        return retVal
def response ( self , resolution ) : retVal = "" if self . _query : retVal += self . _raw [ : 2 ] # Transaction ID retVal += "\x85\x80" # 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 : ( 12 + self . _raw [ 12 : ] . find ( "\x00" ) + 5 ) ] # Original Domain Name Query retVal += "\xc0\x0c" # Pointer to domain name retVal += "\x00\x01" # Type A retVal += "\x00\x01" # Class IN retVal += "\x00\x00\x00\x20" # TTL (32 seconds) retVal += "\x00\x04" # Data length retVal += "" . join ( chr ( int ( _ ) ) for _ in resolution . split ( '.' ) ) # 4 bytes of IP return retVal