feature: pcapConverter runs over all pcap in directory

This commit is contained in:
uhi22 2023-04-18 00:28:32 +02:00
parent f50e99c753
commit 4a8dbe2d4e

View file

@ -12,8 +12,10 @@
import pyshark import pyshark
import exiConnector import exiConnector
import os
inputFileName = "efcaec23.pcap"
def convertPcapToTxt(inputFileName):
cap = pyshark.FileCapture(inputFileName, display_filter="ipv6") cap = pyshark.FileCapture(inputFileName, display_filter="ipv6")
fileOut = open(inputFileName + '.decoded.txt', 'w') fileOut = open(inputFileName + '.decoded.txt', 'w')
#print(cap) #print(cap)
@ -43,3 +45,17 @@ for packet in cap:
print(decoded, file=fileOut) print(decoded, file=fileOut)
fileOut.close() fileOut.close()
# assign directory
directory = '../temp'
# iterate over files in
# that directory
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
# checking if it is a file
if os.path.isfile(f):
print(f)
if (f[-5:]==".pcap") or (f[-7:]==".pcapng"):
strFileNameWithPath = f
print("Will decode " + strFileNameWithPath)
convertPcapToTxt(strFileNameWithPath)