0
大家好,我試圖找到一些方法來檢查當我用scapy嗅探.pcap文件時有多少tcp和udp數據包。如果你能向我解釋某種方式來做到這一點,我會很高興。在sccapy中查找.pcap文件中的udp和tcp數據包的數量
from scapy.all import *
import time
def main():
path = raw_input("Enter path: ") # .pcap file
packs = rdpcap(path)
option = 0
while (option != 4):
print "Options: soon "
option = input("Enter your option: ")
i = 0
count = 0
if(option == 1):
print "Number of packets: "
pack_len = len(packs)
print pack_len
print "Sniff tome: "
print time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(packs[0].time))
print time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(packs[pack_len-1].time))
elif(option == 2):
pass # HERE I NEED TO CHECK HOW MANY TCP AND UDP PACKETS I HAVE
elif(option == 3):
path = raw_input("Enter new path: ")
packs = rdpcap(path)
if __name__ == "__main__":
main()
謝謝它的工作,但下次使用[i]代替(i)和+ =代表計數器。 –
已更新。你能介意我的答案嗎? – FitzChivalry