Ishkur
By: a guest | Jun 29th, 2008 | Syntax:
PHP | Size: 3.62 KB | Hits: 56 | Expires: Never
<?php
/**
* PHP5 class for interfacing with the Tor network
* by Josh Sandlin <josh@thenullbyte.org>
*
* Licensed: MIT/X11
*
* NOTE: The proxy host is configurable by the user,
* so therefore one i not limited to only the Tor
* network. The default setting however is to run
* all data through the Tor/Privoxy network.
*
*/
class Tor
{
private $url;
private $userAgent;
private $timeout;
private $proxy;
private $vector;
private $payload;
private $returnData;
public function Tor()
{
$this->url = null;
$this->userAgent = null;
$this->timeout = 300;
$this->proxy = '127.0.0.1:9050';
$this->vector = null;
$this->payload = null;
$this->returnData = null;
}
private function setUrl($url)
{
$this->url = $url;
}
private function setUserAgent()
{
//list of browsers
'Firefox',
'Safari',
'Opera',
'Flock',
'Internet Explorer',
'Seamonkey',
'Konqueror',
'GoogleBot'
);
//list of operating systems
'Windows 3.1',
'Windows 95',
'Windows 98',
'Windows 2000',
'Windows NT',
'Windows XP',
'Windows Vista',
'Redhat Linux',
'Ubuntu',
'Fedora',
'AmigaOS',
'OS 10.5'
);
//randomly generate UserAgent
$this->userAgent = $agentBrowser[rand(0,7)].'/'.rand(1,8).'.'.rand(0,9).' (' .$agentOS[rand(0,11)].' '.rand(1,7).'.'.rand(0,9).'; en-US;)';
}
private function setTimeout($timeout)
{
$this->timeout = $timeout;
}
public function setProxy($ip, $port)
{
$this->proxy = $ip .":". $port;
}
private function setVector($vector)
{
$this->vector = $vector;
}
private function setCurl()
{
curl_setopt($action, CURLOPT_USERAGENT
, $this->userAgent);
}
private function setPayload()
{
$this->payload = $this->url . $this->vector;
}
public function launch($url, $vector, $timeout = null)
{
//set parameters
$this->setUrl($url);
$this->setVector($vector);
$this->setUserAgent();
//set payload
$this->setPayload();
//if a timeout is set in the args, use it
{
$this->setTimeout($timeout);
}
//run cURL action against url
$this->setCurl();
}
public function getTorData()
{
'url' => $this->url,
'userAgent' => $this->userAgent,
'timeout' => $this->timeout,
'proxy' => $this->proxy,
'payload' => $this->payload,
'return' => $this->returnData
);
}
}
?>