User Tools

Site Tools


networking:dns:dns_response_crafter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
networking:dns:dns_response_crafter [2021/02/01 13:54] – created peternetworking:dns:dns_response_crafter [2022/10/08 09:52] (current) – [Make lots of DNS requests in quick succession:] peter
Line 1: Line 1:
 ====== Networking - DNS - DNS Response Crafter ====== ====== Networking - DNS - DNS Response Crafter ======
 +
 +===== Make lots of DNS requests in quick succession: =====
 +
 +<code python>
 +import dns.resolver
 +
 +resolver = dns.resolver.Resolver()for x in range(2, 10):
 +    for i in range(85, 200):
 +        try:
 +            print resolver.query(chr(i) * x + '.com', 'A')
 +        except:
 +            pass
 +</code>            
 +
 +<WRAP info>
 +**NOTE:**
 +
 +See: https://dnspython.readthedocs.io/en/latest/_modules/dns/resolver.html
 +
 +</WRAP>
 +
 +----
 +
 +===== Craft Specific DNS requests =====
  
 <code python> <code python>
Line 7: Line 31:
 UDP_IP_ADDRESS  = <IP−of−virtual−machine> UDP_IP_ADDRESS  = <IP−of−virtual−machine>
 RESPONSE_IP =  '123.123.123.123'  # Can be any address. RESPONSE_IP =  '123.123.123.123'  # Can be any address.
-UDP_PORT_NO = 53  # Bind to DNS port  +UDP_PORT_NO = 53  # Bind to DNS port. 
-TTL = 86400  # Time to live in cache +TTL = 86400  # Time to live in cache. 
-NAME_POINTER = "\xc0\x0c "  # Message compression rfc 1035 4.1.4910+NAME_POINTER = "\xc0\x0c "  # Message compression rfc 1035 4.1.4910.
  
 def CraftResponse(addr, data): def CraftResponse(addr, data):
   dns = DNS(data)   dns = DNS(data)
   dnsrr =  DNSRR(rrname=NAMEPOINTER, ttl=TTL, rdata=RESPONSEIP)   dnsrr =  DNSRR(rrname=NAMEPOINTER, ttl=TTL, rdata=RESPONSEIP)
-  opt = DNSRROPT(rrname= '.’ ,type= 'OPT' , rclass=512,+  opt = DNSRROPT(rrname= '.,type= 'OPT' , rclass=512,
         extrcode=0, version=0, z=0, rdlen=0)         extrcode=0, version=0, z=0, rdlen=0)
      
-  return \ # Assemble and return packet+  return \ # Assemble and return packet.
     IP(dst=addr[0])/\     IP(dst=addr[0])/\
     UDP(dport=addr[1], sport=UDPPORTNO) /\     UDP(dport=addr[1], sport=UDPPORTNO) /\
Line 26: Line 50:
          
 def main(): def main():
-  # Set up and bind socket for UDP packets+  # Set up and bind socket for UDP packets.
   s = socket.socket(socket.AFINET, socket.SOCKDGRAM)   s = socket.socket(socket.AFINET, socket.SOCKDGRAM)
   s.bind(UDPIPADDRESS, UDPPORTNO)   s.bind(UDPIPADDRESS, UDPPORTNO)
networking/dns/dns_response_crafter.1612187663.txt.gz · Last modified: 2021/02/01 13:54 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki