From 9a7fc72d31cb71997c50f23d3f6858206249cd7d Mon Sep 17 00:00:00 2001 From: rtrimana Date: Tue, 12 Mar 2019 10:18:30 -0700 Subject: [PATCH] Disabling range-based detection for WiFi sniffing; adding scripts for layer 3 negative control experiments. --- .../execute_layer3_unb_all_detection.sh | 253 ++++++++++++++++ .../execute_layer3_unsw_all_detection.sh | 281 ++++++++++++++++++ .../layer2/Layer2SignatureDetector.java | 43 +-- .../layer3/Layer3SignatureDetector.java | 17 +- 4 files changed, 570 insertions(+), 24 deletions(-) create mode 100755 Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unb_all_detection.sh create mode 100755 Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unsw_all_detection.sh diff --git a/Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unb_all_detection.sh b/Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unb_all_detection.sh new file mode 100755 index 0000000..3bd5229 --- /dev/null +++ b/Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unb_all_detection.sh @@ -0,0 +1,253 @@ +#!/bin/bash + +#set -x # echo invoked commands to std out + +# Base dir should point to the experimental_result folder which contains the subfolders: +# - 'smarthome' which contains the traces collected while other devices are idle +# - 'standalone' which contains signatures and the traces used to generate the signatures. +BASE_DIR=$1 +readonly BASE_DIR + +OUTPUT_DIR=$2 +readonly OUTPUT_DIR + +PCAP_FILE_UNB=$3 +readonly PCAP_FILE_UNB + +PCAPS_BASE_DIR="$BASE_DIR/smarthome" +readonly PCAPS_BASE_DIR + +SIGNATURES_BASE_DIR="$BASE_DIR/standalone" +readonly SIGNATURES_BASE_DIR + +# ==================================================== ARLO CAMERA ===================================================== +# Has no device side signature. +PCAP_FILE=${PCAP_FILE_UNB} +echo "$PCAP_FILE" + +# PHONE SIDE (TODO: may possibly be the .incomplete signatures) +ON_ANALYSIS="$SIGNATURES_BASE_DIR/arlo-camera/analysis/arlo-camera-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/arlo-camera/analysis/arlo-camera-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/arlo-camera/signatures/arlo-camera-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/arlo-camera/signatures/arlo-camera-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/arlo-camera/arlo-camera.eth0.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="213" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ================================================= BLOSSOM SPRINKLER ================================================== +# DEVICE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-onClusters-device-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-offClusters-device-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig" +RESULTS_FILE="$OUTPUT_DIR/blossom-sprinkler/blossom-sprinkler.eth0.detection.pcap___device-side$i.detectionresults" +SIGNATURE_DURATION="9274" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/blossom-sprinkler/blossom-sprinkler.eth0.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="3670" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ==================================================== D-LINK PLUG ===================================================== +# DEVICE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-onClusters-device-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-offClusters-device-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-onSignature-device-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-offSignature-device-side.sig" +RESULTS_FILE="$OUTPUT_DIR/dlink-plug/dlink-plug.eth0.detection.pcap___device-side$i.detectionresults" +SIGNATURE_DURATION="8866" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/dlink-plug/dlink-plug.eth0.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="193" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ==================================================== D-LINK SIREN ==================================================== +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-siren/analysis/dlink-siren-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-siren/analysis/dlink-siren-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-siren/signatures/dlink-siren-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-siren/signatures/dlink-siren-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/dlink-siren/dlink-siren.eth0.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="71" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ===================================================== HUE BULB ======================================================= +# Has no device side signature. + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/hue-bulb/analysis/hue-bulb-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/hue-bulb/analysis/hue-bulb-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/hue-bulb/signatures/hue-bulb-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/hue-bulb/signatures/hue-bulb-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/hue-bulb/hue-bulb.eth0.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="27" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ================================================= KWIKSET DOORLOCK =================================================== +# Has no device side signature. + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/kwikset-doorlock/analysis/kwikset-doorlock-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/kwikset-doorlock/analysis/kwikset-doorlock-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/kwikset-doorlock/signatures/kwikset-doorlock-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/kwikset-doorlock/signatures/kwikset-doorlock-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/kwikset-doorlock/kwikset-doorlock.eth0.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="3161" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ================================================= NEST THERMOSTAT ==================================================== +# Has no device side signature. + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/nest-thermostat/analysis/nest-thermostat-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/nest-thermostat/analysis/nest-thermostat-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/nest-thermostat/signatures/nest-thermostat-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/nest-thermostat/signatures/nest-thermostat-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/nest-thermostat/nest-thermostat.eth0.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="1179" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ====================================================== ST PLUG ======================================================= +# Has no device side signature. + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/st-plug/analysis/st-plug-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/st-plug/analysis/st-plug-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/st-plug/signatures/st-plug-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/st-plug/signatures/st-plug-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/st-plug/st-plug.wlan1.detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="2445" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ==================================================== TP-LINK BULB ==================================================== +# Has no device side signature. + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-bulb/analysis/tplink-bulb-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-bulb/analysis/tplink-bulb-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-bulb/signatures/tplink-bulb-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-bulb/signatures/tplink-bulb-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/tplink-bulb/tplink-bulb.wlan1.wan-detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="162" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ==================================================== TP-LINK PLUG ==================================================== +# DEVICE SIDE (both the 112, 115 and 556, 1293 sequences) +ON_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-onClusters.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-offClusters.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-onSignature-device-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-offSignature-device-side.sig" +RESULTS_FILE="$OUTPUT_DIR/tplink-plug/tplink-plug.wlan1.wan-detection.pcap___device-side$i.detectionresults" +SIGNATURE_DURATION="3660" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + +# DEVICE SIDE OUTBOUND (contains only those packets that go through the WAN port, i.e., only the 556, 1293 sequence) +ON_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-onClusters.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-offClusters.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-onSignature-device-side-outbound.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-offSignature-device-side-outbound.sig" +RESULTS_FILE="$OUTPUT_DIR/tplink-plug/tplink-plug.wlan1.wan-detection.pcap___device-side-outbound$i.detectionresults" +SIGNATURE_DURATION="224" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + +# Phone side does not make sense as it is merely a subset of the device side and does not differentiate ONs from OFFs. +# ====================================================================================================================== + + + +# ================================================== WEMO INSIGHT PLUG ================================================= +# Has no device side signature. + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-insight-plug/analysis/wemo-insight-plug-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-insight-plug/analysis/wemo-insight-plug-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-insight-plug/signatures/wemo-insight-plug-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-insight-plug/signatures/wemo-insight-plug-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/wemo-insight-plug/wemo-insight-plug.wlan1.wan-detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="106" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + + + +# ===================================================== WEMO PLUG ====================================================== +# Has no device side signature. + +# PHONE SIDE +ON_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-plug/analysis/wemo-plug-onClusters-phone-side.cls" +OFF_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-plug/analysis/wemo-plug-offClusters-phone-side.cls" +ON_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-plug/signatures/wemo-plug-onSignature-phone-side.sig" +OFF_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-plug/signatures/wemo-plug-offSignature-phone-side.sig" +RESULTS_FILE="$OUTPUT_DIR/wemo-plug/wemo-plug.wlan1.wan-detection.pcap___phone-side$i.detectionresults" +SIGNATURE_DURATION="147" + +PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" +#./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" +# ====================================================================================================================== + diff --git a/Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unsw_all_detection.sh b/Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unsw_all_detection.sh new file mode 100755 index 0000000..e4b1301 --- /dev/null +++ b/Code/Projects/PacketLevelSignatureExtractor/execute_layer3_unsw_all_detection.sh @@ -0,0 +1,281 @@ +#!/bin/bash + +#set -x # echo invoked commands to std out + +# Base dir should point to the experimental_result folder which contains the subfolders: +# - 'smarthome' which contains the traces collected while other devices are idle +# - 'standalone' which contains signatures and the traces used to generate the signatures. +BASE_DIR=$1 +readonly BASE_DIR + +OUTPUT_DIR=$2 +readonly OUTPUT_DIR + +BASE_DIR_UNSW=$3 +readonly BASE_DIR_UNSW + +PCAPS_BASE_DIR="$BASE_DIR/smarthome" +readonly PCAPS_BASE_DIR + +SIGNATURES_BASE_DIR="$BASE_DIR/standalone" +readonly SIGNATURES_BASE_DIR + +# Files that are too big or could generate errors but results are valid +PCAP_FILE_ARR[0]="$BASE_DIR_UNSW/UNSW/16-09-28.pcap" +PCAP_FILE_ARR[1]="$BASE_DIR_UNSW/UNSW/16-10-02.pcap" +PCAP_FILE_ARR[2]="$BASE_DIR_UNSW/UNSW/16-10-03.pcap" +PCAP_FILE_ARR[3]="$BASE_DIR_UNSW/UNSW/16-10-04-a.pcap" +PCAP_FILE_ARR[4]="$BASE_DIR_UNSW/UNSW/16-10-04-b.pcap" +PCAP_FILE_ARR[5]="$BASE_DIR_UNSW/UNSW/16-10-07.pcap" +PCAP_FILE_ARR[6]="$BASE_DIR_UNSW/UNSW/16-10-08.pcap" +PCAP_FILE_ARR[7]="$BASE_DIR_UNSW/UNSW/16-10-09.pcap" +PCAP_FILE_ARR[8]="$BASE_DIR_UNSW/UNSW/16-10-10.pcap" +PCAP_FILE_ARR[9]="$BASE_DIR_UNSW/UNSW/16-10-11.pcap" +PCAP_FILE_ARR[10]="$BASE_DIR_UNSW/UNSW/16-10-12-a.pcap" +PCAP_FILE_ARR[11]="$BASE_DIR_UNSW/UNSW/16-10-12-b.pcap" +PCAP_FILE_ARR[12]="$BASE_DIR_UNSW/UNSW/16-10-12-c.pcap" +PCAP_FILE_ARR[13]="$BASE_DIR_UNSW/UNSW/16-10-12-d.pcap" +# Normal files with valid results +PCAP_FILE_ARR[14]="$BASE_DIR_UNSW/UNSW/16-09-23.pcap" +PCAP_FILE_ARR[15]="$BASE_DIR_UNSW/UNSW/16-09-24.pcap" +PCAP_FILE_ARR[16]="$BASE_DIR_UNSW/UNSW/16-09-25.pcap" +PCAP_FILE_ARR[17]="$BASE_DIR_UNSW/UNSW/16-09-26.pcap" +PCAP_FILE_ARR[18]="$BASE_DIR_UNSW/UNSW/16-09-27.pcap" +PCAP_FILE_ARR[19]="$BASE_DIR_UNSW/UNSW/16-09-29.pcap" +PCAP_FILE_ARR[20]="$BASE_DIR_UNSW/UNSW/16-10-01.pcap" +PCAP_FILE_ARR[21]="$BASE_DIR_UNSW/UNSW/16-10-06.pcap" + +for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 +do + # ==================================================== ARLO CAMERA ===================================================== + # Has no device side signature. + PCAP_FILE=${PCAP_FILE_ARR[$i]} + + echo "$PCAP_FILE" + + # PHONE SIDE (TODO: may possibly be the .incomplete signatures) + ON_ANALYSIS="$SIGNATURES_BASE_DIR/arlo-camera/analysis/arlo-camera-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/arlo-camera/analysis/arlo-camera-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/arlo-camera/signatures/arlo-camera-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/arlo-camera/signatures/arlo-camera-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/arlo-camera/arlo-camera.eth0.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="213" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + ./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ================================================= BLOSSOM SPRINKLER ================================================== + # DEVICE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-onClusters-device-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-offClusters-device-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-device-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-device-side.sig" + RESULTS_FILE="$OUTPUT_DIR/blossom-sprinkler/blossom-sprinkler.eth0.detection.pcap___device-side$i.detectionresults" + SIGNATURE_DURATION="9274" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + ./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/blossom-sprinkler/analysis/blossom-sprinkler-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/blossom-sprinkler/signatures/blossom-sprinkler-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/blossom-sprinkler/blossom-sprinkler.eth0.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="3670" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + ./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ==================================================== D-LINK PLUG ===================================================== + # DEVICE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-onClusters-device-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-offClusters-device-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-onSignature-device-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-offSignature-device-side.sig" + RESULTS_FILE="$OUTPUT_DIR/dlink-plug/dlink-plug.eth0.detection.pcap___device-side$i.detectionresults" + SIGNATURE_DURATION="8866" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-plug/analysis/dlink-plug-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-plug/signatures/dlink-plug-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/dlink-plug/dlink-plug.eth0.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="193" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ==================================================== D-LINK SIREN ==================================================== + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-siren/analysis/dlink-siren-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/dlink-siren/analysis/dlink-siren-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-siren/signatures/dlink-siren-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/dlink-siren/signatures/dlink-siren-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/dlink-siren/dlink-siren.eth0.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="71" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ===================================================== HUE BULB ======================================================= + # Has no device side signature. + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/hue-bulb/analysis/hue-bulb-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/hue-bulb/analysis/hue-bulb-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/hue-bulb/signatures/hue-bulb-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/hue-bulb/signatures/hue-bulb-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/hue-bulb/hue-bulb.eth0.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="27" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ================================================= KWIKSET DOORLOCK =================================================== + # Has no device side signature. + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/kwikset-doorlock/analysis/kwikset-doorlock-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/kwikset-doorlock/analysis/kwikset-doorlock-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/kwikset-doorlock/signatures/kwikset-doorlock-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/kwikset-doorlock/signatures/kwikset-doorlock-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/kwikset-doorlock/kwikset-doorlock.eth0.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="3161" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ================================================= NEST THERMOSTAT ==================================================== + # Has no device side signature. + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/nest-thermostat/analysis/nest-thermostat-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/nest-thermostat/analysis/nest-thermostat-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/nest-thermostat/signatures/nest-thermostat-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/nest-thermostat/signatures/nest-thermostat-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/nest-thermostat/nest-thermostat.eth0.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="1179" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + ./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ====================================================== ST PLUG ======================================================= + # Has no device side signature. + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/st-plug/analysis/st-plug-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/st-plug/analysis/st-plug-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/st-plug/signatures/st-plug-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/st-plug/signatures/st-plug-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/st-plug/st-plug.wlan1.detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="2445" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ==================================================== TP-LINK BULB ==================================================== + # Has no device side signature. + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-bulb/analysis/tplink-bulb-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-bulb/analysis/tplink-bulb-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-bulb/signatures/tplink-bulb-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-bulb/signatures/tplink-bulb-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/tplink-bulb/tplink-bulb.wlan1.wan-detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="162" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ==================================================== TP-LINK PLUG ==================================================== + # DEVICE SIDE (both the 112, 115 and 556, 1293 sequences) + ON_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-onClusters.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-offClusters.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-onSignature-device-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-offSignature-device-side.sig" + RESULTS_FILE="$OUTPUT_DIR/tplink-plug/tplink-plug.wlan1.wan-detection.pcap___device-side$i.detectionresults" + SIGNATURE_DURATION="3660" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + + # DEVICE SIDE OUTBOUND (contains only those packets that go through the WAN port, i.e., only the 556, 1293 sequence) + ON_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-onClusters.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/tplink-plug/analysis/tplink-plug-offClusters.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-onSignature-device-side-outbound.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/tplink-plug/signatures/tplink-plug-offSignature-device-side-outbound.sig" + RESULTS_FILE="$OUTPUT_DIR/tplink-plug/tplink-plug.wlan1.wan-detection.pcap___device-side-outbound$i.detectionresults" + SIGNATURE_DURATION="224" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + + # Phone side does not make sense as it is merely a subset of the device side and does not differentiate ONs from OFFs. + # ====================================================================================================================== + + + + # ================================================== WEMO INSIGHT PLUG ================================================= + # Has no device side signature. + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-insight-plug/analysis/wemo-insight-plug-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-insight-plug/analysis/wemo-insight-plug-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-insight-plug/signatures/wemo-insight-plug-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-insight-plug/signatures/wemo-insight-plug-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/wemo-insight-plug/wemo-insight-plug.wlan1.wan-detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="106" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== + + + + # ===================================================== WEMO PLUG ====================================================== + # Has no device side signature. + + # PHONE SIDE + ON_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-plug/analysis/wemo-plug-onClusters-phone-side.cls" + OFF_ANALYSIS="$SIGNATURES_BASE_DIR/wemo-plug/analysis/wemo-plug-offClusters-phone-side.cls" + ON_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-plug/signatures/wemo-plug-onSignature-phone-side.sig" + OFF_SIGNATURE="$SIGNATURES_BASE_DIR/wemo-plug/signatures/wemo-plug-offSignature-phone-side.sig" + RESULTS_FILE="$OUTPUT_DIR/wemo-plug/wemo-plug.wlan1.wan-detection.pcap___phone-side$i.detectionresults" + SIGNATURE_DURATION="147" + + PROGRAM_ARGS="'$PCAP_FILE' '$ON_ANALYSIS' '$OFF_ANALYSIS' '$ON_SIGNATURE' '$OFF_SIGNATURE' '$RESULTS_FILE' '$SIGNATURE_DURATION'" + #./gradlew run -DmainClass=edu.uci.iotproject.detection.layer3.Layer3SignatureDetector --args="$PROGRAM_ARGS" + # ====================================================================================================================== +done diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java index 505bfdc..2fc1d7a 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SignatureDetector.java @@ -52,11 +52,12 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb public static void main(String[] args) throws PcapNativeException, NotOpenException, IOException { // Parse required parameters. - if (args.length < 7) { +// if (args.length < 7) { + if (args.length < 5) { String errMsg = String.format("Usage: %s inputPcapFile onAnalysisFile offAnalysisFile onSignatureFile offSignatureFile resultsFile" + "\n inputPcapFile: the target of the detection" + - "\n onAnalysisFile: the file that contains the ON clusters analysis" + - "\n offAnalysisFile: the file that contains the OFF clusters analysis" + +// "\n onAnalysisFile: the file that contains the ON clusters analysis" + +// "\n offAnalysisFile: the file that contains the OFF clusters analysis" + "\n onSignatureFile: the file that contains the ON signature to search for" + "\n offSignatureFile: the file that contains the OFF signature to search for" + "\n resultsFile: where to write the results of the detection" + @@ -77,13 +78,19 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb System.out.println(optParamsExplained); return; } +// final String pcapFile = args[0]; +// final String onClusterAnalysisFile = args[1]; +// final String offClusterAnalysisFile = args[2]; +// final String onSignatureFile = args[3]; +// final String offSignatureFile = args[4]; +// final String resultsFile = args[5]; +// final int signatureDuration = Integer.parseInt(args[6]); + final String pcapFile = args[0]; - final String onClusterAnalysisFile = args[1]; - final String offClusterAnalysisFile = args[2]; - final String onSignatureFile = args[3]; - final String offSignatureFile = args[4]; - final String resultsFile = args[5]; - final int signatureDuration = Integer.parseInt(args[6]); + final String onSignatureFile = args[1]; + final String offSignatureFile = args[2]; + final String resultsFile = args[3]; + final int signatureDuration = Integer.parseInt(args[4]); // Parse optional parameters. List> onSignatureMacFilters = null, offSignatureMacFilters = null; @@ -110,8 +117,8 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb // Include metadata as comments at the top PrintWriterUtils.println("# Detection results for:", resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); PrintWriterUtils.println("# - inputPcapFile: " + pcapFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); - PrintWriterUtils.println("# - onAnalysisFile: " + onClusterAnalysisFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); - PrintWriterUtils.println("# - offAnalysisFile: " + offClusterAnalysisFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); +// PrintWriterUtils.println("# - onAnalysisFile: " + onClusterAnalysisFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); +// PrintWriterUtils.println("# - offAnalysisFile: " + offClusterAnalysisFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); PrintWriterUtils.println("# - onSignatureFile: " + onSignatureFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); PrintWriterUtils.println("# - offSignatureFile: " + offSignatureFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); resultsWriter.flush(); @@ -121,23 +128,23 @@ public class Layer2SignatureDetector implements PacketListener, ClusterMatcherOb List>> onSignature = PrintUtils.deserializeFromFile(onSignatureFile); List>> offSignature = PrintUtils.deserializeFromFile(offSignatureFile); // Load signature analyses - List>> onClusterAnalysis = PrintUtils.deserializeFromFile(onClusterAnalysisFile); - List>> offClusterAnalysis = PrintUtils.deserializeFromFile(offClusterAnalysisFile); +// List>> onClusterAnalysis = PrintUtils.deserializeFromFile(onClusterAnalysisFile); +// List>> offClusterAnalysis = PrintUtils.deserializeFromFile(offClusterAnalysisFile); // TODO: FOR NOW WE DECIDE PER SIGNATURE AND THEN WE OR THE BOOLEANS // TODO: SINCE WE ONLY HAVE 2 SIGNATURES FOR NOW (ON AND OFF), THEN IT IS USUALLY EITHER RANGE-BASED OR // TODO: STRICT MATCHING // Check if we should use range-based matching // boolean isRangeBasedForOn = PcapPacketUtils.isRangeBasedMatching(onSignature, eps, offSignature); // boolean isRangeBasedForOff = PcapPacketUtils.isRangeBasedMatching(offSignature, eps, onSignature); +// // Update the signature with ranges if it is range-based +// if (isRangeBasedForOn && isRangeBasedForOff) { +// onSignature = PcapPacketUtils.useRangeBasedMatching(onSignature, onClusterAnalysis); +// offSignature = PcapPacketUtils.useRangeBasedMatching(offSignature, offClusterAnalysis); +// } // TODO: WE DON'T DO RANGE-BASED FOR NOW BECAUSE THE RESULTS ARE TERRIBLE FOR LAYER 2 MATCHING // TODO: THIS WOULD ONLY WORK FOR SIGNATURES LONGER THAN 2 PACKETS boolean isRangeBasedForOn = false; boolean isRangeBasedForOff = false; - // Update the signature with ranges if it is range-based - if (isRangeBasedForOn && isRangeBasedForOff) { - onSignature = PcapPacketUtils.useRangeBasedMatching(onSignature, onClusterAnalysis); - offSignature = PcapPacketUtils.useRangeBasedMatching(offSignature, offClusterAnalysis); - } Layer2SignatureDetector onDetector = onSignatureMacFilters == null ? new Layer2SignatureDetector(onSignature, isRangeBasedForOn, eps) : new Layer2SignatureDetector(onSignature, onSignatureMacFilters, signatureDuration, isRangeBasedForOn, eps); diff --git a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java index f33f3f8..92d2bd9 100644 --- a/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java +++ b/Code/Projects/PacketLevelSignatureExtractor/src/main/java/edu/uci/iotproject/detection/layer3/Layer3SignatureDetector.java @@ -104,9 +104,9 @@ public class Layer3SignatureDetector implements PacketListener, ClusterMatcherOb // WAN Layer3SignatureDetector onDetector = new Layer3SignatureDetector(onSignature, ROUTER_WAN_IP, - 0, isRangeBasedForOn, eps); + signatureDuration, isRangeBasedForOn, eps); Layer3SignatureDetector offDetector = new Layer3SignatureDetector(offSignature, ROUTER_WAN_IP, - 0, isRangeBasedForOff, eps); + signatureDuration, isRangeBasedForOff, eps); final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM). withLocale(Locale.US).withZone(ZoneId.of("America/Los_Angeles")); @@ -170,10 +170,15 @@ public class Layer3SignatureDetector implements PacketListener, ClusterMatcherOb // Output the detected events detectedEvents.forEach(outputter); - System.out.println("Number of detected events of type " + UserAction.Type.TOGGLE_ON + ": " + - detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_ON).count()); - System.out.println("Number of detected events of type " + UserAction.Type.TOGGLE_OFF + ": " + - detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_OFF).count()); + String resultOn = "Number of detected events of type " + UserAction.Type.TOGGLE_ON + ": " + + detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_ON).count(); + String resultOff = "Number of detected events of type " + UserAction.Type.TOGGLE_OFF + ": " + + detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_OFF).count(); + PrintWriterUtils.println(resultOn, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); + PrintWriterUtils.println(resultOff, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT); + System.out.println(resultOn); + System.out.println(resultOff); + // Flush output to results file and close it. resultsWriter.flush(); -- 2.34.1