1

我想使用 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

Wireshark 截图 - scapy

Wireshark 截图 - 挖掘

嗅探dig命令本身,看起来几乎相同,但它给了我一个正确的响应,而且它不会发送另一个ICMP - Destination unreachable数据包..这只会在使用 scapy 发送它时出现。

如果您需要更多信息,请随时询问。也许有人可以帮我解决这个问题..

编辑:

也许ICMP - Destination unreachable数据包被发送是因为8.8.4.4试图将响应发送到 my sport,它已关闭?但是为什么要dig工作呢?!

4

1 回答 1

0

让 Python 代码与 scapy..

srp(Ether()/IP(src="192.168.1.101",dst="8.8.8.8")/UDP(sport=RandShort(),dport=53)/DNS(rd=1,qd=DNSQR(qname="google.com",qtype="ALL",qclass="IN"),ar=DNSRROPT(rclass=3000)),timeout=1,verbose=0)

在 Wireshark 中,我们现在可以看到正确的响应: Wireshark Screenshot

但是我仍然收到ICMP - Destination unreachable数据包..我不知道为什么..

于 2016-08-05T04:04:33.647 回答