This commit is contained in:
Sebastian Lenzlinger 2024-05-04 13:51:55 +02:00
parent 5cc7e2bae0
commit 27de5b4587
2 changed files with 34 additions and 44 deletions

61
.idea/workspace.xml generated
View File

@ -5,26 +5,7 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7a3ac8e1-7fbf-4aa7-9cf9-a51d7ade8503" name="Changes" comment="Start tracking development config files."> <list default="true" id="7a3ac8e1-7fbf-4aa7-9cf9-a51d7ade8503" name="Changes" comment="Start tracking development config files.">
<change afterPath="$PROJECT_DIR$/.idea/webResources.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/kydcap/subcommands/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/fixtures/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/fixtures/shared_fixtures.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/models/test_capture_metadata_model.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/models/test_device_metadata_model.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/subcommands/test_initialize_device_root_dir.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/subcommands/test_sniff.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/test_main.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/utils/test_capture_metadata_utils.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/utils/test_device_metadata_utils.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/code/tests/utils/test_tcpdump_utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/archive/metadata_utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/archive/metadata_utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/kydcap/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/code/kydcap/config.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/kydcap/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/code/kydcap/__main__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/kydcap/models/capture_metadata.py" beforeDir="false" afterPath="$PROJECT_DIR$/code/kydcap/models/capture_metadata_model.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/kydcap/models/device_metadata.py" beforeDir="false" afterPath="$PROJECT_DIR$/code/kydcap/models/device_metadata_model.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/kydcap/subcommands/initialize_device_root_dir.py" beforeDir="false" afterPath="$PROJECT_DIR$/code/kydcap/subcommands/initialize_device_root_dir.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/kydcap/subcommands/sniff.py" beforeDir="false" afterPath="$PROJECT_DIR$/code/kydcap/subcommands/sniff.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/code/kydcap/subcommands/sniff.py" beforeDir="false" afterPath="$PROJECT_DIR$/code/kydcap/subcommands/sniff.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -43,7 +24,7 @@
<option name="PUSH_AUTO_UPDATE" value="true" /> <option name="PUSH_AUTO_UPDATE" value="true" />
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="devel" /> <entry key="$PROJECT_DIR$" value="main" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -59,27 +40,27 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"ASKED_ADD_EXTERNAL_FILES": "true", &quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
"ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true", &quot;ASKED_MARK_IGNORED_FILES_AS_EXCLUDED&quot;: &quot;true&quot;,
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", &quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
"Python.__init__.executor": "Run", &quot;Python.__init__.executor&quot;: &quot;Run&quot;,
"Python.__main__.executor": "Run", &quot;Python.__main__.executor&quot;: &quot;Run&quot;,
"Python.main.executor": "Run", &quot;Python.main.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"SHARE_PROJECT_CONFIGURATION_FILES": "true", &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"last_opened_file_path": "/home/slnopriv/projects/2024-bsc-sebastian-lenzlinger/code/kydcap/utils/device_metadata_utils.py", &quot;last_opened_file_path&quot;: &quot;/home/slnopriv/projects/2024-bsc-sebastian-lenzlinger/code/kydcap/utils/device_metadata_utils.py&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable", &quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/archive" /> <recent name="$PROJECT_DIR$/archive" />

View File

@ -65,10 +65,14 @@ def handle_capture_metadata():
return device_id return device_id
def handle_date_dir():
pass
def run_tcpdum(cmd):
subprocess.run(cmd)
def handle_sniff(args): def handle_sniff(args):
if not cwd_is_device_root_dir(): if cwd_is_device_root_dir():
handle_metadata() handle_date_dir()
else:
cmd = ['sudo tcpdump', '-i', args.capture_interface] cmd = ['sudo tcpdump', '-i', args.capture_interface]
if args.monitor_mode: if args.monitor_mode:
cmd.append('-I') cmd.append('-I')
@ -87,7 +91,7 @@ def handle_sniff(args):
# TODO maybe dump this into file -> put into device metadata # TODO maybe dump this into file -> put into device metadata
try: try:
start_time = datetime.now().strftime('%H:%M:%S') start_time = datetime.now().strftime('%H:%M:%S')
subprocess.run(cmd) run_tcpdum(cmd)
stop_time = datetime.now().strftime('%H:%M:%S') stop_time = datetime.now().strftime('%H:%M:%S')
except KeyboardInterrupt: except KeyboardInterrupt:
print("Received keyboard interrupt.") print("Received keyboard interrupt.")
@ -100,3 +104,8 @@ def handle_sniff(args):
exit(ReturnCodes.FAILURE) exit(ReturnCodes.FAILURE)
return ReturnCodes.SUCCESS return ReturnCodes.SUCCESS
else:
handle_metadata()