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 1b59c65..4e4bd90 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,28 +4,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
@@ -59,27 +44,27 @@
- {
+ "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"
}
-}]]>
+}
@@ -165,7 +150,8 @@
-
+
+
@@ -215,7 +201,15 @@
1714617266799
-
+
+
+ 1714622469786
+
+
+
+ 1714622469786
+
+
@@ -271,7 +265,8 @@
-
+
+
diff --git a/code/kydcap/scripts/wifi_ctl.sh b/code/kydcap/scripts/wifi_ctl.sh
new file mode 100644
index 0000000..076d2fd
--- /dev/null
+++ b/code/kydcap/scripts/wifi_ctl.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# Note, this is not my original work. Source: https://linuxtldr.com/changing-interface-mode/
+
+function list_nic_info () {
+ ip addr show
+}
+
+function enable_monm_iw () {
+ interface=$1
+ sudo ip link set "$interface" down
+ sudo iw "$interface" set monitor control
+ sudo ip link set "$interface" up
+}
+
+function disable_monm_iw () {
+ interface=$1
+ sudo ip link set "$interface" down
+ sudo iw "$interface" set type managed
+ sudo ip link set "$interface" up
+}
+
+function enable_monm_iwconfig () {
+ interface=$1
+ sudo ifconfig "$interface" down
+ sudo iwconfig "$interface" mode monitor
+ sudo ifconfig "$interface" up
+}
+
+function disable_monm_iwconfig () {
+ interface=$1
+ sudo ifconfig "$interface" down
+ sudo iwconfig "$interface" mode managed
+ sudo ifconfig "$interface" up
+}
+
+function enable_monm_acng () {
+ interface=$1
+ sudo airmon-ng check
+ sudo airmon-ng check kill
+ sudo airmon-ng start "$interface"
+}
+
+function disable_monm_acng () {
+ interface="${1}mon"
+ sudo airmon-ng stop "$interface"
+ sudo systemctl restart NetworkManager
+}
+
+if declare -f "$1" > /dev/null
+then
+ "$@"
+else
+ echo "Unknown function '$1'" >&2
+ exit 1
+fi
\ No newline at end of file
diff --git a/code/kydcap/subcommands/sniff.py b/code/kydcap/subcommands/sniff.py
index a84600e..87df0a5 100644
--- a/code/kydcap/subcommands/sniff.py
+++ b/code/kydcap/subcommands/sniff.py
@@ -69,7 +69,7 @@ def handle_sniff(args):
if not cwd_is_device_root_dir():
handle_metadata()
else:
- cmd = ['sudo tcpdump', '-i', args.capture_interface]
+ cmd = ['sudo', 'tcpdump', '-i', args.capture_interface]
if args.monitor_mode:
cmd.append('-I')
if args.no_name_resolution:
@@ -83,8 +83,10 @@ def handle_sniff(args):
cmd.append(str(args.count))
elif args.mins:
pass
- print('Executing: ' + ' '.join(cmd))
+ print('Complete command:' + ' '.join(cmd))
# TODO maybe dump this into file -> put into device metadata
+ # TODO generate pcap filename
+ # TODO construct capture metadata file
try:
start_time = datetime.now().strftime('%H:%M:%S')
subprocess.run(cmd)
diff --git a/code/kydcap/utils/tcpdump_utils.py b/code/kydcap/utils/utils.py
similarity index 81%
rename from code/kydcap/utils/tcpdump_utils.py
rename to code/kydcap/utils/utils.py
index 08bfb7e..a6d0ff2 100644
--- a/code/kydcap/utils/tcpdump_utils.py
+++ b/code/kydcap/utils/utils.py
@@ -1,15 +1,16 @@
import shutil
import subprocess
+DEPENDENCIES =
-def check_installed() -> bool:
+def check_installed(tool) -> bool:
"""Check if tcpdump is installed and available on the system path."""
- return shutil.which('tcpdump') is not None
+ return shutil.which(f'{tool}') is not None
-def ensure_installed():
+def ensure_installed(tool):
"""Ensure that tcpdump is installed, raise an error if not."""
- if not check_installed():
+ if not check_installed(tool):
raise RuntimeError("tcpdump is not installed. Please install it to continue.")
diff --git a/code/kydcap/utils/wifi_ctrl_utils.py b/code/kydcap/utils/wifi_ctrl_utils.py
new file mode 100644
index 0000000..671d038
--- /dev/null
+++ b/code/kydcap/utils/wifi_ctrl_utils.py
@@ -0,0 +1,10 @@
+import subprocess
+
+def enable_monitor_mode(interface):
+ pass
+
+def disable_monitor_mode(interface):
+ pass
+
+def get_ap_channel(interface):
+ pass
\ No newline at end of file