Trying to verify wordpress password hash with phpass

I have a Wordpress hashed password database. I am trying to verify a user password for a stored database password, but the hashes are not correct. I am using this github code with some input in isMatch() . Any ideas why these passwords don't match? plaintext password alberta10

  public boolean isMatch(String password, String storedHash) { // The first 12 digits of the hash is used to modify the encryption. String setting = storedHash.substring(0, 12); logger.log(Level.INFO, "----Hashed pwd from db is: "+storedHash); logger.log(Level.INFO, "----Hashed pwd using php-pass: "+encrypt(password, setting)); return storedHash.equals(encrypt(password, setting)); } 

Here is my authenticate() method

 private void authenticate(String username, String password) throws Exception { // Throw an Exception if the credentials are invalid PasswordHasher pwdHasher=new PasswordHasher(); _logger.log(Level.INFO, "----Authenticating user: "+username); try{ Connection conn=authenticationBiz.connWordpressDB(); String query = "SELECT * FROM wp_users WHERE user_login = ?"; PreparedStatement preparedStmt = conn.prepareStatement(query); preparedStmt.setString(1, username); ResultSet rs=preparedStmt.executeQuery(); rs.next();//get first result _logger.log(Level.INFO, "----Hashed pwd from db is: "+rs.getString("user_pass")); if(pwdHasher.isMatch(password,rs.getString("user_pass"))) return; } catch(Exception e){ _logger.log(Level.INFO, "----Exception in Authenticating user: "+e); throw e; } throw new Exception(); } 

Here is the log output:

 ----Hashed pwd from db is: $P$BeatnTVG2/U8KZwpaWbPUF4yghHEKf. 17:21:40,997 INFO [com.mollom.phpass] (default task-37) ----Hashed pwd from db is: $P$BeatnTVG2/U8KZwpaWbPUF4yghHEKf. ----Hashed pwd using php-pass: $P$BeatnTVG2etvrth3rlCUdiNRm93PO9xZjXNr1f5s8izUZFfIq70V 
+5
source share
2 answers

Turns out I used a Github project that did not meet the original criteria used to generate the hashes. I found: https://github.com/Wolf480pl/PHPass , which worked great

+2
source

Wordpress uses 8 hash iterations, the git chain you are associated with that uses 15 iterations, maybe you can’t just reduce the number of hash iterations defined in the HASH_ITERATIONS constants.

+1
source

Source: https://habr.com/ru/post/1271436/


All Articles