本文整理匯總了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)