-
Notifications
You must be signed in to change notification settings - Fork 8
/
compare.sh
71 lines (59 loc) · 2.5 KB
/
compare.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# set -x
green='\033[1;32m'
blue='\033[1;36m'
white='\033[1;37m'
plain='\033[0m'
if [[ ! -e /var/tmp/file2 ]]; then
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/relays-v4.txt' >/var/tmp/file2
elif
[[ $(find "/var/tmp/file2" -mmin +60 -print) ]]
then
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/relays-v4.txt' >/var/tmp/file2
fi
if [[ ! -e /var/tmp/multi ]]; then
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/above1-or.txt' >/var/tmp/multi
elif
[[ $(find "/var/tmp/multi" -mmin +60 -print) ]]
then
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/above1-or.txt' >/var/tmp/multi
fi
for i in $(cat ipv4.txt | sed 's/:/-/'); do
/usr/sbin/ipset -L tor-$i | awk '{print $1}' >/var/tmp/$i
echo -e "${green}All Blocked Addresses in tor-$i:${white}"
/usr/sbin/ipset -L tor-$i | grep 'Number' | awk '{ print $4 }'
sleep 2
echo -e "${blue}$(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/file2 | wc -l)${green} relays in tor-$i:${white}"
sleep 1
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/file2 | sort -n
echo -e "${blue}$(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/multi | wc -l)${green} relays with multiple Tor instances in tor-$i:${white}"
sleep 2
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/multi | sort -n
read -p "Remove All 'a'. Only the ones with multiple OR ports 'm'. Do Nothing 'n' (a/m/n) " yn
case $yn in
a)
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/file2 >/var/tmp/remove-$i
for b in $(cat /var/tmp/remove-$i); do
/usr/sbin/ipset del tor-$i $b
done
;;
m)
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/multi >/var/tmp/dual-$i
for b in $(cat /var/tmp/dual-$i); do
/usr/sbin/ipset del tor-$i $b
done
;;
n)
echo -e "Doing nothing, next list .... ${plain}"
;;
*)
echo -e "invalid response, next list ... ${plain}"
;;
esac
echo -e "${white}"
read -p "Press Enter to continue" </dev/tty
echo -e "${plain}"
done
for i in $(cat ipv4.txt | sed 's/:/-/'); do
/bin/rm -r /var/tmp/$i /var/tmp/remove-$i /var/tmp/dual-$i 2>/dev/null
done