本文整理汇总了Python中pcapy.findalldevs方法的典型用法代码示例。如果您正苦于以下问题:Python pcapy.findalldevs方法的具体用法?Python pcapy.findalldevs怎么用?Python pcapy.findalldevs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pcapy
的用法示例。
在下文中一共展示了pcapy.findalldevs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getInterface
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import findalldevs [as 别名]
def getInterface():
# Grab a list of interfaces that pcap is able to listen on.
# The current user will be able to listen from all returned interfaces,
# using open_live to open them.
ifs = findalldevs()
# No interfaces available, abort.
if 0 == len(ifs):
print "You don't have enough permissions to open any interface on this system."
sys.exit(1)
# Only one interface available, use it.
elif 1 == len(ifs):
print 'Only one interface present, defaulting to it.'
return ifs[0]
# Ask the user to choose an interface from the list.
count = 0
for iface in ifs:
print '%i - %s' % (count, iface)
count += 1
idx = int(raw_input('Please select an interface: '))
return ifs[idx]
示例2: getInterface
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import findalldevs [as 别名]
def getInterface():
# Grab a list of interfaces that pcap is able to listen on.
# The current user will be able to listen from all returned interfaces,
# using open_live to open them.
ifs = findalldevs()
# No interfaces available, abort.
if 0 == len(ifs):
print("You don't have enough permissions to open any interface on this system.")
sys.exit(1)
# Only one interface available, use it.
elif 1 == len(ifs):
print('Only one interface present, defaulting to it.')
return ifs[0]
# Ask the user to choose an interface from the list.
count = 0
for iface in ifs:
print('%i - %s' % (count, iface))
count += 1
idx = int(input('Please select an interface: '))
return ifs[idx]
示例3: canvas_detect
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import findalldevs [as 别名]
def canvas_detect(self):
self.lilnew1.delete(0, END)
holddevices=pcapy.findalldevs()
for devices in holddevices:
if devices=="any":
self.lilnew1.insert(0, )
elif devices=="lo":
self.lilnew1.insert(0, )
else:
self.lilnew1.insert(0, devices)
示例4: __init__
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import findalldevs [as 别名]
def __init__(self, iface, filename='test.pcap', pcFilter=None, num_packets=3000):
# list all the network devices
# print pcapy.findalldevs()
max_bytes = 1024
promiscuous = False
read_timeout = 100 # in milliseconds
pc = pcapy.open_live(iface, max_bytes, promiscuous, read_timeout)
if pcFilter: pc.setfilter(pcFilter)
self.dumper = pc.dump_open(filename)
pc.loop(num_packets, self.recv_pkts) # capture packets
# callback for received packets
示例5: getInterfaces
# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import findalldevs [as 别名]
def getInterfaces():
# Grab a list of interfaces that pcap is able to listen on.
# The current user will be able to listen from all returned interfaces,
# using open_live to open them.
ifs = findalldevs()
# No interfaces available, abort.
if 0 == len(ifs):
return "You don't have enough permissions to open any interface on this system."
return ifs