You know Tor, and i don’t have to explain it to you about this cool opensource project. In this post i’m going to show you how to get list of all near real time IP addresses of Tor exit nodes using Ruby.
Basically there are three simple steps in this implementation:
- Get the newest Tor exit nodes data from https://check.torproject.org/exit-addresses
- Get all the ip addresses from that data by using regex
- Store them to a file
And here is the implementation in Ruby:
$ ruby get_tor_list.rb $ Successfully written to tor-list-1434561916.txt with 1180 IP addresses in 4.045044 sec(s)
The file contains an array of IP addresses:
$ cat tor-list-1434561916.txt $ ["18.104.22.168", "22.214.171.124", "126.96.36.199", "188.8.131.52",...]
Now you can use these IP addresses for whatever you want like blocking the access of anyone with these IP addresses that visits your site.