Skip to content

Instantly share code, notes, and snippets.

@KuJoe
Created April 20, 2022 10:40
Show Gist options
  • Save KuJoe/b8d422ee4272b78ec68a3868e5e6fb9c to your computer and use it in GitHub Desktop.
Save KuJoe/b8d422ee4272b78ec68a3868e5e6fb9c to your computer and use it in GitHub Desktop.
Simple bash script to create a list of TOR exit node IPs and format to deny them in nginx
#!/bin/bash
/usr/bin/wget -q -O - "https://www.dan.me.uk/torlist/?exit" -U SXTorBlocker/1.0 > /tmp/temp_tor_list
/usr/bin/wget -q -O - "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=80" -U NoSuchBrowser/1.0 >> /tmp/temp_tor_list
/usr/bin/wget -q -O - "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$IP_ADDRESS&port=9998" -U NoSuchBrowser/1.0 >> /tmp/temp_tor_list
/usr/bin/cat /tmp/temp_tor_list | grep -v ":" | grep -v "#" > /tmp/torlist
/usr/bin/sort -u /tmp/torlist > /tmp/nginxtorlist
/usr/bin/sed "s/^/deny /g; s/$/;/g" /tmp/nginxtorlist > /etc/nginx/block-tor.txt
/usr/bin/systemctl reload nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment