【问题标题】:Python - dig ANY equivalent with scapy modulePython - 使用 scapy 模块挖掘任何等价物
【发布时间】:2016-08-04 08:58:31
【问题描述】:

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

Wireshark Screenshot - dig

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

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

编辑:

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

【问题讨论】:

    标签: python dns scapy any dig


    【解决方案1】:

    让 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 数据包.. 我不知道为什么..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-26
      • 2021-12-15
      • 2018-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-11
      • 2010-10-03
      相关资源
      最近更新 更多