Skip to content

Commit

Permalink
started implementation of remote file validation (see [issue#2](#2) )
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Lekov committed Jan 23, 2025
1 parent 306b4d5 commit 894a2de
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion remoteShark.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,14 @@ def addHostKeyCache(self):
return True
else:
return False


def validateRemotePcapFile(self):
""" Connects to the remote host and validates the if the remote file exists and if it correct type """
if self.cfg.debug >= 2:
printf("Validating if '%s' exist and is supported\n", cfg.remotePcapFile)
# TODO - actual implementation
return True

def runWireshark(self):
""" Connect to the remote host and start local Wireshark for live capturing of traffic """
global cfg
Expand All @@ -531,6 +538,9 @@ def runWireshark(self):
if cfg.remotePcapFile == None:
tcpdumpCMD = sprintf('%s -U -ni "%s" -s 0 -q -w - "%s" 2>/dev/null', tcpdumpCMD, cfg.interface, cfg.dumpFilter)
else:
if not self.validateRemotePcapFile():
printf("Invalid file or file format of remote pcap file\n")
self.__exit(1)
if (cfg.remotePcapFile.endswith('.gz')):
tcpdumpCMD = sprintf('zcat %s | %s -U -n -r - -s 0 -q -w - "%s" 2>/dev/null', cfg.remotePcapFile, tcpdumpCMD, cfg.dumpFilter)
elif (cfg.remotePcapFile.endswith('.bz2')):
Expand Down

0 comments on commit 894a2de

Please sign in to comment.