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


Python log_loading.warning方法代码示例

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


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

示例1: load_from_dnet

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def load_from_dnet(self):
        """Populate interface table via dnet"""
        for i in pcapdnet.dnet.intf():
            try:
                # XXX: Only Ethernet for the moment: localhost is not supported by dnet and pcap
                # We only take interfaces that have an IP address, because the IP
                # is used for the mapping between dnet and pcap interface names
                # and this significantly improves Scapy's startup performance
                if i["name"].startswith("eth") and "addr" in i:
                    self.data[i["name"]] = NetworkInterface(i)
            except (KeyError, PcapNameNotFoundError):
                pass
        if len(self.data) == 0:
            log_loading.warning("No match between your pcap and dnet network interfaces found. "
                                "You probably won't be able to send packets. "
                                "Deactivating unneeded interfaces and restarting Scapy might help.") 
开发者ID:medbenali,项目名称:CyberScan,代码行数:18,代码来源:__init__.py

示例2: load_manuf

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def load_manuf(filename):
    """
    Loads manuf file from Wireshark.

    :param filename: the file to load the manuf file from
    :returns: a ManufDA filled object
    """
    manufdb = ManufDA(_name=filename)
    with open(filename, "rb") as fdesc:
        for line in fdesc:
            try:
                line = line.strip()
                if not line or line.startswith(b"#"):
                    continue
                parts = line.split(None, 2)
                ouib, shrt = parts[:2]
                lng = parts[2].lstrip(b"#").strip() if len(parts) > 2 else b""
                lng = lng or shrt
                oui = plain_str(ouib)
                manufdb[oui] = plain_str(shrt), plain_str(lng)
            except Exception:
                log_loading.warning("Couldn't parse one line from [%s] [%r]",
                                    filename, line, exc_info=True)
    return manufdb 
开发者ID:secdev,项目名称:scapy,代码行数:26,代码来源:data.py

示例3: read_routes

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def read_routes():
    ok = 0
    routes = []
    ip = '(\d+\.\d+\.\d+\.\d+)'
    # On Vista and Windows 7 the gateway can be IP or 'On-link'.
    # But the exact 'On-link' string depends on the locale, so we allow any text.
    gw_pattern = '(.+)'
    metric_pattern = "(\d+)"
    delim = "\s+"        # The columns are separated by whitespace
    netstat_line = delim.join([ip, ip, gw_pattern, ip, metric_pattern])
    pattern = re.compile(netstat_line)
    f=os.popen("netstat -rn")
    for l in f.readlines():
        match = re.search(pattern,l)
        if match:
            dest   = match.group(1)
            mask   = match.group(2)
            gw     = match.group(3)
            netif  = match.group(4)
            metric = match.group(5)
            try:
                intf = pcapdnet.dnet.intf().get_dst(pcapdnet.dnet.addr(type=2, addrtxt=dest))
            except OSError:
                log_loading.warning("Building Scapy's routing table: Couldn't get outgoing interface for destination %s" % dest)
                continue               
            if not intf.has_key("addr"):
                break
            addr = str(intf["addr"])
            addr = addr.split("/")[0]
            
            dest = atol(dest)
            mask = atol(mask)
            # If the gateway is no IP we assume it's on-link
            gw_ipmatch = re.search('\d+\.\d+\.\d+\.\d+', gw)
            if gw_ipmatch:
                gw = gw_ipmatch.group(0)
            else:
                gw = netif
            routes.append((dest,mask,gw, str(intf["name"]), addr))
    f.close()
    return routes 
开发者ID:medbenali,项目名称:CyberScan,代码行数:43,代码来源:__init__.py

示例4: _reload

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def _reload(self):
        self.pdfreader = None
        self.psreader = None
        self.svgreader = None
        # We try some magic to find the appropriate executables
        self.dot = win_find_exe("dot")
        self.tcpdump = win_find_exe("windump")
        self.tshark = win_find_exe("tshark")
        self.tcpreplay = win_find_exe("tcpreplay")
        self.display = self._default
        self.hexedit = win_find_exe("hexer")
        self.sox = win_find_exe("sox")
        self.wireshark = win_find_exe("wireshark", "wireshark")
        self.usbpcapcmd = win_find_exe(
            "USBPcapCMD",
            installsubdir="USBPcap",
            env="programfiles"
        )
        self.powershell = win_find_exe(
            "powershell",
            installsubdir="System32\\WindowsPowerShell\\v1.0",
            env="SystemRoot"
        )
        self.cscript = win_find_exe("cscript", installsubdir="System32",
                                    env="SystemRoot")
        self.cmd = win_find_exe("cmd", installsubdir="System32",
                                env="SystemRoot")
        if self.wireshark:
            try:
                new_manuf = load_manuf(
                    os.path.sep.join(
                        self.wireshark.split(os.path.sep)[:-1]
                    ) + os.path.sep + "manuf"
                )
            except (IOError, OSError):  # FileNotFoundError not available on Py2 - using OSError  # noqa: E501
                log_loading.warning("Wireshark is installed, but cannot read manuf !")  # noqa: E501
                new_manuf = None
            if new_manuf:
                # Inject new ManufDB
                conf.manufdb.__dict__.clear()
                conf.manufdb.__dict__.update(new_manuf.__dict__) 
开发者ID:secdev,项目名称:scapy,代码行数:43,代码来源:__init__.py

示例5: _pcap_service_control

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def _pcap_service_control(action, askadmin=True):
    """Internal util to run pcap control command"""
    command = action + ' ' + pcap_service_name()
    res, code = _exec_cmd(_encapsulate_admin(command) if askadmin else command)
    if code != 0:
        warning(res.decode("utf8", errors="ignore"))
    return (code == 0) 
开发者ID:secdev,项目名称:scapy,代码行数:9,代码来源:__init__.py

示例6: _pcap_check

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def _pcap_check(cls):
        """Performs checks/restart pcap adapter"""
        if not conf.use_pcap:
            # Winpcap/Npcap isn't installed
            return

        _detect = pcap_service_status()

        def _ask_user():
            if not conf.interactive:
                return False
            msg = "Do you want to start it ? (yes/no) [y]: "
            try:
                # Better IPython compatibility
                import IPython
                return IPython.utils.io.ask_yes_no(msg, default='y')
            except (NameError, ImportError):
                while True:
                    _confir = input(msg)
                    _confir = _confir.lower().strip()
                    if _confir in ["yes", "y", ""]:
                        return True
                    elif _confir in ["no", "n"]:
                        return False
        if _detect:
            # No action needed
            return
        else:
            warning(
                "Scapy has detected that your pcap service is not running !"
            )
            if not conf.interactive or _ask_user():
                succeed = pcap_service_start(askadmin=conf.interactive)
                if succeed:
                    log_loading.info("Pcap service started !")
                    return
        warning("Could not start the pcap service ! "
                "You probably won't be able to send packets. "
                "Deactivating unneeded interfaces and restarting "
                "Scapy might help. Check your winpcap/npcap installation "
                "and access rights.") 
开发者ID:secdev,项目名称:scapy,代码行数:43,代码来源:__init__.py

示例7: read_routes6

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def read_routes6():
    routes6 = []
    if WINDOWS_XP:
        return routes6
    try:
        routes6 = _read_routes_c(ipv6=True)
    except Exception as e:
        warning("Error building scapy IPv6 routing table : %s", e)
    return routes6 
开发者ID:secdev,项目名称:scapy,代码行数:11,代码来源:__init__.py

示例8: load_from_powershell

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def load_from_powershell(self):
        for i in get_windows_if_list():
            try:
                interface = NetworkInterface(i)
                self.data[interface.name] = interface
            except (KeyError, PcapNameNotFoundError):
                pass
        if len(self.data) == 0:
            log_loading.warning("No match between your pcap and windows network interfaces found. "
                                "You probably won't be able to send packets. "
                                "Deactivating unneeded interfaces and restarting Scapy might help."
                                "Check your winpcap and powershell installation, and access rights.") 
开发者ID:entynetproject,项目名称:arissploit,代码行数:14,代码来源:__init__.py

示例9: read_routes

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def read_routes():
    routes = []
    if_index = '(\d+)'
    dest = '(\d+\.\d+\.\d+\.\d+)/(\d+)'
    next_hop = '(\d+\.\d+\.\d+\.\d+)'
    metric_pattern = "(\d+)"
    delim = "\s+"        # The columns are separated by whitespace
    netstat_line = delim.join([if_index, dest, next_hop, metric_pattern])
    pattern = re.compile(netstat_line)
    # This works only starting from Windows 8/2012 and up. For older Windows another solution is needed
    ps = sp.Popen(['powershell', 'Get-NetRoute', '-AddressFamily IPV4', '|', 'select ifIndex, DestinationPrefix, NextHop, RouteMetric'], stdout = sp.PIPE, universal_newlines = True)
    stdout, stdin = ps.communicate(timeout = 10)
    for l in stdout.split('\n'):
        match = re.search(pattern,l)
        if match:
            try:
                iface = devname_from_index(int(match.group(1)))
                addr = ifaces[iface].ip
            except:
                continue
            dest = atol(match.group(2))
            mask = itom(int(match.group(3)))
            gw = match.group(4)
            # try:
            #     intf = pcapdnet.dnet.intf().get_dst(pcapdnet.dnet.addr(type=2, addrtxt=dest))
            # except OSError:
            #     log_loading.warning("Building Scapy's routing table: Couldn't get outgoing interface for destination %s" % dest)
            #     continue               
            routes.append((dest, mask, gw, iface, addr))
    return routes 
开发者ID:entynetproject,项目名称:arissploit,代码行数:32,代码来源:__init__.py

示例10: load_services

# 需要导入模块: from scapy.error import log_loading [as 别名]
# 或者: from scapy.error.log_loading import warning [as 别名]
def load_services(filename):
    spaces = re.compile(b"[ \t]+|\n")
    tdct = DADict(_name="%s-tcp" % filename)
    udct = DADict(_name="%s-udp" % filename)
    try:
        with open(filename, "rb") as fdesc:
            for line in fdesc:
                try:
                    shrp = line.find(b"#")
                    if shrp >= 0:
                        line = line[:shrp]
                    line = line.strip()
                    if not line:
                        continue
                    lt = tuple(re.split(spaces, line))
                    if len(lt) < 2 or not lt[0]:
                        continue
                    dtct = None
                    if lt[1].endswith(b"/tcp"):
                        dtct = tdct
                    elif lt[1].endswith(b"/udp"):
                        dtct = udct
                    else:
                        continue
                    port = lt[1].split(b'/')[0]
                    name = fixname(lt[0])
                    if b"-" in port:
                        sport, eport = port.split(b"-")
                        for i in range(int(sport), int(eport) + 1):
                            dtct[i] = name
                    else:
                        dtct[int(port)] = name
                except Exception as e:
                    log_loading.warning(
                        "Couldn't parse file [%s]: line [%r] (%s)",
                        filename,
                        line,
                        e,
                    )
    except IOError:
        log_loading.info("Can't open /etc/services file")
    return tdct, udct 
开发者ID:secdev,项目名称:scapy,代码行数:44,代码来源:data.py


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