by axew3 » Tue Jan 14, 2020 10:42 am
The new plugin version is on release to fix this, so the
function wp_check_password($password, $hash, $user_id) { into
wp_w3all.php file,
will be switched (at moment but the function will be totally rewrite, even if it work fine as will be now)
to this:
Code: Select all
function wp_check_password($password, $hash, $user_id) {
global $wpdb,$wp_hasher;
$password = trim($password);
if( $user_id < 1 ){ return; }
$is_phpbb_admin = ( $user_id == 1 ) ? 1 : 0; // switch for phpBB admin // 1 admin 0 all others
$wpu_db_utab = (is_multisite()) ? WPW3ALL_MAIN_DBPREFIX . 'users' : $wpdb->prefix . 'users';
$wpu = $wpdb->get_row("SELECT * FROM $wpu_db_utab WHERE ID = '".$user_id."'");
if(!empty($wpu)){
$changed = WP_w3all_phpbb::check_phpbb_passw_match_on_wp_auth($wpu->user_login, $is_phpbb_admin);
if ( $changed !== false ){
$hash = $changed;
}
// If the hash is still md5...
if ( strlen($hash) <= 32 ) {
$check = hash_equals( $hash, md5( $password ) );
}
if( strpos($hash,'$argon2i') !== false ){
$check = password_verify($password, $hash);
$HArgon2i = true;
}
if ( !isset($check) OR $check !== true && !isset($HArgon2i) ){ // md5 check failed or not fired above ...
// new style phpass portable hash.
if ( empty($wp_hasher) ) {
require_once( ABSPATH . WPINC . '/class-phpass.php');
// By default, use the portable hash from phpass
$wp_hasher = new PasswordHash(8, true);
}
$check = $wp_hasher->CheckPassword($password, $hash); // WP check
}
if ($check !== true && strlen($hash) > 32 && !isset($HArgon2i)){ // Wp check failed ... check that isn't an md5 at this point before to follow or get PHP Fatal error in ... addons/bcrypt/bcrypt.php:111
require_once( WPW3ALL_PLUGIN_DIR . 'addons/bcrypt/bcrypt.php');
$password = htmlspecialchars($password);
$ck = new w3_Bcrypt();
$check = $ck->checkPassword($password, $hash);
}
if ($check === true){
if($wpu){
$phpBB_user_session_set = WP_w3all_phpbb::phpBB_user_session_set_res($wpu);
define("PHPBBCOOKIERELEASED", true); // then the session will be set on_login hook, if this filter bypassed
} else {
$check = false;
}
}
return apply_filters( 'check_password', $check, $password, $hash, $user_id );
} else {
return apply_filters( 'check_password', false, $password, $hash, $user_id );
}
}
endif;
The new plugin version is on release to fix this, so the
[c]function wp_check_password($password, $hash, $user_id) {[/c] into [i]wp_w3all.php[/i] file,
[b]will be switched[/b] (at moment but the function will be totally rewrite, even if it work fine as will be now) [b]to this[/b]:
[code]function wp_check_password($password, $hash, $user_id) {
global $wpdb,$wp_hasher;
$password = trim($password);
if( $user_id < 1 ){ return; }
$is_phpbb_admin = ( $user_id == 1 ) ? 1 : 0; // switch for phpBB admin // 1 admin 0 all others
$wpu_db_utab = (is_multisite()) ? WPW3ALL_MAIN_DBPREFIX . 'users' : $wpdb->prefix . 'users';
$wpu = $wpdb->get_row("SELECT * FROM $wpu_db_utab WHERE ID = '".$user_id."'");
if(!empty($wpu)){
$changed = WP_w3all_phpbb::check_phpbb_passw_match_on_wp_auth($wpu->user_login, $is_phpbb_admin);
if ( $changed !== false ){
$hash = $changed;
}
// If the hash is still md5...
if ( strlen($hash) <= 32 ) {
$check = hash_equals( $hash, md5( $password ) );
}
if( strpos($hash,'$argon2i') !== false ){
$check = password_verify($password, $hash);
$HArgon2i = true;
}
if ( !isset($check) OR $check !== true && !isset($HArgon2i) ){ // md5 check failed or not fired above ...
// new style phpass portable hash.
if ( empty($wp_hasher) ) {
require_once( ABSPATH . WPINC . '/class-phpass.php');
// By default, use the portable hash from phpass
$wp_hasher = new PasswordHash(8, true);
}
$check = $wp_hasher->CheckPassword($password, $hash); // WP check
}
if ($check !== true && strlen($hash) > 32 && !isset($HArgon2i)){ // Wp check failed ... check that isn't an md5 at this point before to follow or get PHP Fatal error in ... addons/bcrypt/bcrypt.php:111
require_once( WPW3ALL_PLUGIN_DIR . 'addons/bcrypt/bcrypt.php');
$password = htmlspecialchars($password);
$ck = new w3_Bcrypt();
$check = $ck->checkPassword($password, $hash);
}
if ($check === true){
if($wpu){
$phpBB_user_session_set = WP_w3all_phpbb::phpBB_user_session_set_res($wpu);
define("PHPBBCOOKIERELEASED", true); // then the session will be set on_login hook, if this filter bypassed
} else {
$check = false;
}
}
return apply_filters( 'check_password', $check, $password, $hash, $user_id );
} else {
return apply_filters( 'check_password', false, $password, $hash, $user_id );
}
}
endif;[/code]