Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import pycurl
  2. import stem.process
  3. import io
  4.  
  5. SOCKS_PORT = 9150
  6.  
  7. print("Starting Tor:\n")
  8.  
  9. def print_bootstrap_lines(line):
  10.   if "Bootstrapped " in line:
  11.     print(line)
  12.  
  13. tor_process = stem.process.launch_tor_with_config(
  14.   config = {
  15.     'SocksPort': str(SOCKS_PORT),
  16.     #'ExitNodes': '{ru}',
  17.   },
  18.   init_msg_handler = print_bootstrap_lines,
  19. )
  20.  
  21. output = io.BytesIO()
  22.  
  23. curl = pycurl.Curl()
  24. curl.setopt( pycurl.URL, 'http://www.priler.com/ip.php' )
  25. curl.setopt( pycurl.PROXY, 'localhost' )
  26. curl.setopt( pycurl.PROXYPORT, SOCKS_PORT )
  27. curl.setopt( pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5 )
  28. curl.setopt( pycurl.WRITEFUNCTION, output.write)
  29.  
  30. curl.perform()
  31.  
  32. print("RESULT : " + output.getvalue().decode('ascii'))
  33.  
  34. #print("RESULT : " + output.getvalue())
  35.  
  36. tor_process.kill()  # stops tor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement