From 6d1f3f2bf1bcd4285d68ac6c7edfdb1dd7c785d3 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Thu, 14 Jul 2022 21:56:47 +0200 Subject: [PATCH] Add automatic scrolling when headers don't fit on screen - Closes #26 --- Docker/run-analysis.sh | 21 ++++++++++++--------- Docker/utils.sh | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Docker/run-analysis.sh b/Docker/run-analysis.sh index ce4280e..ec7937f 100755 --- a/Docker/run-analysis.sh +++ b/Docker/run-analysis.sh @@ -62,20 +62,23 @@ while IFS= read -r DOMAIN; do network_inspector_search "domain:$DOMAIN " # can filter with more granularity: https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor/request_list#filtering_by_properties # grab ni_search - count=0 while network_inspector_has_more_entries do - filename="$ID/${index}.png" - scrot "/opt/static/$filename" - grab "searching $DOMAIN" - BASE_URL="$BASE_URL" python annotate_header.py "$filename" "$DOMAIN" \ - "set-cookie" "identyfikator internetowy z cookie" 11 ""\ - "Cookie" "identyfikator internetowy z cookie" 11 ""\ - "Referer" "Część mojej historii przeglądania" 0 "$ORIGIN_DOMAIN" & + screenshot_and_annotate "$ID" $index "$DOMAIN" "$ORIGIN_DOMAIN" & pids+=($!) - network_inspector_next_entry ((index++)) + while network_inspector_headers_need_scrolling + do + xdotool mousemove 2400 1000 + echo "SCROLLING DOWN" + xdotool click 5 click 5 click 5 # scroll down + sleep 0.1 + screenshot_and_annotate "$ID" $index "$DOMAIN" "$ORIGIN_DOMAIN" & + pids+=($!) + ((index++)) + done + network_inspector_next_entry ((count++)) if [ $count -gt 10 ]; then break; diff --git a/Docker/utils.sh b/Docker/utils.sh index c790574..61d32a4 100644 --- a/Docker/utils.sh +++ b/Docker/utils.sh @@ -223,3 +223,21 @@ network_inspector_next_entry(){ # measure(){ # } +network_inspector_headers_need_scrolling (){ + color=$(get_pixel_color 2870 1573) + [ "$color" = "#ededf0" ] +} + +screenshot_and_annotate(){ + ID=$1 + index=$2 + DOMAIN=$3 + ORIGIN_DOMAIN=$4 + filename="$ID/${index}.png" + scrot "/opt/static/$filename" + grab "searching $DOMAIN" + BASE_URL="$BASE_URL" python annotate_header.py "$filename" "$DOMAIN" \ + "set-cookie" "identyfikator internetowy z cookie" 11 ""\ + "Cookie" "identyfikator internetowy z cookie" 11 ""\ + "Referer" "Część mojej historii przeglądania" 0 "$ORIGIN_DOMAIN" +}