daily pastebin goal
50%
SHARE
TWEET

#OpDarknet - TOR .onion is up or not

opdarknet Oct 24th, 2011 24,279 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     /**
  4.      *
  5.      *   _        __        ___                 __               _                
  6.      *   | |     / /__     /   |  ________     / /   ___  ____  (_)___  ____      
  7.      *   | | /| / / _ \   / /| | / ___/ _ \   / /   / _ \/ __ `/ / __ \/ __ \    
  8.      *   | |/ |/ /  __/  / ___ |/ /  /  __/  / /___/  __/ /_/ / / /_/ / / / / _ _ _
  9.      *   |__/|__/\___/  /_/  |_/_/   \___/  /_____/\___/\__, /_/\____/_/ /_(_|_|_)_)
  10.      *                                                 /\_/ /
  11.      *                                                 \ _ /  
  12.      *  
  13.      *  #OpDarknet: This script checks whether an TOR onion address is online or not.
  14.      *  This assumes your usings TOR socks 9050 and control port 9051.  Uses $_GET['host']
  15.      *  as input parameter.
  16.      *
  17.      *  #occupywallstreet, #freeanons, #freetopiary, #antisec
  18.      *  We are Anonymous.
  19.      *  We are Legion.
  20.      *  We do not forgive.
  21.      *  We do not forget.
  22.      *  Expect us.    
  23.      */
  24.    
  25.     /* Request a new identity through the control port */
  26.     function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code='') {
  27.         $fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30);
  28.         if (!$fp) return false; //can't connect to the control port
  29.  
  30.         fputs($fp, "AUTHENTICATE $auth_code\r\n");
  31.         $response = fread($fp, 1024);
  32.         list($code, $text) = explode(' ', $response, 2);
  33.         if ($code != '250') return false; //authentication failed
  34.  
  35.         //send the request to for new identity
  36.         fputs($fp, "signal NEWNYM\r\n");
  37.         $response = fread($fp, 1024);
  38.         list($code, $text) = explode(' ', $response, 2);
  39.         if ($code != '250') return false; //signal failed
  40.  
  41.         fclose($fp);
  42.         return true;
  43.     }
  44.    
  45.     /* A socks 4a wrapper, returns a socket through to the destination */
  46.     function socks_connect ( $ip, $port, $dhost, $dport ) {
  47.         if ( $socket = fsockopen( $ip, $port, $err, $errstr ) ) {
  48.             /* Ask for a tunnel through to the destination */
  49.             $h = pack("H*","0401")
  50.                 .pack( "n", $dport )
  51.                 .pack( "H*",'0000000'.rand(1,9)."00" )
  52.                 .$dhost.pack("H*","00" );
  53.             if ( !fwrite( $socket, $h ) ) die ('Connection to socks failed');
  54.             else return $socket;
  55.         } else die('Cannot establish socks connection. Check settings');
  56.     }
  57.    
  58.     function check( $url, $proxy ) {
  59.         $tmp = parse_url($url);
  60.         if ( !isset($tmp['host']) ) $tmp['host'] = $url;
  61.        
  62.         $fp = socks_connect( $proxy[0], $proxy[1], $url, 80 );
  63.         $out = "HEAD / HTTP/1.1\r\n";
  64.         $out .= "Host: ".$tmp['host']."\r\n"; // this will have to be broken down to URL and request
  65.         $out .= "Proxy-Connection: close\r\n\r\n";
  66.         fwrite($fp, $out);
  67.         $response = '';
  68.         while ( !feof($fp) ) {
  69.             $response .= fgets($fp, 128);
  70.         }
  71.         fclose($fp);
  72.         return $response;
  73.    }
  74.     /* How to get the correct PORT to your Tor Sock:
  75.     *
  76.     * Open your Tor browser Edit/Preferences/Advanced/Network/Settings
  77.     * and see the SOCKS host and port
  78.     */
  79.     $proxy = array('127.0.0.1', '9050'); // Supply your SOCKS Tor credentials
  80.     $response = check ( $_GET['host'] , $proxy );
  81.     var_dump($response); // debug
  82.     // do whatever we need to verify (200, 404, etc.)
  83. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top