mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
feature: pcapConverter runs over all pcap in directory
This commit is contained in:
parent
f50e99c753
commit
4a8dbe2d4e
1 changed files with 45 additions and 29 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue