def __init__(self, message, offset): data = DNSQuestion.decode_domain_name(message, offset) self.primary_name_server = data[0] offset = data[1] data = DNSQuestion.decode_domain_name(message, offset) self.authority_mailbox = data[0] offset = data[1] self.serial_number = str( struct.unpack('!I', message[offset:offset + 4])[0]) offset += 4 self.refresh_interval = str( struct.unpack('!I', message[offset:offset + 4])[0]) offset += 4 self.retry_interval = struct.unpack('!I', message[offset:offset + 4])[0] offset += 4 self.expire_limit = struct.unpack('!I', message[offset:offset + 4])[0] offset += 4 self.minimum_TTL = struct.unpack('!I', message[offset:offset + 4])[0]
def decode_info(self, message, offset): name_offset = struct.unpack_from('!H', message, offset)[0] & 0x1fff self.host_name = DNSQuestion.decode_domain_name(message, name_offset)[0] offset += 2 self.type = struct.unpack('!H', message[offset:offset + 2])[0] offset += 2 self.request_class = struct.unpack('!H', message[offset:offset + 2])[0] offset += 2 self.ttl = struct.unpack('!I', message[offset:offset + 4])[0] offset += 4 self.data_length = struct.unpack('!H', message[offset:offset + 2])[0] offset += 2 for i in range(self.data_length): self.address += str( struct.unpack_from('!B', message, offset + i)[0]) + '.' self.address = self.address[:-1] self.request = Request(self.data_length, self.type, message, offset) return offset + self.data_length
def __init__(self, message, offset): self.name_server = DNSQuestion.decode_domain_name(message, offset)[0]
def __init__(self, message, offset): self.priority = struct.unpack('!H', message[offset:offset + 2])[0] offset += 2 self.mail_exchanger = DNSQuestion.decode_domain_name( message, offset + 2)[0]
def __init__(self, message, offset): self.mailbox = DNSQuestion.decode_domain_name(message, offset)[0]
def __init__(self, message, offset): self.name = DNSQuestion.decode_domain_name(message, offset)[0] print(' PTR: {0}'.format(self.name)) exit(0)