Cleaning up the software folder.
[pingpong.git] / Code / Projects / PacketLevelSignatureExtractor / execute_ip_detection.sh
1 #!/bin/bash
2
3 # TODO: This script was used to look for certain IP addresses in the YourThings public dataset.
4 # TODO: https://yourthings.info/
5
6 # Arg1 should point to the folder with YourThings traces (PCAP files w/o any expected events).
7 # There are 3 overlap devices:
8 # 1) Belkin WeMo switch: https://yourthings.info/devices/belkin_switch.html
9 # 2) Roomba iRobot 690: https://yourthings.info/devices/roomba.html
10 # 3) TP-Link Bulb LB130: https://yourthings.info/devices/tplink_bulb.html
11 YT_TRACES_DIR=$1
12
13 # Arg2 should contain the IP address that we are looking for in a certain PCAP file
14 IP_ADDRESS=$2
15
16 # Arg3 should point to output file that has the list of PCAP files that contain a certain IP address.
17 # Subfolders will be created for each individual pcap file in YT_TRACES_DIR.
18 OUTPUT_FILE=$3
19
20 # Download and untar the public data set https://yourthings.info/data/
21 # Then everything should be untarred/unzipped into /.../2018/
22 # YT_TRACES_DIR path should be something like /.../2018/
23 # Then there are subfolders inside 2018/ such as 2018/03/20/
24 for SUBFOLDER1 in $YT_TRACES_DIR/*; do
25         for SUBFOLDER2 in $SUBFOLDER1/*; do
26                 for PCAP_FILE in $SUBFOLDER2/*; do
27                         # skip non pcap files
28                         [ -e "$PCAP_FILE" ] || continue
29                         RESULT=`tshark -r $PCAP_FILE | grep $IP_ADDRESS`
30                         echo $PCAP_FILE
31                         # make an output sub dir in the base output dir that is the filename minus extension
32                         if [ -n "$RESULT" ]; then
33                 #OUTPUT_SUB_DIR=$(basename "$PCAP_FILE" .pcap)
34                 echo "$IP_ADDRESS is found in this PCAP file!"
35                 echo $PCAP_FILE >> $OUTPUT_FILE
36             fi
37                 done
38         done
39 done