本文整理汇总了Python中scapy.config.conf.L2socket方法的典型用法代码示例。如果您正苦于以下问题:Python conf.L2socket方法的具体用法?Python conf.L2socket怎么用?Python conf.L2socket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scapy.config.conf
的用法示例。
在下文中一共展示了conf.L2socket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: srp1flood
# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import L2socket [as 别名]
def srp1flood(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2 and return only the first answer
:param prn: function applied to packets received
:param verbose: set verbosity level
:param nofilter: put 1 to avoid use of BPF filters
:param filter: provide a BPF filter
:param iface: listen answers only on the given interface
"""
s = conf.L2socket(promisc=promisc, filter=filter, nofilter=nofilter, iface=iface) # noqa: E501
ans, _ = sndrcvflood(s, x, *args, **kargs)
s.close()
if len(ans) > 0:
return ans[0][1]
# SNIFF METHODS
示例2: __init__
# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import L2socket [as 别名]
def __init__(self, *args, **kargs):
kargs.setdefault("ll", conf.L2socket)
kargs.setdefault("monitor", True)
super(KrackAP, self).__init__(*args, **kargs)
示例3: sendp
# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import L2socket [as 别名]
def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None,
verbose=None, realtime=None,
return_packets=False, socket=None, *args, **kargs):
"""
Send packets at layer 2
:param x: the packets
:param inter: time (in s) between two packets (default 0)
:param loop: send packet indefinetly (default 0)
:param count: number of packets to send (default None=1)
:param verbose: verbose mode (default None=conf.verbose)
:param realtime: check that a packet was sent before sending the next one
:param return_packets: return the sent packets
:param socket: the socket to use (default is conf.L3socket(kargs))
:param iface: the interface to send the packets on
:param monitor: (not on linux) send in monitor mode
:returns: None
"""
if iface is None and iface_hint is not None and socket is None:
iface = conf.route.route(iface_hint)[0]
need_closing = socket is None
socket = socket or conf.L2socket(iface=iface, *args, **kargs)
results = __gen_send(socket, x, inter=inter, loop=loop,
count=count, verbose=verbose,
realtime=realtime, return_packets=return_packets)
if need_closing:
socket.close()
return results
示例4: srp
# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import L2socket [as 别名]
def srp(x, promisc=None, iface=None, iface_hint=None, filter=None,
nofilter=0, type=ETH_P_ALL, *args, **kargs):
"""
Send and receive packets at layer 2
"""
if iface is None and iface_hint is not None:
iface = conf.route.route(iface_hint)[0]
s = conf.L2socket(promisc=promisc, iface=iface,
filter=filter, nofilter=nofilter, type=type)
result = sndrcv(s, x, *args, **kargs)
s.close()
return result
示例5: srpflood
# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import L2socket [as 别名]
def srpflood(x, promisc=None, filter=None, iface=None, iface_hint=None, nofilter=None, *args, **kargs): # noqa: E501
"""Flood and receive packets at layer 2
:param prn: function applied to packets received
:param unique: only consider packets whose print
:param nofilter: put 1 to avoid use of BPF filters
:param filter: provide a BPF filter
:param iface: listen answers only on the given interface
"""
if iface is None and iface_hint is not None:
iface = conf.route.route(iface_hint)[0]
s = conf.L2socket(promisc=promisc, filter=filter, iface=iface, nofilter=nofilter) # noqa: E501
r = sndrcvflood(s, x, *args, **kargs)
s.close()
return r
示例6: start
# 需要导入模块: from scapy.config import conf [as 别名]
# 或者: from scapy.config.conf import L2socket [as 别名]
def start(self):
self.s = conf.L2socket(iface=self.iface)