Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create_DNS_query(hostname):
- packet = struct.pack("!H", 12049) # Query Ids (Just 12049, Can randomize if you want)
- packet += struct.pack("!H", 256) # Flags (0x0100, Recursive Query)
- packet += struct.pack("!H", 1) # Questions
- packet += struct.pack("!H", 0) # Answers RRs
- packet += struct.pack("!H", 0) # Authorities RRs
- packet += struct.pack("!H", 0) # Additional RRs
- split_url = hostname.split(".")
- for part in split_url:
- packet += struct.pack("B", len(part))
- for byte in part:
- packet += struct.pack("c", byte.encode('ascii'))
- packet += struct.pack("B", 0) # End of String (implies that there is no URL information ahead)
- packet += struct.pack("!H", 1) # Query Type
- packet += struct.pack("!H", 1) # Query Class
- return packet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement