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


Python conf.iface方法代码示例

本文整理汇总了Python中scapy.config.conf.iface方法的典型用法代码示例。如果您正苦于以下问题:Python conf.iface方法的具体用法?Python conf.iface怎么用?Python conf.iface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.config.conf的用法示例。


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

示例1: arping

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def arping(net, timeout=2, cache=0, verbose=None, **kargs):
    """Send ARP who-has requests to determine which hosts are up
arping(net, [cache=0,] [iface=conf.iface,] [verbose=conf.verb]) -> None
Set cache=True if you want arping to modify internal ARP-Cache"""
    if verbose is None:
        verbose = conf.verb
    ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=net), verbose=verbose,
                    filter="arp and arp[7] = 2", timeout=timeout, iface_hint=net, **kargs)
    ans = ARPingResult(ans.res)

    if cache and ans is not None:
        for pair in ans:
            arp_cache[pair[1].psrc] = (pair[1].hwsrc, time.time())
    if verbose:
        ans.show()
    return ans,unans 
开发者ID:medbenali,项目名称:CyberScan,代码行数:18,代码来源:l2.py

示例2: send

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def send(self, x):
        iff,a,gw  = x.route()
        if iff is None:
            iff = conf.iface
        sdto = (iff, self.type)
        self.outs.bind(sdto)
        sn = self.outs.getsockname()
        ll = lambda x:x
        if type(x) in conf.l3types:
            sdto = (iff, conf.l3types[type(x)])
        if sn[3] in conf.l2types:
            ll = lambda x:conf.l2types[sn[3]]()/x
        try:
            sx = str(ll(x))
            x.sent_time = time.time()
            self.outs.sendto(sx, sdto)
        except socket.error,msg:
            x.sent_time = time.time()  # bad approximation
            if conf.auto_fragment and msg[0] == 90:
                for p in x.fragment():
                    self.outs.sendto(str(ll(p)), sdto)
            else:
                raise 
开发者ID:medbenali,项目名称:CyberScan,代码行数:25,代码来源:linux.py

示例3: __init__

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def __init__(self, iface = None, type = ETH_P_ALL, promisc=None, filter=None):
                self.type = type
                self.outs = None
                self.iface = iface
                if iface is None:
                    iface = conf.iface
                if promisc is None:
                    promisc = conf.sniff_promisc
                self.promisc = promisc
                self.ins = open_pcap(iface, 1600, self.promisc, 100)
                try:
                    ioctl(self.ins.fileno(),BIOCIMMEDIATE,struct.pack("I",1))
                except:
                    pass
                if type == ETH_P_ALL: # Do not apply any filter if Ethernet type is given
                    if conf.except_filter:
                        if filter:
                            filter = "(%s) and not (%s)" % (filter, conf.except_filter)
                        else:
                            filter = "not (%s)" % conf.except_filter
                    if filter:
                        self.ins.setfilter(filter) 
开发者ID:medbenali,项目名称:CyberScan,代码行数:24,代码来源:pcapdnet.py

示例4: send

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def send(self, x):
            iff,a,gw  = x.route()
            if iff is None:
                iff = conf.iface
            ifs,cls = self.iflist.get(iff,(None,None))
            if ifs is None:
                iftype = self.intf.get(iff)["type"]
                if iftype == dnet.INTF_TYPE_ETH:
                    try:
                        cls = conf.l2types[1]
                    except KeyError:
                        warning("Unable to find Ethernet class. Using nothing")
                    ifs = dnet.eth(iff)
                else:
                    ifs = dnet.ip()
                self.iflist[iff] = ifs,cls
            if cls is None:
                sx = str(x)
            else:
                sx = str(cls()/x)
            x.sent_time = time.time()
            ifs.send(sx) 
开发者ID:medbenali,项目名称:CyberScan,代码行数:24,代码来源:pcapdnet.py

示例5: recv

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def recv(self,x=MTU):
            ll = self.ins.datalink()
            if ll in conf.l2types:
                cls = conf.l2types[ll]
            else:
                cls = conf.default_l2
                warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name))
    
            pkt = self.ins.next()
            if pkt is not None:
                ts,pkt = pkt
            if pkt is None:
                return
    
            try:
                pkt = cls(pkt)
            except KeyboardInterrupt:
                raise
            except:
                if conf.debug_dissector:
                    raise
                pkt = conf.raw_layer(pkt)
            pkt.time = ts
            return pkt.payload 
开发者ID:medbenali,项目名称:CyberScan,代码行数:26,代码来源:pcapdnet.py

示例6: __attrs_post_init__

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def __attrs_post_init__(self):
        """Initializes attributes after attrs __init__.

        These attributes do not change during the life of the object.

        """
        logger.debug('Creating new DHCPCAP obj.')
        if self.iface is None:
            self.iface = conf.iface
        if self.client_mac is None:
            _, client_mac = get_if_raw_hwaddr(self.iface)
            self.client_mac = str2mac(client_mac)
        if self.prl is None:
            self.prl = PRL
        if self.xid is None:
            self.xid = gen_xid()
        logger.debug('Modifying Lease obj, setting iface.')
        self.lease.interface = self.iface 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:20,代码来源:dhcpcap.py

示例7: handle_offer_ack

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def handle_offer_ack(self, pkt, time_sent_request=None):
        """Create a lease object with the values in OFFER/ACK packet."""
        attrs_dict = dict()
        for opt in pkt[DHCP].options:
            if isinstance(opt, tuple) and opt[0] in DHCP_OFFER_OPTIONS:
                v = opt[1] if len(opt[1:]) < 2 else ' '.join(opt[1:])
                v = str(v.decode('utf8')) if isinstance(v, bytes) else str(v)
                attrs_dict[opt[0]] = v
        attrs_dict.update({
            "interface": self.iface,
            "address": pkt[BOOTP].yiaddr,
            "next_server": pkt[BOOTP].siaddr,
        })
        # this function changes the dict
        self.gen_check_lease_attrs(attrs_dict)
        logger.debug('Creating Lease obj.')
        logger.debug('with attrs %s', attrs_dict)
        lease = DHCPCAPLease(**attrs_dict)
        return lease 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:21,代码来源:dhcpcap.py

示例8: reset

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def reset(self, iface=None, client_mac=None, xid=None, scriptfile=None):
        """Reset object attributes when state is INIT."""
        logger.debug('Reseting attributes.')
        if iface is None:
            iface = conf.iface
        if client_mac is None:
            # scapy for python 3 returns byte, not tuple
            tempmac = get_if_raw_hwaddr(iface)
            if isinstance(tempmac, tuple) and len(tempmac) == 2:
                mac = tempmac[1]
            else:
                mac = tempmac
            client_mac = str2mac(mac)
        self.client = DHCPCAP(iface=iface, client_mac=client_mac, xid=xid)
        if scriptfile is not None:
            self.script = ClientScript(scriptfile)
        else:
            self.script = None
        self.time_sent_request = None
        self.discover_attempts = 0
        self.request_attempts = 0
        self.current_state = STATE_PREINIT
        self.offers = list() 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:25,代码来源:dhcpcapfsm.py

示例9: send_discover

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def send_discover(self):
        """Send discover."""
        assert self.client
        assert self.current_state == STATE_INIT or \
            self.current_state == STATE_SELECTING
        pkt = self.client.gen_discover()
        sendp(pkt)
        # FIXME:20 check that this is correct,: all or only discover?
        if self.discover_attempts < MAX_ATTEMPTS_DISCOVER:
            self.discover_attempts += 1
        timeout = gen_timeout_resend(self.discover_attempts)
        self.set_timeout(self.current_state,
                         self.timeout_selecting,
                         timeout)
        # logger.info('DHCPDISCOVER on %s to %s port %s' %
        #             (self.client.iface, self.client.server_mac,
        #              self.client.server_port))) 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:19,代码来源:dhcpcapfsm.py

示例10: BOUND

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def BOUND(self):
        """BOUND state."""
        logger.debug('In state: BOUND')
        logger.info('(%s) state changed %s -> bound', self.client.iface,
                    STATES2NAMES[self.current_state])
        self.current_state = STATE_BOUND
        self.client.lease.info_lease()
        if self.script is not None:
            self.script.script_init(self.client.lease, self.current_state)
            self.script.script_go()
        else:
            try:
                set_net(self.client.lease)
            except Exception as e:
                logger.error('Can not set IP', exc_info=True)
                # raise self.END()
        # TODO: go daemon? 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:19,代码来源:dhcpcapfsm.py

示例11: arping

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def arping(net, timeout=2, cache=0, verbose=None, **kargs):
    """Send ARP who-has requests to determine which hosts are up
arping(net, [cache=0,] [iface=conf.iface,] [verbose=conf.verb]) -> None
Set cache=True if you want arping to modify internal ARP-Cache"""
    if verbose is None:
        verbose = conf.verb
    ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=net), verbose=verbose,
                    filter="arp and arp[7] = 2", timeout=timeout, iface_hint=net, **kargs)
    ans = ARPingResult(ans.res)

    if cache and ans is not None:
        for pair in ans:
            conf.netcache.arp_cache[pair[1].psrc] = (pair[1].hwsrc, time.time())
    if verbose:
        ans.show()
    return ans,unans 
开发者ID:theralfbrown,项目名称:smod-1,代码行数:18,代码来源:l2.py

示例12: __repr__

# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import iface [as 别名]
def __repr__(self):
        rtlst = []

        for net, msk, gw, iface, cset, metric in self.routes:
            rtlst.append(('%s/%i' % (net, msk),
                          gw,
                          (iface if isinstance(iface, six.string_types)
                           else iface.description),
                          ", ".join(cset) if len(cset) > 0 else "",
                          str(metric)))

        return pretty_list(rtlst,
                           [('Destination', 'Next Hop', "Iface", "Src candidates", "Metric")],  # noqa: E501
                           sortBy=1)

    # Unlike Scapy's Route.make_route() function, we do not have 'host' and 'net'  # noqa: E501
    # parameters. We only have a 'dst' parameter that accepts 'prefix' and
    # 'prefix/prefixlen' values.
    # WARNING: Providing a specific device will at the moment not work correctly.  # noqa: E501 
开发者ID:secdev,项目名称:scapy,代码行数:21,代码来源:route6.py


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