pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP pastebin - collaborative debugging tool View Help


Posted by Ishkur on Sun 29 Jun 19:15
report abuse | download | new post

  1. <?php
  2.  
  3. /**
  4.  * PHP5 class for interfacing with the Tor network
  5.  * by Josh Sandlin <josh@thenullbyte.org>
  6.  *
  7.  * Licensed: MIT/X11
  8.  *
  9.  * NOTE: The proxy host is configurable by the user,
  10.  * so therefore one i not limited to only the Tor
  11.  * network. The default setting however is to run
  12.  * all data through the Tor/Privoxy network.
  13.  *
  14.  */
  15.  
  16. class Tor
  17. {
  18.     private $url;
  19.     private $userAgent;
  20.     private $timeout;
  21.     private $proxy;
  22.     private $vector;
  23.     private $payload;
  24.     private $returnData;
  25.  
  26.     public function Tor()
  27.     {
  28.         $this->url = null;
  29.         $this->userAgent = null;
  30.         $this->timeout = 300;
  31.         $this->proxy = '127.0.0.1:9050';
  32.         $this->vector = null;
  33.         $this->payload = null;
  34.         $this->returnData = null;
  35.     }
  36.  
  37.     private function setUrl($url)
  38.     {
  39.         $this->url = $url;
  40.     }
  41.  
  42.     private function setUserAgent()
  43.     {
  44.         //list of browsers
  45.         $agentBrowser = array(
  46.                 'Firefox',
  47.                 'Safari',
  48.                 'Opera',
  49.                 'Flock',
  50.                 'Internet Explorer',
  51.                 'Seamonkey',
  52.                 'Konqueror',
  53.                 'GoogleBot'
  54.         );
  55.         //list of operating systems
  56.         $agentOS = array(
  57.                 'Windows 3.1',
  58.                 'Windows 95',
  59.                 'Windows 98',
  60.                 'Windows 2000',
  61.                 'Windows NT',
  62.                 'Windows XP',
  63.                 'Windows Vista',
  64.                 'Redhat Linux',
  65.                 'Ubuntu',
  66.                 'Fedora',
  67.                 'AmigaOS',
  68.                 'OS 10.5'
  69.         );
  70.         //randomly generate UserAgent
  71.         $this->userAgent = $agentBrowser[rand(0,7)].'/'.rand(1,8).'.'.rand(0,9).' (' .$agentOS[rand(0,11)].' '.rand(1,7).'.'.rand(0,9).'; en-US;)';
  72.     }
  73.  
  74.     private function setTimeout($timeout)
  75.     {
  76.         $this->timeout = $timeout;
  77.     }
  78.  
  79.     public function setProxy($ip, $port)
  80.     {
  81.         $this->proxy = $ip .":". $port;
  82.     }
  83.  
  84.     private function setVector($vector)
  85.     {
  86.         $this->vector = $vector;
  87.     }
  88.  
  89.     private function setCurl()
  90.     {
  91.         $action = curl_init();
  92.         curl_setopt($action, CURLOPT_PROXY, $this->proxy);
  93.         curl_setopt($action, CURLOPT_URL, $this->payload);
  94.         curl_setopt($action, CURLOPT_HEADER, 1);
  95.         curl_setopt($action, CURLOPT_USERAGENT, $this->userAgent);
  96.         curl_setopt($action, CURLOPT_RETURNTRANSFER, 1);
  97.         curl_setopt($action, CURLOPT_FOLLOLOCATION, 1);
  98.         curl_setopt($action, CURLOPT_TIMEOUT, $this->timeout);
  99.         $this->returnData = curl_exec($action);
  100.         curl_close($action);
  101.     }
  102.    
  103.     private function setPayload()
  104.     {
  105.         $this->payload = $this->url . $this->vector;
  106.     }
  107.  
  108.     public function launch($url, $vector, $timeout = null)
  109.     {
  110.         //set parameters
  111.         $this->setUrl($url);
  112.         $this->setVector($vector);
  113.         $this->setUserAgent();
  114.            
  115.         //set payload
  116.         $this->setPayload();
  117.            
  118.         //if a timeout is set in the args, use it
  119.         if(isset($timeout))
  120.         {
  121.             $this->setTimeout($timeout);
  122.         }
  123.            
  124.         //run cURL action against url
  125.         $this->setCurl();
  126.     }
  127.  
  128.     public function getTorData()
  129.     {
  130.         return array(
  131.                 'url' => $this->url,
  132.                 'userAgent' => $this->userAgent,
  133.                 'timeout' => $this->timeout,
  134.                 'proxy' => $this->proxy,
  135.                 'payload' => $this->payload,
  136.                 'return' => $this->returnData
  137.         );
  138.     }
  139. }
  140.  
  141. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post