From 27de5b4587678362cc12ec4203b862e92ecda4a0 Mon Sep 17 00:00:00 2001 From: Sebastian Lenzlinger Date: Sat, 4 May 2024 13:51:55 +0200 Subject: [PATCH 1/6] 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() + + + From 7e3e1019872c7dd1657314895bc64c8fa4248681 Mon Sep 17 00:00:00 2001 From: Sebastian Lenzlinger Date: Sun, 5 May 2024 16:24:58 +0200 Subject: [PATCH 2/6] Refactor various names. --- .idea/2024-bsc-sebastian-lenzlinger.iml | 3 ++ .idea/workspace.xml | 40 ++++++++++++++++--- archive/metadata_utils.py | 4 +- code/{kydcap => iottb}/__init__.py | 0 code/{kydcap => iottb}/__main__.py | 10 ++--- code/iottb/cli.py | 2 + .../config.py => iottb/definitions.py} | 2 +- code/{kydcap => iottb}/models/__init__.py | 0 .../models/capture_metadata_model.py | 3 +- .../models/device_metadata_model.py | 4 +- .../{kydcap => iottb}/subcommands/__init__.py | 0 .../sniff.py => iottb/subcommands/capture.py} | 22 ++++++---- .../subcommands/config.py} | 0 .../subcommands/init.py} | 10 ++--- code/iottb/utils/__init__.py | 0 .../utils/capture_metadata_utils.py | 2 +- .../utils/device_metadata_utils.py | 2 +- code/{kydcap => iottb}/utils/tcpdump_utils.py | 0 .../utils/test_capture_metadata_utils.py | 2 +- 19 files changed, 73 insertions(+), 33 deletions(-) rename code/{kydcap => iottb}/__init__.py (100%) rename code/{kydcap => iottb}/__main__.py (72%) create mode 100644 code/iottb/cli.py rename code/{kydcap/config.py => iottb/definitions.py} (78%) rename code/{kydcap => iottb}/models/__init__.py (100%) rename code/{kydcap => iottb}/models/capture_metadata_model.py (95%) rename code/{kydcap => iottb}/models/device_metadata_model.py (97%) rename code/{kydcap => iottb}/subcommands/__init__.py (100%) rename code/{kydcap/subcommands/sniff.py => iottb/subcommands/capture.py} (88%) rename code/{kydcap/utils/__init__.py => iottb/subcommands/config.py} (100%) rename code/{kydcap/subcommands/initialize_device_root_dir.py => iottb/subcommands/init.py} (83%) create mode 100644 code/iottb/utils/__init__.py rename code/{kydcap => iottb}/utils/capture_metadata_utils.py (97%) rename code/{kydcap => iottb}/utils/device_metadata_utils.py (97%) rename code/{kydcap => iottb}/utils/tcpdump_utils.py (100%) diff --git a/.idea/2024-bsc-sebastian-lenzlinger.iml b/.idea/2024-bsc-sebastian-lenzlinger.iml index ec63674..aad402c 100644 --- a/.idea/2024-bsc-sebastian-lenzlinger.iml +++ b/.idea/2024-bsc-sebastian-lenzlinger.iml @@ -4,4 +4,7 @@ + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 67d858b..141240e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,9 +4,26 @@