scripts/adblock_test.sh

43 lines
816 B
Bash

#!/bin/bash
RED='\033[1;31m'
GREEN='\033[1;32m'
BLUE='\033[1;35m'
YELLOW='\033[1;33m'
NC='\033[0m'
ip_to_find="0.0.0.0"
blocked=0
rojo(){
echo -e "${RED}$1${NC}"
}
amarillo(){
echo -e "${YELLOW}$1${NC}"
}
verde(){
echo -e "${GREEN}$1${NC}"
}
azul(){
echo -e "${BLUE}$1${NC}"
}
if [ -z "$1" ]
then
#dns="127.0.0.1"
dns=$(cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f 2)
else
dns=$1
fi
domains=$(curl -s https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts | shuf -n 10 | cut -d" " -f2)
for j in $domains; do
echo -e "${YELLOW}$j${NC}:"
output=$(dig @$dns $j +short)
if [[ "$output" == *"$ip_to_find"* ]]; then
verde $output
((blocked++))
else
rojo $output
fi
echo ""
done;
porcentaje=$(( blocked * 10 ))
azul "$porcentaje % dominios bloqueados"