% !TEX root = ../Thesis.tex \chapter{Appendix A} \section{Command Line Examples}\label{example:pre-post} \subsection{Pre and post scripts} In this example, the \verb|--unsafe| option allows not to specify a IP or MAC address. \verb|default| is the device name used and \verb|-c 10| tells \iottb that we only want to capture 10 packets. \begin{minted}{bash} # Command: $ iottb sniff --pre='/usr/bin/echo "pre"' --post='/usr/bin/echo "post"' \ default --unsafe -c 10 # Stdout: Testbed [Info] Running pre command /usr/bin/echo "pre" pre Using canonical device name default Found device at path /home/seb/iottb.db/default Using filter None Files will be placed in /home/seb/iottb.db/default/sniffs/2024-06-30/cap0002-2101 Capture has id dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe Capture setup complete! Capture complete. Saved to default_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.pcap tcpdump took 2.12 seconds. Ensuring correct ownership of created files. Saving metadata. END SNIFF SUBCOMMAND Running post script /usr/bin/echo "post" post \end{minted} The contents of the 'sniff' directory for the default device after this capture has completed: \begin{minted}{bash} sniffs/2024-06-30/cap0002-2101 $ tree . |-- capture_metadata.json |-- default_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.pcap |-- stderr_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.log L__ stdout_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.log \end{minted} and the metadata file contains (\verb|\| only used for fitting into this document):\\ \verb|# capture_metadata.json|\\ \begin{minted}{json} { "device": "default", "device_id": "default", "capture_id": "dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe", "capture_date_iso": "2024-06-30T21:01:31.496870", "invoked_command": "sudo tcpdump -# -n -c 10 -w \ /home/seb/iottb.db \ /default/sniffs/2024-06-30 \ /cap0002-2101/default_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.pcap", "capture_duration": 2.117154359817505, "generic_parameters": { "flags": "-# -n", "kwargs": "-c 10", "filter": null }, "non_generic_parameters": { "kwargs": "-w \ /home/seb/iottb.db/default/sniffs/2024-06-30 \ /cap0002-2101 \ /default_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.pcap", "filter": null }, "features": { "interface": null, "address": null }, "resources": { "pcap_file": "default_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.pcap", "stdout_log": "stdout_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.log", "stderr_log": "stderr_dcdf1e0b-6c4d-4f01-ba16-f42a04131fbe.log", "pre": "/usr/bin/echo \"pre\"", "post": "/usr/bin/echo \"post\"" }, "environment": { "capture_dir": "cap0002-2101", "database": "iottb.db", "capture_base_dir": "/home/seb/iottb.db/default/sniffs/2024-06-30", "capture_dir_abs_path": \ "/home/seb/iottb.db/default/sniffs/2024-06-30/cap0002-2101" } } \end{minted} \section{Canonical Name} \begin{listing}[!ht] \inputminted[firstline=12, lastline=40]{python}{string_processing.py} \caption{Shows how the canonical name is created.} \label{lst:dev-canonical} \end{listing} \section{Add Device Example} \subsection{Configuration File}\label{appendixA:add-dev-cfg} \begin{listing}[!ht] \inputminted[linenos, breaklines]{python}{appendixa-after-add-device-dir.txt} \caption{Directory and file contents after adding two devices.} \label{lst:appendix:appendixa:config-file} \end{listing} \section{Debug Flag Standard Output} \begin{figure} \centering \begin{minted}{bash} ❯ iottb -vvv --debug sniff roomba --unsafe -c 10 <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> INFO - main - cli - 48 - Starting execution. INFO - iottb_config - __init__ - 24 - Initializing Config object WARNING - iottb_config - warn - 21 - DatabaseLocations are DatabaseLocationMap in the class iottb.models.iottb_config INFO - iottb_config - load_config - 57 - Loading configuration file INFO - iottb_config - load_config - 62 - Config file exists, opening. DEBUG - main - cli - 52 - Verbosity: 3 DEBUG - main - cli - 54 - Debug: True INFO - sniff - validate_sniff - 37 - Validating sniff... INFO - sniff - sniff - 91 - sniff command invoked DEBUG - sniff - sniff - 98 - Config loaded: DEBUG - sniff - sniff - 104 - Full db path is /home/seb/showcase INFO - string_processing - make_canonical_name - 20 - Normalizing name roomba DEBUG - string_processing - make_canonical_name - 38 - Canonical name: roomba DEBUG - string_processing - make_canonical_name - 39 - Aliases: ['roomba'] Testbed [I] Using canonical device name roomba Found device at path /home/seb/showcase/roomba INFO - sniff - sniff - 152 - Generic filter None Using filter None DEBUG - sniff - sniff - 160 - Previous captures DEBUG - sniff - sniff - 162 - Capture count is 4 DEBUG - sniff - sniff - 165 - capture_dir: cap0004-0310 Files will be placed in /home/seb/showcase/roomba/sniffs/2024-07-01/cap0004-0310 DEBUG - sniff - sniff - 172 - successfully created capture directory Capture has id 59153b53-c49d-44de-99d2-b5a3490df29a DEBUG - sniff - sniff - 185 - Full pcap file path is /home/seb/showcase/roomba/sniffs/2024-07-01/cap0004-0310/roomba_59153b53-c49d-44de-99d2-b5a3490df29a.pcap INFO - sniff - sniff - 186 - pcap file name is roomba_59153b53-c49d-44de-99d2-b5a3490df29a.pcap INFO - sniff - sniff - 187 - stdout log file is stdout_59153b53-c49d-44de-99d2-b5a3490df29a.log INFO - sniff - sniff - 188 - stderr log file is stderr_59153b53-c49d-44de-99d2-b5a3490df29a.log DEBUG - sniff - sniff - 191 - pgid 260696 DEBUG - sniff - sniff - 192 - ppid 12862 DEBUG - sniff - sniff - 193 - (real, effective, saved) user id: (1000, 1000, 1000) DEBUG - sniff - sniff - 194 - (real, effective, saved) group id: (1000, 1000, 1000) DEBUG - sniff - sniff - 209 - Flags: -# -n DEBUG - sniff - sniff - 217 - verbosity string to pass to tcpdump: -vvv DEBUG - sniff - sniff - 228 - KW args: -c 10 DEBUG - sniff - sniff - 237 - Non transferable (special) kw args: -w /home/seb/showcase/roomba/sniffs/2024-07-01/cap0004-0310/roomba_59153b53-c49d-44de-99d2-b5a3490df29a.pcap INFO - sniff - sniff - 246 - tcpdump command: sudo tcpdump -# -n -vvv -c 10 -w /home/seb/showcase/roomba/sniffs/2024-07-01/cap0004-0310/roomba_59153b53-c49d-44de-99d2-b5a3490df29a.pcap Capture setup complete! DEBUG - sniff - sniff - 259 - stdout: <_io.TextIOWrapper name='/home/seb/showcase/roomba/sniffs/2024-07-01/cap0004-0310/stdout_59153b53-c49d-44de-99d2-b5a3490df29a.log' mode='w' encoding='UTF-8'>. stderr: <_io.TextIOWrapper name='/home/seb/showcase/roomba/sniffs/2024-07-01/cap0004-0310/stderr_59153b53-c49d-44de-99d2-b5a3490df29a.log' mode='w' encoding='UTF-8'>. Capture complete. Saved to roomba_59153b53-c49d-44de-99d2-b5a3490df29a.pcap tcpdump took 1.11 seconds. Ensuring correct ownership of created files. Saving metadata. END SNIFF SUBCOMMAND \end{minted} \caption{Output with max verbosity and debug flag set.} \label{fig:example-debug-output} \end{figure}