简体   繁体   English

发送scapy IP数据包,没有接口IP错误

[英]Sending scapy IP packet with no interface IP error

I'm currently trying to send an IP packet to an interface using the send(pkt, iface="eth0") function and I'm getting the error: 我正在尝试使用send(pkt,iface =“eth0”)函数将IP数据包发送到接口,我收到错误:

WARNING: Mac address to reach destination not found. Using broadcast

The interface I am trying to send out on doesn't have an IP address, and thats the way I would prefer it. 我试图发送的接口没有IP地址,这就是我喜欢的方式。 And if it makes a difference, the interface is a bridge (created with brctl) 如果它有所不同,界面是一个桥(用brctl创建)

There is an ARP entry for the host that is in the IP packet however it seems scapy isn't doing the lookup required to get the MAC from the ARP table... IP数据包中存在主机的ARP条目,但似乎scapy没有进行从ARP表中获取MAC所需的查找...

Thoughts?! 思考?

I would say this is normal, since making a valid ARP request requires an IP address (and Scapy maintains its own ARP table, independent from the OS one). 我认为这是正常的,因为制作有效的ARP请求需要一个IP地址(并且Scapy维护自己的ARP表,独立于OS)。

You can set the destination address yourself: srp(Ether(dst="[MAC address]")/[...]) . 您可以自己设置目标地址: srp(Ether(dst="[MAC address]")/[...]) If you need to get the MAC address first, create and send an ARP request the same way. 如果您需要先获取MAC地址,请以相同方式创建并发送ARP请求。

To query Scapy's ARP table, access the element conf.netcache.arp_cache , which is a Scapy-specific dict subclass (called CacheInstance ). 要查询Scapy的ARP表,请访问conf.netcache.arp_cache元素,该元素是Scapy特定的dict子类(称为CacheInstance )。

For example, to add an entry for your host (and then use sr([...]) instead of srp(Ether(dst="[MAC address])/[...]) ), use: 例如,要为主机添加条目(然后使用sr([...])而不是srp(Ether(dst="[MAC address])/[...]) ),请使用:

conf.netcache.arp_cache['[IP address]'] = '[MAC address]'

The default dst address (MAC address) of an Ethernet frame in scapy is broadcast. scapy中以太网帧的默认dst地址(MAC地址)是广播的。 This warning is generated whenever you send an Ethernet frame to the broadcast address (ff:ff:ff:ff:ff:ff), as far as I'm concerned. 每当您将以太网帧发送到广播地址(ff:ff:ff:ff:ff:ff)时,就会产生此警告,就我而言。 You can see this by creating the packet like this: 你可以通过这样创建数据包来看到这个:

Ether()/IP() or Ether()/ARP() 以太()/ IP()或以太()/ ARP()

instead of just IP() or ARP(). 而不仅仅是IP()或ARP()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM