Guest User

Untitled

a guest
Nov 25th, 2017
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. require_once( 'wp-includes/class-phpass.php' );
  2. $wp_hasher = new PasswordHash( 8, TRUE );
  3. $password = "passwordhere";
  4. $hashed_password = $wp_hasher->HashPassword( $password );
  5. $encryptedpass = md5($hashed_password);
  6.  
  7. SELECT * FROM wp_customers WHERE email = "ccc@aaa.com" AND password = "<what goes here?>"
  8.  
  9. function wp_check_password($password, $hash, $user_id = '') {
  10. global $wp_hasher;
  11.  
  12. // If the hash is still md5...
  13. if ( strlen($hash) <= 32 ) {
  14. $check = ( $hash == md5($password) );
  15. if ( $check && $user_id ) {
  16. // Rehash using new hash.
  17. wp_set_password($password, $user_id);
  18. $hash = wp_hash_password($password);
  19. }
  20.  
  21. return apply_filters('check_password', $check, $password, $hash, $user_id);
  22. }
  23.  
  24. // If the stored hash is longer than an MD5, presume the
  25. // new style phpass portable hash.
  26. if ( empty($wp_hasher) ) {
  27. require_once ( ABSPATH . 'wp-includes/class-phpass.php');
  28. // By default, use the portable hash from phpass
  29. $wp_hasher = new PasswordHash(8, TRUE);
  30. }
  31.  
  32. $check = $wp_hasher->CheckPassword($password, $hash);
  33.  
  34. return apply_filters('check_password', $check, $password, $hash, $user_id);
  35. }
  36.  
  37. function my_password_validation( $username, $password ) {
  38. // Select the users's password hash from the database
  39. $stored = query( 'SELECT * FROM wp_customers WHERE email = ' . $username );
  40.  
  41. require_one( 'class-phpass.php' );
  42. $hasher = new PasswordHash(8, TRUE);
  43.  
  44. return $hasher->CheckPassword( $password, $stored );
  45. }
  46.  
  47. <?php
  48. include_once($_SERVER['DOCUMENT_ROOT'].'/wp-includes/class-phpass.php' );
  49.  
  50. // prepare database connection
  51. $ip_address="localhost";
  52. $user_db="userdb";
  53. $pass_db="passdb";
  54.  
  55. $conn= mysql_connect($ip_address,$user_db,$pass_db);
  56. mysql_select_db("dbname",$conn);
  57. if (!$conn){
  58. echo "Could not connect: " . mysql_error();
  59. exit();
  60. }
  61.  
  62. // wordpress' username that his password going to compare
  63. $user = 'test';
  64. $user_name = htmlspecialchars($user,ENT_QUOTES);
  65.  
  66. // plain password to compare
  67. $password = 'tespass';
  68.  
  69. $hasher = new PasswordHash(8, TRUE);
  70.  
  71. // get user_name's hashed password from wordpress database
  72. $queryx = "select * from wa1gty5f_users where user_login='$user_name'";
  73. $Resultx = mysql_query($queryx,$conn);
  74.  
  75. while($row = mysql_fetch_array($Resultx)){
  76. $passnya = $row[user_pass];
  77. }
  78.  
  79. // compare plain password with hashed password
  80. if ($hasher->CheckPassword( $password, $passnya )){
  81. echo "MATCHED";
  82. } else {
  83. echo "NO MATCHED";
  84. }
  85. ?>
  86.  
  87. <?php
  88.  
  89. $wp_hasher = new PasswordHash(8, TRUE);
  90.  
  91. $password_hashed = '$P$B55D6LjfHDkINU5wF.v2BuuzO0/XPk/';
  92. $plain_password = 'test';
  93.  
  94. if($wp_hasher->CheckPassword($plain_password, $password_hashed)) {
  95. echo "YES, Matched";
  96. } else {
  97. echo "No, Wrong Password";
  98. }
  99.  
  100. ?>
Add Comment
Please, Sign In to add comment