我想使用 python 模块 scapy 执行等效的命令
dig ANY google.com @8.8.4.4 +notcp
我做了一个简单的示例代码:
from scapy.all import *
a = sr(IP(dst="8.8.4.4")/UDP(sport=RandShort(),dport=53)/DNS(qd=DNSQR(qname="google.com",qtype="ALL",qclass="IN")))
print str(a[0])
它发送和接收一个数据包,但是当我嗅探数据包时,响应说Server failure
。
嗅探dig
命令本身,看起来几乎相同,但它给了我一个正确的响应,而且它不会发送另一个ICMP - Destination unreachable
数据包..这只会在使用 scapy 发送它时出现。
如果您需要更多信息,请随时询问。也许有人可以帮我解决这个问题..
编辑:
也许ICMP - Destination unreachable
数据包被发送是因为8.8.4.4
试图将响应发送到 my sport
,它已关闭?但是为什么要dig
工作呢?!