Reputation: 43
I've been using Scapy to craft packets and test my network, but the programmer inside me is itching to know how to do this without Scapy.
For example, how do I craft a DNS Query using sockets (I assume it's sockets that would be used).
Thanks
Upvotes: 3
Views: 2698
Reputation: 138
To open a UDP socket you'd use:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_UDP
To send use:
query = craft_dns_query() # you do this part
s.sendto(query,(socket.inet_aton("8.8.8.8",53))
To receive the response use:
response = s.recv(1024)
You'll have to refer to documentation on DNS for actually crafting the messages and handling the responses.
Upvotes: 2