Advertisement
Googleinurl

Mudar ip TOR

Jul 9th, 2014
1,190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 KB | None | 0 0
  1. //http://www.linuxquestions.org/questions/linux-newbie-8/telnet-connect-to-address-127-0-0-1-connection-refused-4175452681/
  2. //http://w-shadow.com/blog/2008/06/20/tor-how-to-new-identity-with-php/
  3. //https://github.com/craig/ge.mine.nu/tree/master/tor-ctrl
  4. //https://stem.torproject.org/faq.html
  5. //https://stem.torproject.org/download.html
  6.  
  7. <?php /**
  8.  * Switch TOR to a new identity.
  9.  **/
  10. function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code=''){
  11.     $fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30);
  12.     if (!$fp) return false; //can't connect to the control port
  13.      
  14.     fputs($fp, "AUTHENTICATE $auth_code\r\n");
  15.     $response = fread($fp, 1024);
  16.     list($code, $text) = explode(' ', $response, 2);
  17.     if ($code != '250') return false; //authentication failed
  18.      
  19.     //send the request to for new identity
  20.     fputs($fp, "signal NEWNYM\r\n");
  21.     $response = fread($fp, 1024);
  22.     list($code, $text) = explode(' ', $response, 2);
  23.     if ($code != '250') return false; //signal failed
  24.      
  25.     fclose($fp);
  26.     return true;
  27. }
  28.  
  29. /**
  30.  * Load the TOR's "magic cookie" from a file and encode it in hexadecimal.
  31.  **/
  32. function tor_get_cookie($filename){
  33.     $cookie = file_get_contents($filename);
  34.     //convert the cookie to hexadecimal
  35.     $hex = '';
  36.     for ($i=0;$i<strlen($cookie);$i++){
  37.         $h = dechex(ord($cookie[$i]));
  38.         $hex .= str_pad($h, 2, '0', STR_PAD_LEFT);
  39.     }
  40.     return strtoupper($hex);
  41. }
  42.  
  43.  
  44. $cookie = tor_get_cookie('/path/to/tor/data/dir/control_auth_cookie');
  45. if (tor_new_identity('127.0.0.01', '9051')) {
  46.     echo "Identity switched!";
  47. }
  48. ?>
  49.  
  50.  
  51.  
  52.  
  53. //------------------------------------------------------
  54.  
  55.  
  56.  
  57. python
  58. from stem import Signal
  59. from stem.control import Controller
  60.  
  61. with Controller.from_port(port = 9051) as controller:
  62.   controller.authenticate()
  63.   controller.signal(Signal.NEWNYM)
  64. /python
  65.  
  66. Comando
  67. echo 123456 > /var/lib/tor/control_auth_cookie
  68. echo -e 'AUTHENTICATE "123456"\r\nsignal NEWNYM\r\nQUIT' | nc localhost 9051
  69.  
  70. Comando2
  71. [ -z 'pidof tor' ] || echo '::::MUDANDO IP TOR::::';pidof tor | xargs sudo kill -HUP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement