2022-05-05 21:54:34 +02:00
#!/bin/bash
2022-02-24 00:24:13 +01:00
2022-06-17 09:37:27 +02:00
export DISPLAY = :0
2022-04-24 18:09:36 +02:00
INPUT = " $1 "
ID = $2
unquote( ) {
echo $1 | sed 's/"//g'
}
2022-07-24 14:39:50 +02:00
echo $INPUT
2022-04-24 18:09:36 +02:00
URL = $( unquote $( echo $INPUT | jq .url) )
DOMAINS = ` node array-to-lines.js " $( echo $INPUT | jq .third_party_domains) " `
2022-07-24 14:39:50 +02:00
FILTERED_DOMAINS = ` node filter-requested-domains.js " $( echo $INPUT | jq .third_party_domains) " `
2022-04-24 18:09:36 +02:00
2022-04-21 22:20:44 +02:00
source ./utils.sh
2022-07-24 14:39:50 +02:00
source ./bloatter.sh
2022-04-24 19:57:01 +02:00
2022-07-15 08:17:29 +02:00
PREVIEW = "TRUE" # set to "TRUE" in order to enable automatic screenshots kept in preview.png
2022-05-25 20:10:44 +02:00
2022-05-27 15:49:56 +02:00
if [ " $PREVIEW " = "TRUE" ] ;
then
( while true; do
grab_screen_to_public $ID
2022-07-15 09:34:58 +02:00
sleep 0.7
2022-05-27 15:49:56 +02:00
done ) &
refresher_pid = $! ;
fi
2022-07-08 10:40:16 +02:00
ORIGIN_DOMAIN = $( sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/' <<< " $URL " )
2022-05-27 15:49:56 +02:00
2022-07-09 20:04:57 +02:00
2022-07-24 14:39:50 +02:00
if [ -z " $FILTERED_DOMAINS " ]
then
echo "No need to blot"
else
bloat_firefox 1
grab bloat_firefox
fi
# while IFS= read -r DOMAIN; do
# # these domains return a 404 anyways, no need to waste time on them:
# if is_http_error "$DOMAIN"; then echo "skipping $DOMAIN"; continue; fi
# load_website "$DOMAIN?hl=pl" "$DOMAIN"
# sleep 1 # sometimes the consent popup needs a little time
# open_console
# grab "$DOMAIN before"
# (tr '\n' ' ' < click-accept-all.js) | xclip -sel clip
# keycombo Control_L v
# sleep 0.3
# xdotool key Return
# sleep 1.5
# grab "$DOMAIN after"
# done <<< "$DOMAINS"
2022-07-09 20:04:57 +02:00
2022-07-09 21:57:32 +02:00
click 1270 217 # the "trash" icon, so requests from plamienie don't appear in the screenshots
2022-07-11 15:24:14 +02:00
load_website " $URL " " $URL "
2022-07-15 12:39:38 +02:00
sleep 7 # sometimes the consent popup needs a little time
2022-07-15 11:36:44 +02:00
echo " {\"current_action\": \"Strona $ORIGIN_DOMAIN wczytana. Przygotowywanie do analizy...\"} "
2022-04-24 18:09:36 +02:00
grab load_website
2022-04-21 22:20:44 +02:00
open_network_inspector
2022-04-24 18:09:36 +02:00
grab open_network_inspector
2022-04-21 22:20:44 +02:00
declare -a pids;
pids = ( )
2022-02-24 00:24:13 +01:00
2022-02-14 22:10:01 +01:00
2022-04-24 18:09:36 +02:00
index = 0
mkdir -p " /opt/static/ $ID "
while IFS = read -r DOMAIN; do
if [ " $DOMAIN " = "" ] ; then
continue
fi
2022-07-09 21:14:03 +02:00
echo " {\"current_action\": \"Skanowanie skryptów z domeny $DOMAIN ...\"} "
2022-07-08 08:59:56 +02:00
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
2022-07-07 22:35:51 +02:00
2022-06-15 20:27:15 +02:00
# grab ni_search
2022-04-24 18:09:36 +02:00
count = 0
while network_inspector_has_more_entries
do
2022-07-14 21:56:47 +02:00
screenshot_and_annotate " $ID " $index " $DOMAIN " " $ORIGIN_DOMAIN " &
2022-04-24 18:09:36 +02:00
pids += ( $! )
( ( index++) )
2022-07-14 21:56:47 +02:00
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
2022-04-24 18:09:36 +02:00
( ( count++) )
if [ $count -gt 10 ] ; then
break;
fi
done
done <<< " $DOMAINS "
2022-05-27 15:49:56 +02:00
if [ " $PREVIEW " = "TRUE" ] ;
then
kill $refresher_pid ;
fi
2022-04-24 19:57:01 +02:00
2022-07-09 21:14:03 +02:00
echo "{\"current_action\": \"Kończenie...\"}"
2022-02-13 22:30:56 +01:00
2022-04-21 22:20:44 +02:00
for PID in " ${ pids [@] } "
2022-02-24 00:24:13 +01:00
do
2022-04-21 22:20:44 +02:00
wait $PID
2022-02-24 00:24:13 +01:00
done
2022-02-13 22:30:56 +01:00
kill -2 %%;
cleanup
2022-02-24 00:24:13 +01:00
2022-04-21 22:20:44 +02:00
echo "Done!"