嘿,我建立了一个嗅探器,但我不能使用gpl3.0库 所以我决定选择pyshark,但是我有很多错误...
@staticmethod
def start_channels_sniffing(channels):
processes = {}
# get all ifaces on the computer
ifaces_names = mySniffer.get_ifaces_name_list()
for channel in channels:
# if the channel's iface is exist
if channel.iface in ifaces_names or type(channel.iface) != str:
# threads[channel] = channel.start()
processes[channel.getId()] = Process(target=channel.start)
else:
print("iface: " + str(channel.iface) + " could not be found")
return processes
这是我得到流程的时候
def start(self):
while(self.cyclic == True):
cap = pyshark.LiveCapture()
#cap.interfaces = ['eth0', 'eth1','eth2','eth3']
cap.sniff(packet_count=50)
print(cap)
即函数start()
processes = {}
processes = mySniffer.start_channels_sniffing(Channels)
for key in processes.keys():
processes[key].start()
processes[key].join()
那是我开始并行工作的地方
但是该程序不会嗅探东西,有时会在cap.sniff(packet_count = 50)行上崩溃
我想问的另一个问题是,如果我想用以太网接口而不是eth0嗅探,我该怎么办?
感谢助手:)