Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why am i getting this error when i try to answer my own dns request?

import scapy.all as scapy
p = scapy.DNS(qd=scapy.DNSQR(qname='www.example.com'), an=scapy.DNSRR(rrname='127.0.0.1'))
scapy.send(p)

result :

    Traceback (most recent call last):
  File "/home/kali/PROJECTS/server.py", line 3, in <module>
    scapy.send(p)
  File "/usr/lib/python3/dist-packages/scapy/sendrecv.py", line 425, in send
    return _send(
  File "/usr/lib/python3/dist-packages/scapy/sendrecv.py", line 395, in _send
    results = __gen_send(socket, x, inter=inter, loop=loop,
  File "/usr/lib/python3/dist-packages/scapy/sendrecv.py", line 360, in __gen_send
    s.send(p)
  File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 605, in send
    self.outs.bind(sdto)
TypeError: AF_PACKET address must be a tuple of two to five elements

Why am i getting this error when i try to answer my own dns request ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to specify the destination address and the ports.

p = scapy.IP(dst='127.0.0.1') / scapy.UDP(sport=53, dport = client_port) / scapy.DNS(qd=scapy.DNSQR(qname='www.example.com'), an=scapy.DNSRR(rrname='127.0.0.1'))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading