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