Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2. $username = strtolower($_GET["username"]);
  3. $password = $_GET["password"];
  4.  
  5. $con = mysql_connect("localhost","MysqlUsername","MysqlPassword");
  6. if (!$con)
  7.   {
  8.   die('conection failed');
  9.   }
  10.  
  11. mysql_select_db("Database", $con);
  12.  
  13. $result = mysql_query("SELECT * FROM phpbb_users
  14. WHERE username_clean='{$username}'");
  15.  
  16. while($row = mysql_fetch_array($result))
  17.   {
  18.   $realHash = $row['user_password'];
  19.   }
  20.  
  21. if(phpbb_check_hash($password, $realHash))
  22.     echo "true";
  23. else
  24.     echo "false";
  25.  
  26.  
  27.   function phpbb_check_hash($password, $hash)
  28. {
  29.     $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  30.     if (strlen($hash) == 34)
  31.     {
  32.         return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
  33.     }
  34.  
  35.     return (md5($password) === $hash) ? true : false;
  36. }
  37.  
  38. function _hash_encode64($input, $count, &$itoa64)
  39. {
  40.     $output = '';
  41.     $i = 0;
  42.  
  43.     do
  44.     {
  45.         $value = ord($input[$i++]);
  46.         $output .= $itoa64[$value & 0x3f];
  47.  
  48.         if ($i < $count)
  49.         {
  50.             $value |= ord($input[$i]) << 8;
  51.         }
  52.  
  53.         $output .= $itoa64[($value >> 6) & 0x3f];
  54.  
  55.         if ($i++ >= $count)
  56.         {
  57.             break;
  58.         }
  59.  
  60.         if ($i < $count)
  61.         {
  62.             $value |= ord($input[$i]) << 16;
  63.         }
  64.  
  65.         $output .= $itoa64[($value >> 12) & 0x3f];
  66.  
  67.         if ($i++ >= $count)
  68.         {
  69.             break;
  70.         }
  71.  
  72.         $output .= $itoa64[($value >> 18) & 0x3f];
  73.     }
  74.     while ($i < $count);
  75.  
  76.     return $output;
  77. }
  78.  
  79. function _hash_crypt_private($password, $setting, &$itoa64)
  80. {
  81.     $output = '*';
  82.  
  83.     // Check for correct hash
  84.     if (substr($setting, 0, 3) != '$H$')
  85.     {
  86.         return $output;
  87.     }
  88.  
  89.     $count_log2 = strpos($itoa64, $setting[3]);
  90.  
  91.     if ($count_log2 < 7 || $count_log2 > 30)
  92.     {
  93.         return $output;
  94.     }
  95.  
  96.     $count = 1 << $count_log2;
  97.     $salt = substr($setting, 4, 8);
  98.  
  99.     if (strlen($salt) != 8)
  100.     {
  101.         return $output;
  102.     }
  103.     if (PHP_VERSION >= 5)
  104.     {
  105.         $hash = md5($salt . $password, true);
  106.         do
  107.         {
  108.             $hash = md5($hash . $password, true);
  109.         }
  110.         while (--$count);
  111.     }
  112.     else
  113.     {
  114.         $hash = pack('H*', md5($salt . $password));
  115.         do
  116.         {
  117.             $hash = pack('H*', md5($hash . $password));
  118.         }
  119.         while (--$count);
  120.     }
  121.  
  122.     $output = substr($setting, 0, 12);
  123.     $output .= _hash_encode64($hash, 16, $itoa64);
  124.  
  125.     return $output;
  126. }  
  127.  
  128. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement