-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
673 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,69 @@ | ||
#!/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 | ||
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 | ||
[[ $(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/dual-or ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/dual-or.txt' > /var/tmp/dual-or | ||
|
||
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/dual-or" -mmin +60 -print) ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/dual-or.txt' > /var/tmp/dual-or | ||
[[ $(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 "\033[1;32mAll relays in tor-$i:\033[1;37m" | ||
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/file2 | ||
echo -e "\033[1;32mRelays with multiple Tor instances in tor-$i:\033[1;37m" | ||
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/dual-or | ||
|
||
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/dual-or > /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 .... \033[0m"; | ||
;; | ||
|
||
* ) echo -e "invalid response, next list ... \033[0m"; | ||
;; | ||
|
||
esac | ||
|
||
echo -e "\033[1;37m" | ||
read -p "Press Enter to continue" </dev/tty | ||
echo -e "\033[0m" | ||
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; | ||
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 "${green}All relays in tor-$i:${white}" | ||
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/file2 | ||
echo -e "${green}Relays with multiple Tor instances in tor-$i:${white}" | ||
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' /var/tmp/$i /var/tmp/multi | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,65 @@ | ||
#!/bin/bash | ||
# set -x | ||
# This script depends on conntrack utilities package (apt get conntrack). If you don't have the nf_conntrack file on your system you can use this script. | ||
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 | ||
# This script depends on conntrack utilities package (apt install conntrack). If you don't have the nf_conntrack file on your system you can use this script. | ||
green='\033[1;32m' | ||
blue='\033[1;36m' | ||
white='\033[1;37m' | ||
plain='\033[0m' | ||
|
||
if [[ ! -e /var/tmp/dual-or ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/dual-or.txt' > /var/tmp/dual-or | ||
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/dual-or" -mmin +60 -print) ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/dual-or.txt' > /var/tmp/dual-or | ||
[[ $(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-or ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/above2-or.txt' > /var/tmp/multi-or | ||
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-or" -mmin +60 -print) ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/above2-or.txt' > /var/tmp/multi-or | ||
[[ $(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 | ||
|
||
if [[ ! -e /var/tmp/snow ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/snowflake.txt' > /var/tmp/snow | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/snowflake.txt' >/var/tmp/snow | ||
elif | ||
[[ $(find "/var/tmp/snow" -mmin +60 -print) ]]; then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/snowflake.txt' > /var/tmp/snow | ||
[[ $(find "/var/tmp/snow" -mmin +60 -print) ]] | ||
then | ||
curl -s 'https://raw.githubusercontent.com/Enkidu-6/tor-relay-lists/main/snowflake.txt' >/var/tmp/snow | ||
fi | ||
|
||
echo -e "\033[1;32mConntrack count:\033[0m" | ||
echo -e " \033[1;36m`conntrack -C`\033[0m" | ||
echo -e "${green}Conntrack count:${plain}" | ||
echo -e " ${blue}$(conntrack -C)${plain}" | ||
|
||
echo -e "\033[1;32mIPs with more than 2 connections:\033[0;30m" | ||
conntrack -L | grep ESTABLISHED | awk '{ print $5 }' | awk -F= '{ print $2 }' | sort | uniq -c > /var/tmp/5 | ||
conntrack -L -f ipv6 | grep ESTABLISHED | awk '{ print $5 }' | awk -F= '{ print $2 }' | sort | uniq -c >> /var/tmp/5 | ||
echo -e "${green}IPs with more than 2 connections:\033[0;30m" | ||
conntrack -L | grep ESTABLISHED | awk '{ print $5 }' | awk -F= '{ print $2 }' | sort | uniq -c >/var/tmp/5 | ||
conntrack -L -f ipv6 | grep ESTABLISHED | awk '{ print $5 }' | awk -F= '{ print $2 }' | sort | uniq -c >>/var/tmp/5 | ||
cd /var/tmp | ||
echo -e "\033[1;37m`cat 5 | grep -v ' 1 ' | grep -v ' 2 '`\033[0m" | ||
echo -e "${white}$(cat 5 | grep -v ' 1 ' | grep -v ' 2 ')${plain}" | ||
|
||
echo -e "\033[1;32mIPs with More than Two connections:\033[0m" | ||
cat 5 | grep -v ' 1 ' | grep -v ' 2 ' | awk '{ print $2 }' > 8 | ||
echo -e "${green}IPs with More than Two connections:${plain}" | ||
cat 5 | grep -v ' 1 ' | grep -v ' 2 ' | awk '{ print $2 }' >8 | ||
|
||
echo -e "\033[1;37m There are \033[1;36m`cat 8 | wc -l`\033[1;37m IPs With More than Two connections" | ||
echo -e "\033[1;36m `perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 8 file2 | wc -l` \033[1;37mRelays" | ||
echo -e "\033[1;36m `perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 8 dual-or | wc -l` \033[1;37mMulti-OR" | ||
echo -e "\033[1;36m `perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 8 snow | wc -l` \033[1;37mSnowflake\033[0m" | ||
echo -e "${white} There are ${blue}$(cat 8 | wc -l)${white} IPs With More than Two connections" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 8 file2 | wc -l) ${white}Relays" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 8 multi | wc -l) ${white}Multi-OR" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 8 snow | wc -l) ${white}Snowflake${plain}" | ||
|
||
echo -e "\033[1;32mIPs with Two connections:\033[0m" | ||
cat 5 | grep ' 2 ' | awk '{ print $2 }' > 6 | ||
echo -e "${green}IPs with Two connections:${plain}" | ||
cat 5 | grep ' 2 ' | awk '{ print $2 }' >6 | ||
|
||
echo -e "\033[1;37m There are \033[1;36m`cat 6 | wc -l`\033[1;37m IPs with Two connections" | ||
echo -e "\033[1;36m `perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 6 file2 | wc -l` \033[1;37mRelays\033[0m" | ||
echo -e "\033[1;36m `perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 6 dual-or | wc -l` \033[1;37mMulti-OR\033[0m" | ||
echo -e "${white} There are ${blue}$(cat 6 | wc -l)${white} IPs with Two connections" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 6 file2 | wc -l) ${white}Relays${plain}" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 6 multi | wc -l) ${white}Multi-OR${plain}" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 6 snow | wc -l) ${white}Snowflake${plain}" | ||
|
||
echo -e "\033[1;32mIPs with One connection:\033[0m" | ||
cat 5 | grep ' 1 ' | awk '{ print $2 }' > 7 | ||
echo -e "${green}IPs with One connection:${plain}" | ||
cat 5 | grep ' 1 ' | awk '{ print $2 }' >7 | ||
|
||
echo -e "\033[1;37m There are \033[1;36m`cat 7 | wc -l`\033[1;37m IPs With One connection" | ||
echo -e "\033[1;36m `perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 7 file2 | wc -l` \033[1;37mRelays" | ||
echo -e "\033[1;36m `perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 7 dual-or | wc -l` \033[1;37mMulti-OR\033[0m" | ||
/bin/rm -r 5 6 7 8 | ||
echo -e "${white} There are ${blue}$(cat 7 | wc -l)${white} IPs With One connection" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 7 file2 | wc -l) ${white}Relays" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 7 multi | wc -l) ${white}Multi-OR${plain}" | ||
echo -e "${blue} $(perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' 7 snow | wc -l) ${white}Snowflake${plain}" | ||
/bin/rm -r 5 6 7 8 |
Oops, something went wrong.