From 27de5b4587678362cc12ec4203b862e92ecda4a0 Mon Sep 17 00:00:00 2001 From: Sebastian Lenzlinger Date: Sat, 4 May 2024 13:51:55 +0200 Subject: [PATCH] SYNC --- .idea/workspace.xml | 61 +++++++++++--------------------- code/kydcap/subcommands/sniff.py | 17 ++++++--- 2 files changed, 34 insertions(+), 44 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1b59c65..67d858b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,26 +5,7 @@ - - - - - - - - - - - - - - - - - - - - { + "keyToString": { + "ASKED_ADD_EXTERNAL_FILES": "true", + "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true", + "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", + "Python.__init__.executor": "Run", + "Python.__main__.executor": "Run", + "Python.main.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "SHARE_PROJECT_CONFIGURATION_FILES": "true", + "git-widget-placeholder": "main", + "last_opened_file_path": "/home/slnopriv/projects/2024-bsc-sebastian-lenzlinger/code/kydcap/utils/device_metadata_utils.py", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable", + "vue.rearranger.settings.migration": "true" } -}]]> +} diff --git a/code/kydcap/subcommands/sniff.py b/code/kydcap/subcommands/sniff.py index a84600e..523cd64 100644 --- a/code/kydcap/subcommands/sniff.py +++ b/code/kydcap/subcommands/sniff.py @@ -65,10 +65,14 @@ def handle_capture_metadata(): return device_id +def handle_date_dir(): + pass + +def run_tcpdum(cmd): + subprocess.run(cmd) def handle_sniff(args): - if not cwd_is_device_root_dir(): - handle_metadata() - else: + if cwd_is_device_root_dir(): + handle_date_dir() cmd = ['sudo tcpdump', '-i', args.capture_interface] if args.monitor_mode: cmd.append('-I') @@ -87,7 +91,7 @@ def handle_sniff(args): # TODO maybe dump this into file -> put into device metadata try: start_time = datetime.now().strftime('%H:%M:%S') - subprocess.run(cmd) + run_tcpdum(cmd) stop_time = datetime.now().strftime('%H:%M:%S') except KeyboardInterrupt: print("Received keyboard interrupt.") @@ -100,3 +104,8 @@ def handle_sniff(args): exit(ReturnCodes.FAILURE) return ReturnCodes.SUCCESS + else: + handle_metadata() + + +