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 name="ChangeListManager">
<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$/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" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -43,7 +24,7 @@
<option name="PUSH_AUTO_UPDATE" value="true" />
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="devel" />
<entry key="$PROJECT_DIR$" value="main" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -59,27 +40,27 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"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"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;ASKED_MARK_IGNORED_FILES_AS_EXCLUDED&quot;: &quot;true&quot;,
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;Python.__init__.executor&quot;: &quot;Run&quot;,
&quot;Python.__main__.executor&quot;: &quot;Run&quot;,
&quot;Python.main.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/slnopriv/projects/2024-bsc-sebastian-lenzlinger/code/kydcap/utils/device_metadata_utils.py&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/archive" />

View File

@ -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()