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)
结果 :
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
当我尝试回答自己的 dns 请求时,为什么会出现此错误?
您必须指定目标地址和端口。
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'))