Scapy DNS 请求
Scapy DNS Request
我正在尝试使用 Scapy 在 Python 中编写一个脚本,该脚本发出 DNS 请求并接收 DNS 响应。
这是我写的:
packet = IP(dst="1.1.1.1")/ICMP()
res = sr1(packet)
if res:
print "---------------------------------------"
print "Host is Up, trying DNS Query"
print "---------------------------------------"
packet = IP(dst="1.1.1.1") / UDP() / DNS(rd=1, qd=DNSQR(qname="www.google.com"))
sr1(packet)
else:
print "Destination Unreachable!"
当我 运行 这段代码时,ping (ICMP) 工作并收到响应,但是当它发送 DNS 查询时它说:
Begin emission:
Finished sending 1 packets.
.....................................................................
它一直打印点,直到我停止它并打印:"Received 83 packets, got 0 answers, remaining 1 packets".
你知道如何解决这个问题吗?
预先感谢您的回答。
编辑:查看文档:https://scapy.readthedocs.io/en/latest/usage.html#dns-requests
使用最新的scapy版本,我无法复制:/
您发布的代码有效
一些可能对您有帮助的事情:
- 使用最新的开发版本:发布速度非常慢。在此处下载 https://github.com/secdev/scapy/archive/master.zip 并通过
python setup.py install
安装(Unix 上为 sudo)
- 尝试手动指定接口(在
sr1
中使用iface=...
)。 get_if_list()
提供完整列表
- 检查你的防火墙。它可能会阻止数据包
我正在尝试使用 Scapy 在 Python 中编写一个脚本,该脚本发出 DNS 请求并接收 DNS 响应。 这是我写的:
packet = IP(dst="1.1.1.1")/ICMP()
res = sr1(packet)
if res:
print "---------------------------------------"
print "Host is Up, trying DNS Query"
print "---------------------------------------"
packet = IP(dst="1.1.1.1") / UDP() / DNS(rd=1, qd=DNSQR(qname="www.google.com"))
sr1(packet)
else:
print "Destination Unreachable!"
当我 运行 这段代码时,ping (ICMP) 工作并收到响应,但是当它发送 DNS 查询时它说:
Begin emission:
Finished sending 1 packets.
.....................................................................
它一直打印点,直到我停止它并打印:"Received 83 packets, got 0 answers, remaining 1 packets".
你知道如何解决这个问题吗? 预先感谢您的回答。
编辑:查看文档:https://scapy.readthedocs.io/en/latest/usage.html#dns-requests
使用最新的scapy版本,我无法复制:/
您发布的代码有效
一些可能对您有帮助的事情:
- 使用最新的开发版本:发布速度非常慢。在此处下载 https://github.com/secdev/scapy/archive/master.zip 并通过
python setup.py install
安装(Unix 上为 sudo) - 尝试手动指定接口(在
sr1
中使用iface=...
)。get_if_list()
提供完整列表
- 检查你的防火墙。它可能会阻止数据包