Enviado em 24/06/2018 - 14:01h
Boa tarde galera!
class DnsPacket(BigEndianStructure):
""" Class representative to DNS header.
This class handle a bytes buffer in ctypes field mode """
def __new__(cls, buffer):
return cls.from_buffer_copy(buffer)
_fields_ = [('identification', c_uint, 16),
('query_type', c_uint, 1),
('optional_code', c_uint, 4),
('authoritative_answer', c_uint, 1),
('truncation', c_uint, 1),
('recursion_desired', c_uint, 1),
('recursion_available', c_uint, 1),
('reserved_for_future', c_uint, 3),
('response_code', c_uint, 4),
('question_count', c_uint, 16),
('answer_count', c_uint, 16),
('nameserver_count', c_uint, 16),
('aditional_count', c_uint, 16)]
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| |
/ QNAME /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QTYPE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QCLASS |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
class QuestionSection(BigEndianStructure):
_fields_ = [('size', c_uint),
('name', label), # Aqui criariamos uma string baseado no tamanho da label acima.
def get_domain_name(self, data):
array_data = bytearray(data[sizeof(self):])
expected_lenght = array_data.pop(0)
nameserver = ''
while expected_lenght is not 0:
for _ in range(expected_lenght):
nameserver += chr(array_data.pop(0))
expected_lenght = array_data.pop(0)
if expected_lenght is not 0:
nameserver += '.'
return nameserver
Atualizar o macOS no Mac - Opencore Legacy Patcher
Crie alias para as tarefas que possuam longas linhas de comando - bash e zsh
Criando um gateway de internet com o Debian
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Aprenda a criar músicas com Inteligência Artificial usando Suno AI
Instalando e usando o Dconf Editor, o "regedit" para Linux
Como instalar o navegador TOR no seu Linux
Instalando Zoom Client no Ubuntu 24.04 LTS
Em que pasta/arquivo ficam as configurações das janelas em derivados d... (3)
validando quandidade de leitura no read[DUVIDA] (2)
Qual a relevancia dos valores de bogomips com os Mhz e Ghz[DUVIDA] (4)
Jogar jogos do Win 10 no Ubuntu (6)
Som parou de funcionar depois de atualizar o kernel do Slackware 15 (1)