Skip to content

Instantly share code, notes, and snippets.

@dustyfresh
Created June 17, 2016 15:37
Show Gist options
  • Save dustyfresh/e90ff480bca20c97211c3de57999452f to your computer and use it in GitHub Desktop.
Save dustyfresh/e90ff480bca20c97211c3de57999452f to your computer and use it in GitHub Desktop.
Check if an IP address is a Tor exit node or not. Requires the requests module.
#!/usr/bin/env python
import requests
import re
def checkTor(ip):
headers = {'user-agent': 'checkTor'}
exit_nodes = requests.get('https://check.torproject.org/exit-addresses', headers=headers)
exit_nodes = exit_nodes.text
if re.search(ip, exit_nodes):
return True
else:
return False
@goshlanguage
Copy link

BLESS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment