From 75134b4929b614a7b7241f3228db73242a42cf8f Mon Sep 17 00:00:00 2001 From: edoardoColi Date: Thu, 11 May 2023 02:36:41 +0200 Subject: [PATCH] add comments --- .MAClistall.tmp | 34 ++++++++++++++++++++++++++++++++++ .MACrandom.tmp | 7 +++++++ MACshuffle.sh | 20 ++++++++++---------- 3 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 .MAClistall.tmp create mode 100644 .MACrandom.tmp diff --git a/.MAClistall.tmp b/.MAClistall.tmp new file mode 100644 index 0000000..ac65c5f --- /dev/null +++ b/.MAClistall.tmp @@ -0,0 +1,34 @@ +90:B8:32:37:1D:37 2 +90:B8:32:37:1D:37 2 +90:B8:32:37:1D:37 2 +90:B8:32:37:1D:34 2 +90:B8:32:37:1D:37 2 +90:B8:32:37:1D:37 2 +90:B8:32:37:1D:37 2 +90:B8:32:37:1D:37 2 +90:B8:32:37:1D:37 1 +3C:22:FB:28:F7:91 0 +90:B8:32:37:1D:37 1 +90:B8:32:37:1D:37 2 +3C:22:FB:28:F7:91 1 +25:18:04:B1:31:E7,25:18:04:B1:31:E7 0X0006 +C2:2B:FF:5D:B4:F3 1 +90:B8:32:37:1D:37 1 +90:B8:32:37:1D:37 1 +C2:2B:FF:5D:B4:F3 1 +3C:22:FB:28:F7:91 1 +3C:22:FB:28:F7:91 2 +90:B8:32:37:1D:37 1 +90:B8:32:36:E8:77 2 +F8:FF:C2:12:A7:E5 1 +A2:1F:10:7D:D0:62 1 +90:B8:32:36:E8:77 2 +90:B8:32:36:E8:77 2 +90:B8:32:36:E8:77 2 +C2:2B:FF:5D:B4:F3 1 +90:B8:32:37:1D:37 1 +90:B8:32:37:1D:37 1 +C2:2B:FF:5D:B4:F3 1 +90:B8:32:37:1D:37 1 +12:6E:38:87:38:7D 0 +C2:2B:FF:5D:B4:F3 1 diff --git a/.MACrandom.tmp b/.MACrandom.tmp new file mode 100644 index 0000000..5775bba --- /dev/null +++ b/.MACrandom.tmp @@ -0,0 +1,7 @@ +C2:2B:FF:5D:B4:F3 +C2:2B:FF:5D:B4:F3 +A2:1F:10:7D:D0:62 +C2:2B:FF:5D:B4:F3 +C2:2B:FF:5D:B4:F3 +12:6E:38:87:38:7D +C2:2B:FF:5D:B4:F3 diff --git a/MACshuffle.sh b/MACshuffle.sh index c277034..6868fd7 100755 --- a/MACshuffle.sh +++ b/MACshuffle.sh @@ -90,7 +90,7 @@ function handle_sigint() rm -f "$_FILE2_TMP" rm -f "$_FILE3_TMP" rm -f "$lock_print" - kill -9 $_PROCESS_ID #forcefully terminate the process, and any subprocesses or child processes, with the ID using the SIGKILL signal (sometimes it's not enough, why?) + kill -9 $_PROCESS_ID #forcefully terminate the process, and any subprocesses or child processes, with the ID using the SIGKILL signal. (sometimes it's not enough, why?) exit 0 } @@ -129,24 +129,24 @@ function filtering_away() filter="($scope) && (wlan) $filterSSID" #save the complete filter which wanna use to split the data. rm -f $_FILE_TMP $_FILE2_TMP #just as a precaution. _TMP=$(mktemp -d) #creates a unique temporary directory in /tmp/ folder. - mkfifo $_TMP/pipe1 $_TMP/pipe2 $_TMP/pipe3 $_TMP/pipe4 #creates named pipes inside a temporary directory created before + mkfifo $_TMP/pipe1 $_TMP/pipe2 $_TMP/pipe3 $_TMP/pipe4 #creates named pipes inside a temporary directory created before. verbose_msg "Counting packets in $_FILE_REF" verbose_msg "Counting packets with field 'wlan' in $_FILE_REF" if ! [[ $_SSID_REF == '' ]]; then verbose_msg "Counting packets with field 'wlan.ssid == $_SSID_REF' in $_FILE_REF" fi verbose_msg "Counting packets with filter '$filter' in $_FILE_REF" - (tshark -r $_FILE_REF -T fields -e frame.number -c $_MAX_TO | wc -l >$_TMP/pipe1) & - (tshark -r $_FILE_REF -Y "wlan" -T fields -e frame.number -c $_MAX_TO | wc -l >$_TMP/pipe2) & + (tshark -r $_FILE_REF -T fields -e frame.number -c $_MAX_TO | wc -l >$_TMP/pipe1) & #the symbol '&' runs the command in the background, allowing other commands to be run in parallel. + (tshark -r $_FILE_REF -Y "wlan" -T fields -e frame.number -c $_MAX_TO | wc -l >$_TMP/pipe2) & #the symbol '&' runs the command in the background, allowing other commands to be run in parallel. if ! [[ $_SSID_REF == '' ]]; then - (tshark -r $_FILE_REF -Y "wlan.ssid == $_SSID_REF" -T fields -e frame.number -c $_MAX_TO | wc -l >$_TMP/pipe3) & + (tshark -r $_FILE_REF -Y "wlan.ssid == $_SSID_REF" -T fields -e frame.number -c $_MAX_TO | wc -l >$_TMP/pipe3) & #the symbol '&' runs the command in the background, allowing other commands to be run in parallel. else (echo "(NaN)" >$_TMP/pipe3) & fi if [[ $_UNIQ_FLAG == 'true' ]]; then - (tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -c $_MAX_TO | tr '[:lower:]' '[:upper:]' | sort | uniq | tee >(wc -l > $_TMP/pipe4) >"$_FILE2_TMP") & + (tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -c $_MAX_TO | tr '[:lower:]' '[:upper:]' | sort | uniq | tee >(wc -l > $_TMP/pipe4) >"$_FILE2_TMP") & #the symbol '&' runs the command in the background, allowing other commands to be run in parallel. else - (tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -e wlan.fc.type -c $_MAX_TO | tr '[:lower:]' '[:upper:]' | tee >(wc -l > $_TMP/pipe4) >"$_FILE2_TMP") & + (tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -e wlan.fc.type -c $_MAX_TO | tr '[:lower:]' '[:upper:]' | tee >(wc -l > $_TMP/pipe4) >"$_FILE2_TMP") & #the symbol '&' runs the command in the background, allowing other commands to be run in parallel. fi while read line; do verbose_msg " '$line'" @@ -155,7 +155,7 @@ function filtering_away() _PCKS_SSID_CNTR=$(echo $line | cut -d ' ' -f 3) _SCOPE_ALL_CNTR=$(echo $line | cut -d ' ' -f 4) done < <(paste -d ' ' $_TMP/pipe1 $_TMP/pipe2 $_TMP/pipe3 $_TMP/pipe4) #the 'paste' command merges the lines of both named pipes and separates them with a space. the '< <' operator to redirect the merged output as input to the while loop. - rm -rf $_TMP #remove the temporary directory and all its contents recursively (-r) and without prompting (-f) + rm -rf $_TMP #remove the temporary directory and all its contents recursively (-r) and without prompting (-f). verbose_msg "=> $_PCKS_CNTR for no filter" verbose_msg "=> $_PCKS_WLAN_CNTR for filter 'wlan'" if ! [[ $_SSID_REF == '' ]]; then @@ -252,7 +252,7 @@ function print_results() fi # rm $_FILE_TMP if [ $(wc -l < $_FILE2_TMP) -gt $N ] && [[ $_UNIQ_FLAG == 'false' ]]; then - echo && echo -e "${LOOKGOOD}$_FILE2_TMP${DEFAULT}" && head -n $N "$_FILE2_TMP" && echo "..." && echo "[MAC Address] [Frame Control Type:]" && echo " [0-Management Frame, 1-Control Frame, 2-Data Frame, 3-Extension Frame, (4+)-PV1 Reserved]" + echo && echo -e "${LOOKGOOD}$_FILE2_TMP${DEFAULT}" && echo "[MAC Address] [Frame Control Type:]" && echo " [0-Management Frame, 1-Control Frame, 2-Data Frame, 3-Extension Frame, (4+)-PV1 Reserved]" && head -n $N "$_FILE2_TMP" && echo "..." elif [ $(wc -l < $_FILE2_TMP) -gt $N ]; then echo && echo -e "${LOOKGOOD}$_FILE2_TMP${DEFAULT}" && head -n $N "$_FILE2_TMP" && echo "..." elif [ $(wc -l < $_FILE2_TMP) -gt 0 ]; then @@ -294,7 +294,7 @@ if ! [ -t 0 ]; then #checks if the descriptor is opened with a redirection, reg trap handle_sigint SIGINT #set up a trap for SIGINT lock_print=$(mktemp) #creates a unique temporary file in /tmp/ folder. _FILE_REF="$_FILE3_TMP" - sleep 2 #waiting to have something to analyze + sleep 2 #waiting to have something to analyze. echo -ne "\033[2J\033[H" #the "\033[2J" sequence clear the terminal screen, the "\033[H" sequence moves the cursor to the top left corner of the screen. while true do