Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. public function xf(){
  2. global $db;
  3. $login = $this->login;
  4. $postPass = $this->pass;
  5. $q0 = $db->select("SELECT user_id,username from xf_user WHERE username='$login'");
  6. if(count($q0)==0) return false;
  7. $id = $q0[0]['user_id'];
  8. $q = $db->select("SELECT scheme_class,data FROM xf_user_authenticate WHERE user_id='$id'");
  9. if(count($q)==0) return false;
  10. if($q[0]['scheme_class']==='XenForo_Authentication_Core') {
  11. $salt = substr($q[0]['data'],105,64);
  12. $realPass = substr($q[0]['data'],22,64);
  13. } else {
  14. $salt = false;
  15. $realPass = substr($q[0]['data'],22,60);
  16. }
  17. $cryptPass = hash_xf($realPass,$postPass,$salt);
  18. if(!strcmp($realPass,$cryptPass) == 0 || !$realPass) return false;
  19. else return $q0[0]['username'];
  20. }
  21. function hash_xf($realPass, $postPass, $salt) {
  22. if($salt!==false) {
  23. return $cryptPass = hash('sha256', hash('sha256', $postPass) . $salt);
  24. }
  25. $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  26. $cryptPass = '*0';
  27. if (substr($realPass, 0, 2) == $cryptPass) $cryptPass = '*1';
  28. $id = substr($realPass, 0, 3);
  29. # We use "$P$", phpBB3 uses "$H$" for the same thing
  30. if ($id != '$P$' && $id != '$H$') return $cryptPass = crypt($postPass, $realPass);
  31. $count_log2 = strpos($itoa64, $realPass[3]);
  32. if ($count_log2 < 7 || $count_log2 > 30) return $cryptPass = crypt($postPass, $realPass);
  33. $count = 1 << $count_log2;
  34. $salt = substr($realPass, 4, 8);
  35. if (strlen($salt) != 8) return $cryptPass = crypt($postPass, $realPass);
  36. $hash = md5($salt . $postPass, TRUE);
  37. do {
  38. $hash = md5($hash . $postPass, TRUE);
  39. } while (--$count);
  40. $cryptPass = substr($realPass, 0, 12);
  41. $encode64 = '';
  42. $i = 0;
  43. do {
  44. $value = ord($hash[$i++]);
  45. $encode64 .= $itoa64[$value & 0x3f];
  46. if ($i < 16) $value |= ord($hash[$i]) << 8;
  47. $encode64 .= $itoa64[($value >> 6) & 0x3f];
  48. if ($i++ >= 16) break;
  49. if ($i < 16) $value |= ord($hash[$i]) << 16;
  50. $encode64 .= $itoa64[($value >> 12) & 0x3f];
  51. if ($i++ >= 16) break;
  52. $encode64 .= $itoa64[($value >> 18) & 0x3f];
  53. } while ($i < 16);
  54. $cryptPass .= $encode64;
  55. if ($cryptPass[0] == '*') $cryptPass = crypt($postPass, $realPass);
  56. return $cryptPass;
  57. }
  58. }
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement