当前位置: 首页>>代码示例>>Python>>正文


Python all.get_if_hwaddr方法代码示例

本文整理汇总了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 
开发者ID:noise-lab,项目名称:iot-inspector-client,代码行数:22,代码来源:utils.py

示例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) 
开发者ID:nsg-ethz,项目名称:p4-utils,代码行数:16,代码来源:send.py

示例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)) 
开发者ID:paranoidninja,项目名称:piSociEty,代码行数:8,代码来源:utils.py

示例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)) 
开发者ID:shramos,项目名称:polymorph,代码行数:8,代码来源:poison.py

示例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 
开发者ID:pilotak,项目名称:HomeAssistant-CustomComponents,代码行数:11,代码来源:arpspoof.py


注:本文中的scapy.all.get_if_hwaddr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。