本文整理汇总了Python中scapy.all.get_if_hwaddr方法的典型用法代码示例。如果您正苦于以下问题:Python all.get_if_hwaddr方法的具体用法?Python all.get_if_hwaddr怎么用?Python all.get_if_hwaddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scapy.all
的用法示例。
在下文中一共展示了all.get_if_hwaddr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_my_mac_set
# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import get_if_hwaddr [as 别名]
def get_my_mac_set(iface_filter=None):
"""Returns a set of MAC addresses of the current host."""
out_set = set()
if sys.platform.startswith("win"):
from scapy.arch.windows import NetworkInterface
if type(iface_filter) == NetworkInterface:
out_set.add(iface_filter.mac)
for iface in sc.get_if_list():
if iface_filter is not None and iface != iface_filter:
continue
try:
mac = sc.get_if_hwaddr(iface)
except Exception as e:
continue
else:
out_set.add(mac)
return out_set
示例2: main
# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import get_if_hwaddr [as 别名]
def main():
if len(sys.argv)<3:
print 'pass 2 arguments: <destination> "<message>"'
exit(1)
addr = socket.gethostbyname(sys.argv[1])
iface = get_if()
print "sending on interface %s to %s" % (iface, str(addr))
pkt = Ether(src=get_if_hwaddr(iface), dst='ff:ff:ff:ff:ff:ff')
pkt = pkt /IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / sys.argv[2]
pkt.show2()
sendp(pkt, iface=iface, verbose=False)
示例3: get_mac
# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import get_if_hwaddr [as 别名]
def get_mac(interface):
try:
mac_address = get_if_hwaddr(interface)
return mac_address
except Exception as e:
shutdown("Error retrieving MAC address from {}: {}".format(interface, e))
示例4: get_mac
# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import get_if_hwaddr [as 别名]
def get_mac(self):
try:
mac_address = get_if_hwaddr(self._iface)
return mac_address
except Exception as e:
print("Error retrieving MAC address from {}: {}".format(self._iface, e))
示例5: get_default_gateway_mac
# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import get_if_hwaddr [as 别名]
def get_default_gateway_mac(self, interface):
try:
return get_if_hwaddr(interface)
except OSError as e:
_LOGGER.error(
"Error when trying to get MAC of router on interface '%s': %s",
e.args[1])
return None