Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * _ __ ___ __ _
- * | | / /__ / | ________ / / ___ ____ (_)___ ____
- * | | /| / / _ \ / /| | / ___/ _ \ / / / _ \/ __ `/ / __ \/ __ \
- * | |/ |/ / __/ / ___ |/ / / __/ / /___/ __/ /_/ / / /_/ / / / / _ _ _
- * |__/|__/\___/ /_/ |_/_/ \___/ /_____/\___/\__, /_/\____/_/ /_(_|_|_)_)
- * /\_/ /
- * \ _ /
- *
- * #OpDarknet: This script checks whether an TOR onion address is online or not.
- * This assumes your usings TOR socks 9050 and control port 9051. Uses $_GET['host']
- * as input parameter.
- *
- * #occupywallstreet, #freeanons, #freetopiary, #antisec
- * We are Anonymous.
- * We are Legion.
- * We do not forgive.
- * We do not forget.
- * Expect us.
- */
- /* Request a new identity through the control port */
- function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code='') {
- $fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30);
- if (!$fp) return false; //can't connect to the control port
- fputs($fp, "AUTHENTICATE $auth_code\r\n");
- $response = fread($fp, 1024);
- list($code, $text) = explode(' ', $response, 2);
- if ($code != '250') return false; //authentication failed
- //send the request to for new identity
- fputs($fp, "signal NEWNYM\r\n");
- $response = fread($fp, 1024);
- list($code, $text) = explode(' ', $response, 2);
- if ($code != '250') return false; //signal failed
- fclose($fp);
- return true;
- }
- /* A socks 4a wrapper, returns a socket through to the destination */
- function socks_connect ( $ip, $port, $dhost, $dport ) {
- if ( $socket = fsockopen( $ip, $port, $err, $errstr ) ) {
- /* Ask for a tunnel through to the destination */
- $h = pack("H*","0401")
- .pack( "n", $dport )
- .pack( "H*",'0000000'.rand(1,9)."00" )
- .$dhost.pack("H*","00" );
- if ( !fwrite( $socket, $h ) ) die ('Connection to socks failed');
- else return $socket;
- } else die('Cannot establish socks connection. Check settings');
- }
- function check( $url, $proxy ) {
- $tmp = parse_url($url);
- if ( !isset($tmp['host']) ) $tmp['host'] = $url;
- $fp = socks_connect( $proxy[0], $proxy[1], $url, 80 );
- $out = "HEAD / HTTP/1.1\r\n";
- $out .= "Host: ".$tmp['host']."\r\n"; // this will have to be broken down to URL and request
- $out .= "Proxy-Connection: close\r\n\r\n";
- fwrite($fp, $out);
- $response = '';
- while ( !feof($fp) ) {
- $response .= fgets($fp, 128);
- }
- fclose($fp);
- return $response;
- }
- /* How to get the correct PORT to your Tor Sock:
- *
- * Open your Tor browser Edit/Preferences/Advanced/Network/Settings
- * and see the SOCKS host and port
- */
- $proxy = array('127.0.0.1', '9050'); // Supply your SOCKS Tor credentials
- $response = check ( $_GET['host'] , $proxy );
- var_dump($response); // debug
- // do whatever we need to verify (200, 404, etc.)
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement