當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。