-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconntrack.sh
136 lines (112 loc) · 6.59 KB
/
conntrack.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# set -x
rhel() {
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
if [[ ! -e /var/tmp/snow ]]; then
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
fi
echo -e "${green}Conntrack count:${plain}"
echo -e " ${blue}$(cat /proc/sys/net/netfilter/nf_conntrack_count)${plain}"
echo -e "${green}IPs with more than Two connections:${plain}"
cat /proc/net/nf_conntrack | grep ESTABLISHED | awk '{ print $7 }' | awk -F= '{ print $2 }' | sort | uniq -c >/var/tmp/5
cd /var/tmp
echo -e "${white}$(cat 5 | grep -v ' 1 ' | grep -v ' 2 ' | sort -n)${plain}"
echo -e "${green}IPs with More than Two connections:${plain}"
cat 5 | grep -v ' 1 ' | grep -v ' 2 ' | awk '{ print $2 }' >8
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 "${green}IPs with Two connections:${plain}"
cat 5 | grep ' 2 ' | awk '{ print $2 }' >6
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 "${green}IPs with One connection:${plain}"
cat 5 | grep ' 1 ' | awk '{ print $2 }' >7
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
}
deb() {
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
if [[ ! -e /var/tmp/snow ]]; then
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
fi
echo -e "${green}Conntrack count:${plain}"
echo -e " ${blue}$(conntrack -C)${plain}"
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 "${white}$(cat 5 | grep -v ' 1 ' | grep -v ' 2 ')${plain}"
echo -e "${green}IPs with More than Two connections:${plain}"
cat 5 | grep -v ' 1 ' | grep -v ' 2 ' | awk '{ print $2 }' >8
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 "${green}IPs with Two connections:${plain}"
cat 5 | grep ' 2 ' | awk '{ print $2 }' >6
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 "${green}IPs with One connection:${plain}"
cat 5 | grep ' 1 ' | awk '{ print $2 }' >7
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
}
if [[ ! -e /proc/net/nf_conntrack ]]; then
deb
else
rhel
fi