本文整理汇总了Python中scapy.error.log_loading.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: load_services
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
if lt[1].endswith(b"/tcp"):
tdct[lt[0]] = int(lt[1].split(b'/')[0])
elif lt[1].endswith(b"/udp"):
udct[lt[0]] = int(lt[1].split(b'/')[0])
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:netkey,项目名称:scapy,代码行数:31,代码来源:data.py
示例2: load_protocols
def load_protocols(filename, _integer_base=10):
""""Parse /etc/protocols and return values as a dictionary."""
spaces = re.compile(b"[ \t]+|\n")
dct = DADict(_name=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
dct[lt[0]] = int(lt[1], _integer_base)
except Exception as e:
log_loading.info(
"Couldn't parse file [%s]: line [%r] (%s)",
filename,
line,
e,
)
except IOError:
log_loading.info("Can't open %s file", filename)
return dct
开发者ID:netkey,项目名称:scapy,代码行数:28,代码来源:data.py
示例3: resync
def resync(self):
# TODO : At the moment, resync will drop existing Teredo routes
# if any. Change that ...
self.invalidate_cache()
self.routes = read_routes6()
if self.routes == []:
log_loading.info("No IPv6 support in kernel")
开发者ID:segment-routing,项目名称:scapy,代码行数:7,代码来源:route6.py
示例4: load_services
def load_services(filename):
spaces = re.compile("[ \t]+|\n")
tdct=DADict(_name="%s-tcp"%filename)
udct=DADict(_name="%s-udp"%filename)
try:
f=open(filename)
for l in f:
try:
shrp = l.find("#")
if shrp >= 0:
l = l[:shrp]
l = l.strip()
if not l:
continue
lt = tuple(re.split(spaces, l))
if len(lt) < 2 or not lt[0]:
continue
if lt[1].endswith("/tcp"):
tdct[lt[0]] = int(lt[1].split('/')[0])
elif lt[1].endswith("/udp"):
udct[lt[0]] = int(lt[1].split('/')[0])
except Exception as e:
log_loading.warning("Couldn't file [%s]: line [%r] (%s)" % (filename,l,e))
f.close()
except IOError:
log_loading.info("Can't open /etc/services file")
return tdct,udct
开发者ID:thibaultdelmas,项目名称:scapy,代码行数:27,代码来源:data.py
示例5: load_from_powershell
def load_from_powershell(self):
if not conf.prog.os_access:
return
ifaces_ips = None
for i in get_windows_if_list():
try:
interface = NetworkInterface(i)
self.data[interface.guid] = interface
# If no IP address was detected using winpcap and if
# the interface is not the loopback one, look for
# internal windows interfaces
if not interface.ip:
if not ifaces_ips: # ifaces_ips is used as a cache
ifaces_ips = get_ips()
# If it exists, retrieve the interface's IP from the cache
interface.ip = ifaces_ips.get(interface.name, "")
except (KeyError, PcapNameNotFoundError):
pass
if not self.data and conf.use_winpcapy:
_detect = pcap_service_status()
def _ask_user():
if not conf.interactive:
return False
while True:
_confir = input("Do you want to start it ? (yes/no) [y]: ").lower().strip() # noqa: E501
if _confir in ["yes", "y", ""]:
return True
elif _confir in ["no", "n"]:
return False
return False
_error_msg = "No match between your pcap and windows network interfaces found. " # noqa: E501
if _detect[0] and not _detect[2] and not (hasattr(self, "restarted_adapter") and self.restarted_adapter): # noqa: E501
warning("Scapy has detected that your pcap service is not running !") # noqa: E501
if not conf.interactive or _ask_user():
succeed = pcap_service_start(askadmin=conf.interactive)
self.restarted_adapter = True
if succeed:
log_loading.info("Pcap service started !")
self.load_from_powershell()
return
_error_msg = "Could not start the pcap service ! "
warning(_error_msg +
"You probably won't be able to send packets. "
"Deactivating unneeded interfaces and restarting Scapy might help. " # noqa: E501
"Check your winpcap and powershell installation, and access rights.") # noqa: E501
else:
# Loading state: remove invalid interfaces
self.remove_invalid_ifaces()
# Replace LOOPBACK_INTERFACE
try:
scapy.consts.LOOPBACK_INTERFACE = self.dev_from_name(
scapy.consts.LOOPBACK_NAME,
)
except:
pass
开发者ID:plorinquer,项目名称:scapy,代码行数:57,代码来源:__init__.py
示例6: load_from_powershell
def load_from_powershell(self):
if not conf.prog.os_access:
return
for i in get_windows_if_list():
try:
interface = NetworkInterface(i)
self.data[interface.guid] = interface
except (KeyError, PcapNameNotFoundError):
pass
if len(self.data) == 0 and conf.use_winpcapy:
_detect = pcap_service_status()
def _ask_user():
if not conf.interactive:
return False
while True:
_confir = raw_input("Do you want to start it ? (yes/no) [y]: ").lower().strip()
if _confir in ["yes", "y", ""]:
return True
elif _confir in ["no", "n"]:
return False
return False
_error_msg = "No match between your pcap and windows network interfaces found. "
if _detect[0] and not _detect[2] and ((hasattr(self, "restarted_adapter") and not self.restarted_adapter)
or not hasattr(self, "restarted_adapter")):
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)
self.restarted_adapter = True
if succeed:
log_loading.info("Pcap service started !")
self.load_from_powershell()
return
_error_msg = "Could not start the pcap service ! "
warning(_error_msg +
"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.", True)
else:
# Loading state: remove invalid interfaces
self.remove_invalid_ifaces()
# Replace LOOPBACK_INTERFACE
try:
scapy.consts.LOOPBACK_INTERFACE = self.dev_from_name(LOOPBACK_NAME)
except:
pass
开发者ID:mcpat,项目名称:scapy,代码行数:46,代码来源:__init__.py
示例7: init_session
def init_session(session_name, mydict=None):
global SESSION
global GLOBKEYS
scapy_builtins = {k: v for k, v in six.iteritems(importlib.import_module(".all", "scapy").__dict__) if _validate_local(k)} # noqa: E501
six.moves.builtins.__dict__.update(scapy_builtins)
GLOBKEYS.extend(scapy_builtins)
GLOBKEYS.append("scapy_session")
scapy_builtins = None # XXX replace with "with" statement
if session_name:
try:
os.stat(session_name)
except OSError:
log_loading.info("New session [%s]" % session_name)
else:
try:
try:
SESSION = six.moves.cPickle.load(gzip.open(session_name, "rb")) # noqa: E501
except IOError:
SESSION = six.moves.cPickle.load(open(session_name, "rb"))
log_loading.info("Using session [%s]" % session_name)
except EOFError:
log_loading.error("Error opening session [%s]" % session_name)
except AttributeError:
log_loading.error("Error opening session [%s]. Attribute missing" % session_name) # noqa: E501
if SESSION:
if "conf" in SESSION:
conf.configure(SESSION["conf"])
conf.session = session_name
SESSION["conf"] = conf
else:
conf.session = session_name
else:
conf.session = session_name
SESSION = {"conf": conf}
else:
SESSION = {"conf": conf}
six.moves.builtins.__dict__["scapy_session"] = SESSION
if mydict is not None:
six.moves.builtins.__dict__["scapy_session"].update(mydict)
update_ipython_session(mydict)
GLOBKEYS.extend(mydict)
开发者ID:segment-routing,项目名称:scapy,代码行数:46,代码来源:main.py
示例8: load_ethertypes
def load_ethertypes(filename):
spaces = re.compile("[ \t]+|\n")
dct = DADict(_name=filename)
try:
f=open(filename)
for l in f:
try:
shrp = l.find("#")
if shrp >= 0:
l = l[:shrp]
l = l.strip()
if not l:
continue
lt = tuple(re.split(spaces, l))
if len(lt) < 2 or not lt[0]:
continue
dct[lt[0]] = int(lt[1], 16)
except Exception,e:
log_loading.info("Couldn't parse file [%s]: line [%r] (%s)" % (filename,l,e))
f.close()
开发者ID:guedou,项目名称:scapy-issues,代码行数:20,代码来源:data.py
示例9: load_protocols
def load_protocols(filename):
spaces = re.compile("[ \t]+|\n")
dct = DADict(_name=filename)
try:
for l in open(filename):
try:
shrp = l.find("#")
if shrp >= 0:
l = l[:shrp]
l = l.strip()
if not l:
continue
lt = tuple(re.split(spaces, l))
if len(lt) < 2 or not lt[0]:
continue
dct[lt[0]] = int(lt[1])
except Exception,e:
log_loading.info("Couldn't parse file [%s]: line [%r] (%s)" % (filename,l,e))
except IOError:
log_loading.info("Can't open %s file" % filename)
return dct
开发者ID:guedou,项目名称:scapy-issues,代码行数:21,代码来源:data.py
示例10: load_session
def load_session(fname=None):
"""Load current Scapy session from the file specified in the fname arg.
This will erase any existing session.
params:
- fname: file to load the scapy session from"""
if fname is None:
fname = conf.session
try:
s = six.moves.cPickle.load(gzip.open(fname,"rb"))
except IOError:
try:
s = six.moves.cPickle.load(open(fname,"rb"))
except IOError:
# Raise "No such file exception"
raise
scapy_session = six.moves.builtins.__dict__["scapy_session"]
scapy_session.clear()
scapy_session.update(s)
update_ipython_session(scapy_session)
log_loading.info("Loaded session [%s]" % fname)
开发者ID:6WIND,项目名称:scapy,代码行数:23,代码来源:main.py
示例11: PrismHeader
FieldListField, XStrFixedLenField, PacketField
from scapy.ansmachine import AnsweringMachine
from scapy.plist import PacketList
from scapy.layers.l2 import Ether, LLC, MACField
from scapy.layers.inet import IP, TCP
from scapy.error import warning, log_loading
from scapy.sendrecv import sniff, sendp
from scapy.utils import issubtype
if conf.crypto_valid:
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms
else:
default_backend = Ciphers = algorithms = None
log_loading.info("Can't import python-cryptography v1.7+. Disabled WEP decryption/encryption. (Dot11)") # noqa: E501
# Layers
class PrismHeader(Packet):
""" iwpriv wlan0 monitor 3 """
name = "Prism header"
fields_desc = [LEIntField("msgcode", 68),
LEIntField("len", 144),
StrFixedLenField("dev", "", 16),
LEIntField("hosttime_did", 0),
LEShortField("hosttime_status", 0),
LEShortField("hosttime_len", 0),
LEIntField("hosttime", 0),
开发者ID:netkey,项目名称:scapy,代码行数:31,代码来源:dot11.py
示例12: tuple
l = l[:shrp]
l = l.strip()
if not l:
continue
lt = tuple(re.split(spaces, l))
if len(lt) < 2 or not lt[0]:
continue
if lt[1].endswith("/tcp"):
tdct[lt[0]] = int(lt[1].split('/')[0])
elif lt[1].endswith("/udp"):
udct[lt[0]] = int(lt[1].split('/')[0])
except Exception,e:
log_loading.warning("Couldn't file [%s]: line [%r] (%s)" % (filename,l,e))
f.close()
except IOError:
log_loading.info("Can't open /etc/services file")
return tdct,udct
class ManufDA(DADict):
def fixname(self, val):
return val
def _get_manuf_couple(self, mac):
oui = ":".join(mac.split(":")[:3]).upper()
return self.__dict__.get(oui,(mac,mac))
def _get_manuf(self, mac):
return self._get_manuf_couple(mac)[1]
def _get_short_manuf(self, mac):
return self._get_manuf_couple(mac)[0]
def _resolve_MAC(self, mac):
oui = ":".join(mac.split(":")[:3]).upper()
开发者ID:guedou,项目名称:scapy-issues,代码行数:31,代码来源:data.py
示例13: inet_aton
except socket.error:
def inet_aton(x):
if x == "255.255.255.255":
return "\xff"*4
else:
return socket.inet_aton(x)
else:
inet_aton = socket.inet_aton
inet_ntoa = socket.inet_ntoa
try:
inet_ntop = socket.inet_ntop
inet_pton = socket.inet_pton
except AttributeError:
from scapy.pton_ntop import *
log_loading.info("inet_ntop/pton functions not found. Python IPv6 support not present")
def atol(x):
try:
ip = inet_aton(x)
except socket.error:
ip = inet_aton(socket.gethostbyname(x))
return struct.unpack("!I", ip)[0]
def ltoa(x):
return inet_ntoa(struct.pack("!I", x&0xffffffff))
def itom(x):
return (0xffffffff00000000L>>x)&0xffffffffL
def do_graph(graph,prog=None,format=None,target=None,type=None,string=None,options=None):
开发者ID:danieljakots,项目名称:scapy,代码行数:31,代码来源:utils.py
示例14: except
chainCC=chainCC,
nofilter=1)
if res is not None:
mac = res.payload.hwsrc
conf.netcache.arp_cache[ip] = mac
return mac
return None
import scapy.layers.l2
scapy.layers.l2.getmacbyip = getmacbyip
try:
import readline
console = readline.GetOutputFile()
except (ImportError, AttributeError):
log_loading.info("Could not get readline console. Will not interpret ANSI color codes.")
else:
conf.readfunc = readline.rl.readline
orig_stdout = sys.stdout
sys.stdout = console
def sndrcv(pks, pkt, timeout = 2, inter = 0, verbose=None, chainCC=0, retry=0, multi=0):
if not isinstance(pkt, Gen):
pkt = SetGen(pkt)
if verbose is None:
verbose = conf.verb
开发者ID:0x0d,项目名称:hijack,代码行数:31,代码来源:__init__.py
示例15: Copyright
## This file is part of Scapy
## See http://www.secdev.org/projects/scapy for more informations
## Copyright (C) Philippe Biondi <[email protected]>
## This program is published under a GPLv2 license
"""
All layers. Configurable with conf.load_layers.
"""
import importlib
from scapy.config import conf
from scapy.error import log_loading
import logging
log = logging.getLogger("scapy.loading")
log_loading.info("Please, report issues to https://github.com/phaethon/scapy")
def _import_star(m):
#mod = __import__("." + m, globals(), locals())
mod = importlib.import_module("scapy.layers." + m)
for k,v in mod.__dict__.items():
globals()[k] = v
for _l in conf.load_layers:
log_loading.debug("Loading layer %s" % _l)
try:
_import_star(_l)
except Exception as e:
log.warning("can't import layer %s: %s" % (_l,e))
开发者ID:437049211,项目名称:PyQYT,代码行数:29,代码来源:all.py
示例16: data_for_encryption
def data_for_encryption(self):
return bytes(self.data) + self.padding + chr(self.padlen).encode('ascii') + chr(self.nh).encode('ascii')
#------------------------------------------------------------------------------
try:
from cryptography.exceptions import InvalidTag
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import (
Cipher,
algorithms,
modes,
)
except ImportError:
# no error if pycrypto is not available but encryption won't be supported
log_loading.info("Can't import python cryptography lib. "
"Disabled IPsec encryption/authentication.")
algorithms = None
Cipher = None
modes = None
#------------------------------------------------------------------------------
def _lcm(a, b):
"""
Least Common Multiple between 2 integers.
"""
if a == 0 or b == 0:
return 0
else:
return abs(a * b) // gcd(a, b)
class CryptAlgo(object):
开发者ID:4shadoww,项目名称:usploit,代码行数:31,代码来源:ipsec.py
示例17: import
from scapy.layers.inet import IP
from scapy.layers.inet6 import IPv6
from scapy.compat import raw
from scapy.data import ETH_P_MACSEC, ETHER_TYPES, ETH_P_IP, ETH_P_IPV6
from scapy.error import log_loading
import scapy.modules.six as six
if conf.crypto_valid:
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import (
Cipher,
algorithms,
modes,
)
else:
log_loading.info("Can't import python-cryptography v1.7+. "
"Disabled MACsec encryption/authentication.")
NOSCI_LEN = 14 + 6
SCI_LEN = 8
DEFAULT_ICV_LEN = 16
class MACsecSA(object):
"""Representation of a MACsec Secure Association
Provides encapsulation, decapsulation, encryption, and decryption
of MACsec frames
"""
def __init__(self, sci, an, pn, key, icvlen, encrypt, send_sci, xpn_en=False, ssci=None, salt=None): # noqa: E501
if isinstance(sci, six.integer_types):
开发者ID:commial,项目名称:scapy,代码行数:32,代码来源:macsec.py
示例18: matplotlib_get_backend
try:
from matplotlib import get_backend as matplotlib_get_backend
import matplotlib.pyplot as plt
MATPLOTLIB = 1
if "inline" in matplotlib_get_backend():
MATPLOTLIB_INLINED = 1
else:
MATPLOTLIB_INLINED = 0
MATPLOTLIB_DEFAULT_PLOT_KARGS = {"marker": "+"}
# RuntimeError to catch gtk "Cannot open display" error
except (ImportError, RuntimeError):
plt = None
MATPLOTLIB = 0
MATPLOTLIB_INLINED = 0
MATPLOTLIB_DEFAULT_PLOT_KARGS = dict()
log_loading.info("Can't import matplotlib. Won't be able to plot.")
# PYX
def _test_pyx():
"""Returns if PyX is correctly installed or not"""
try:
with open(os.devnull, 'wb') as devnull:
r = subprocess.check_call(["pdflatex", "--version"],
stdout=devnull, stderr=subprocess.STDOUT)
except (subprocess.CalledProcessError, OSError):
return False
else:
return r == 0
开发者ID:commial,项目名称:scapy,代码行数:30,代码来源:extlib.py
示例19: import
CANSocket.
"""
from scapy.error import log_loading
from scapy.consts import LINUX
from scapy.config import conf
import scapy.modules.six as six
PYTHON_CAN = False
try:
if conf.contribs['CANSocket']['use-python-can']:
from can import BusABC as can_BusABC # noqa: F401
PYTHON_CAN = True
except ImportError:
log_loading.info("Can't import python-can.")
except KeyError:
log_loading.info("Specify 'conf.contribs['CANSocket'] = "
"{'use-python-can': True}' to enable python-can.")
if PYTHON_CAN:
from scapy.contrib.cansocket_python_can import (CANSocket, # noqa: F401
srcan, CANSocketTimeoutElapsed, CAN_FRAME_SIZE, CAN_INV_FILTER) # noqa: E501
elif LINUX and six.PY3:
log_loading.info("Use native CANSocket. Specify "
"'conf.contribs['CANSocket'] = "
"{'use-python-can': True}' to enable python-can.")
from scapy.contrib.cansocket_native import (CANSocket, # noqa: F401
srcan, CAN_FRAME_SIZE, CAN_INV_FILTER) # noqa: E501
else:
开发者ID:commial,项目名称:scapy,代码行数:31,代码来源:cansocket.py
注:本文中的scapy.error.log_loading.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论