本文整理匯總了Python中scapy.config.conf.verb方法的典型用法代碼示例。如果您正苦於以下問題:Python conf.verb方法的具體用法?Python conf.verb怎麽用?Python conf.verb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scapy.config.conf
的用法示例。
在下文中一共展示了conf.verb方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: arping
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [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
示例2: arping
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [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
示例3: netflowv9_defragment
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def netflowv9_defragment(plist, verb=1):
"""Process all NetflowV9/10 Packets to match IDs of the DataFlowsets
with the Headers
params:
- plist: the list of mixed NetflowV9/10 packets.
- verb: verbose print (0/1)
"""
if not isinstance(plist, (PacketList, list)):
plist = [plist]
# We need the whole packet to be dissected to access field def in
# NetflowFlowsetV9 or NetflowOptionsFlowsetV9/10
definitions = {}
definitions_opts = {}
ignored = set()
# Iterate through initial list
for pkt in plist:
_netflowv9_defragment_packet(pkt,
definitions,
definitions_opts,
ignored)
if conf.verb >= 1 and ignored:
warning("Ignored templateIDs (missing): %s" % list(ignored))
return plist
示例4: arping
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [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, # noqa: E501
filter="arp and arp[7] = 2", timeout=timeout, iface_hint=net, **kargs) # noqa: E501
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()) # noqa: E501
if ans is not None and verbose:
ans.show()
return ans, unans
示例5: _recv_sf
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def _recv_sf(self, data):
"""Process a received 'Single Frame' frame"""
if self.rx_timeout_handle is not None:
self.rx_timeout_handle.cancel()
self.rx_timeout_handle = None
if self.rx_state != ISOTP_IDLE:
if conf.verb > 2:
warning("RX state was reset because single frame was received")
self.rx_state = ISOTP_IDLE
length = six.indexbytes(data, 0) & 0xf
if len(data) - 1 < length:
return 1
msg = data[1:1 + length]
self.rx_queue.put(msg)
for cb in self.rx_callbacks:
cb(msg)
self.call_release()
return 0
示例6: arpcachepoison
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def arpcachepoison(target, victim, interval=60):
"""Poison target's cache with (your MAC,victim's IP) couple
arpcachepoison(target, victim, [interval=60]) -> None
"""
tmac = getmacbyip(target)
p = Ether(dst=tmac)/ARP(op="who-has", psrc=victim, pdst=target)
try:
while 1:
sendp(p, iface_hint=target)
if conf.verb > 1:
os.write(1,".")
time.sleep(interval)
except KeyboardInterrupt:
pass
示例7: traceroute
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def traceroute(target, dport=80, minttl=1, maxttl=30, sport=RandShort(), l4 = None, filter=None, timeout=2, verbose=None, **kargs):
"""Instant TCP traceroute
traceroute(target, [maxttl=30,] [dport=80,] [sport=80,] [verbose=conf.verb]) -> None
"""
if verbose is None:
verbose = conf.verb
if filter is None:
# we only consider ICMP error packets and TCP packets with at
# least the ACK flag set *and* either the SYN or the RST flag
# set
filter="(icmp and (icmp[0]=3 or icmp[0]=4 or icmp[0]=5 or icmp[0]=11 or icmp[0]=12)) or (tcp and (tcp[13] & 0x16 > 0x10))"
if l4 is None:
a,b = sr(IP(dst=target, id=RandShort(), ttl=(minttl,maxttl))/TCP(seq=RandInt(),sport=sport, dport=dport),
timeout=timeout, filter=filter, verbose=verbose, **kargs)
else:
# this should always work
filter="ip"
a,b = sr(IP(dst=target, id=RandShort(), ttl=(minttl,maxttl))/l4,
timeout=timeout, filter=filter, verbose=verbose, **kargs)
a = TracerouteResult(a.res)
if verbose:
a.show()
return a,b
#############################
## Simple TCP client stack ##
#############################
示例8: traceroute6
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def traceroute6(target, dport=80, minttl=1, maxttl=30, sport=RandShort(),
l4 = None, timeout=2, verbose=None, **kargs):
"""
Instant TCP traceroute using IPv6 :
traceroute6(target, [maxttl=30], [dport=80], [sport=80]) -> None
"""
if verbose is None:
verbose = conf.verb
if l4 is None:
a,b = sr(IPv6(dst=target, hlim=(minttl,maxttl))/TCP(seq=RandInt(),sport=sport, dport=dport),
timeout=timeout, filter="icmp6 or tcp", verbose=verbose, **kargs)
else:
a,b = sr(IPv6(dst=target, hlim=(minttl,maxttl))/l4,
timeout=timeout, verbose=verbose, **kargs)
a = TracerouteResult6(a.res)
if verbose:
a.display()
return a,b
#############################################################################
#############################################################################
### Sockets ###
#############################################################################
#############################################################################
示例9: canvas_dump
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def canvas_dump(self, **kargs):
# type: (Any) -> Any # Using Any since pyx is imported later
import pyx
d = pyx.document.document()
len_res = len(self.res)
for i, res in enumerate(self.res):
c = self._elt2pkt(res).canvas_dump(**kargs)
cbb = c.bbox()
c.text(cbb.left(), cbb.top() + 1, r"\font\cmssfont=cmss12\cmssfont{Frame %i/%i}" % (i, len_res), [pyx.text.size.LARGE]) # noqa: E501
if conf.verb >= 2:
os.write(1, b".")
d.append(pyx.document.page(c, paperformat=pyx.document.paperformat.A4, # noqa: E501
margin=1 * pyx.unit.t_cm,
fittosize=1))
return d
示例10: _read_config_file
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def _read_config_file(cf, _globals=globals(), _locals=locals(),
interactive=True):
# type: (str, Dict[str, Any], Dict[str, Any], bool) -> None
"""Read a config file: execute a python file while loading scapy, that
may contain some pre-configured values.
If _globals or _locals are specified, they will be updated with
the loaded vars. This allows an external program to use the
function. Otherwise, vars are only available from inside the scapy
console.
params:
- _globals: the globals() vars
- _locals: the locals() vars
- interactive: specified whether or not errors should be printed
using the scapy console or raised.
ex, content of a config.py file:
'conf.verb = 42\n'
Manual loading:
>>> _read_config_file("./config.py"))
>>> conf.verb
42
"""
log_loading.debug("Loading config file [%s]", cf)
try:
with open(cf) as cfgf:
exec(
compile(cfgf.read(), cf, 'exec'),
_globals, _locals
)
except IOError as e:
if interactive:
raise
log_loading.warning("Cannot read config file [%s] [%s]", cf, e)
except Exception:
if interactive:
raise
log_loading.exception("Error during evaluation of config file [%s]",
cf)
示例11: __init__
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def __init__(self, **kargs):
self.mode = 0
self.verbose = kargs.get("verbose", conf.verb >= 0)
if self.filter:
kargs.setdefault("filter", self.filter)
kargs.setdefault("prn", self.reply)
self.optam1 = {}
self.optam2 = {}
self.optam0 = {}
doptsend, doptsniff = self.parse_all_options(1, kargs)
self.defoptsend = self.send_options.copy()
self.defoptsend.update(doptsend)
self.defoptsniff = self.sniff_options.copy()
self.defoptsniff.update(doptsniff)
self.optsend, self.optsniff = [{}, {}]
示例12: __gen_send
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def __gen_send(s, x, inter=0, loop=0, count=None, verbose=None, realtime=None, return_packets=False, *args, **kargs): # noqa: E501
if isinstance(x, str):
x = conf.raw_layer(load=x)
if not isinstance(x, Gen):
x = SetGen(x)
if verbose is None:
verbose = conf.verb
n = 0
if count is not None:
loop = -count
elif not loop:
loop = -1
if return_packets:
sent_packets = PacketList()
try:
while loop:
dt0 = None
for p in x:
if realtime:
ct = time.time()
if dt0:
st = dt0 + float(p.time) - ct
if st > 0:
time.sleep(st)
else:
dt0 = ct - float(p.time)
s.send(p)
if return_packets:
sent_packets.append(p)
n += 1
if verbose:
os.write(1, b".")
time.sleep(inter)
if loop < 0:
loop += 1
except KeyboardInterrupt:
pass
if verbose:
print("\nSent %i packets." % n)
if return_packets:
return sent_packets
示例13: autorun_commands
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def autorun_commands(cmds, my_globals=None, ignore_globals=None, verb=None):
sv = conf.verb
try:
try:
if my_globals is None:
my_globals = importlib.import_module(".all", "scapy").__dict__
if ignore_globals:
for ig in ignore_globals:
my_globals.pop(ig, None)
if verb is not None:
conf.verb = verb
interp = ScapyAutorunInterpreter(my_globals)
cmd = ""
cmds = cmds.splitlines()
cmds.append("") # ensure we finish multi-line commands
cmds.reverse()
six.moves.builtins.__dict__["_"] = None
while True:
if cmd:
sys.stderr.write(sys.__dict__.get("ps2", "... "))
else:
sys.stderr.write(str(sys.__dict__.get("ps1", sys.ps1)))
line = cmds.pop()
print(line)
cmd += "\n" + line
if interp.runsource(cmd):
continue
if interp.error:
return 0
cmd = ""
if len(cmds) <= 1:
break
except SystemExit:
pass
finally:
conf.verb = sv
return _ # noqa: F821
示例14: arpcachepoison
# 需要導入模塊: from scapy.config import conf [as 別名]
# 或者: from scapy.config.conf import verb [as 別名]
def arpcachepoison(target, victim, interval=60):
"""Poison target's cache with (your MAC,victim's IP) couple
arpcachepoison(target, victim, [interval=60]) -> None
"""
tmac = getmacbyip(target)
p = Ether(dst=tmac) / ARP(op="who-has", psrc=victim, pdst=target)
try:
while True:
sendp(p, iface_hint=target)
if conf.verb > 1:
os.write(1, b".")
time.sleep(interval)
except KeyboardInterrupt:
pass