-
Notifications
You must be signed in to change notification settings - Fork 0
/
getTorexitNodes
44 lines (29 loc) · 895 Bytes
/
getTorexitNodes
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
#!/bin/bash
usage(){
cat << EOF
usage: getexitNodes -h -a
-h prints this text
-a prints only alive nodes
EOF
}
if [ "$1" == "-h" ]; then
usage
exit 0
fi
exitaddFile=$(wget --quiet -O - https://check.torproject.org/exit-addresses | grep 'ExitAddress' | cut -d' ' -f2)
counter=0
#for the total number of IPs found in the exit-addresses file check the status of the exit Nodes
for ipaddr in $exitaddFile; do
#silent ping
ping -q -c 1 -w 1 $ipaddr > /dev/null
#check the outcome of the ping
if [ $? == 0 ]; then
echo "Tor Exit Node: $ipaddr Alive..."
let counter=counter+1
else
if [ "$1" != "-a" ]; then
echo "Tor Exit Node $ipaddr probably down..."
fi
fi
done
echo "The total Number of the alive Tor Exit Nodes is $counter"