• Home
  • Geocoding
  • Nieuws
  • Contact
BackuPs.NL
  • Geocoding
  • News
    • Fiat
    • Grappige zaken
    • Software
    • Video’s
    • Wordpress
  • Contact Us
  • Geocoding
  • News
    • Fiat
    • Grappige zaken
    • Software
    • Video’s
    • Wordpress
  • Contact Us

Wordpress revealing username by login trial and error

6 maart 2014|Internet, Wordpress|admin, loginname
Wordpress  revealing username by login trial and error
Security Problem : In any wordpress version it is possible to get a valid loginname by trial and error by the use of the login screen.

What happens that in case you enter a wrong username that username is removed after the login attempt. However if you enter a correct username that username stays visible in the login screen.

Both attempts also generate a different error message explaining that you either provided the wrong username and or password or the wrong password. In the latter case wordpress indirectly is telling you that you entered the valid and correct username (stupid if i may say so).

All is caused by this piece of code in the wp-login.php where it checks the error message and depending on that error message keeps or removes the username, making it possible to reveal a valid username.

if ( isset($_POST['log']) ) $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : '';
Top
How to deal with this?

1) We have to tell WordPress a different error message on a false login

First we add a filter to the authentication and within that filter we change the error report status.

Instead of “invalid password” we return “invalid username” and thus misleading the wordpress system so it removes the username from the login screen when either a incorrect password or username is entered.

To accomplish the trick you have to add the code below to the theme functions.php

/* Change the wordpress login error message on incorrect password only */ function wp_modify_login_error_incorrect_password($user) { if ( is_wp_error( $user ) ) { $error_string = $user->get_error_message(); if ($user->get_error_code()=='incorrect_password') { $user = new WP_Error( 'invalid_username', $error_string); } } return $user; } add_filter('authenticate', 'wp_modify_login_error_incorrect_password', 25, 1);

The only difference to the original wordpress code is that we tell the login-screen that although we have a incorrect_password that we have a invalid_username. And that is exactly the only change we make to the error code returned (below is a image with the original and changed code to explain the trick).

Note : The original code is located in the \wp-includes\user.php starting around line 71.

The wordpress login-screen error message trick
The wordpress login-screen error message trick
Top
2) Change the error notifications so they don’t reveal information.

Changing that error code alone however is still not enough. WordPress still reveals the correct username by the error message it presents on return and thus giving the attacker just enough information he needs to discover a valid username.  So altering the error message to a message that does not reveal any information is advisable.

We have two ways todo this, either we remove the complete message (solution 2a) or we change the message into a generic one (solution 2b).

2a) Removing the default login error messages.

This requires to add this filter to your theme functions.php

add_filter('login_errors',create_function('$a', "return null;"));

2b) Changing the login error messages both into a generic one.

For changing the login error-message to a generic requires to add this filter to the theme functions.php

function error_message_failed_login() { return 'The login information entered is incorrect.'; } add_filter('login_errors', 'error_message_failed_login');
Top
3) Optional you can hide the remember me checkbox from the wp-login form

The next step is to hide the remember me checkbox from the loginscreen for which you need to add this to the theme functions.php

add_action('login_head', 'remove_remember_me'); function remove_remember_me() { echo '<style type="text/css">.forgetmenot { display:none; }</style>' . "\n"; }
Top
Now let us put all into a plugin.

Of course you can create a plugin with all these code changes in it. Create a php file from the code below and upload the plugin into a subfolder of the wordpress plugins folder.

<?php /* Plugin Name: WP Modify Login Error Message Plugin URI: http://www.backups.nl/ Description: Wordpress Modify Login Error Message. Modify the login error message result to prevent WordPress from revealing a valid login name (admin) Version: 1.0 Author: BackuPs Author URI: http://www.backups.nl/ Email Address : my email address License: GPL2 */ /* change default login error message */ function error_message_failed_login() { return 'The login information entered is incorrect.'; } add_filter('login_errors', 'error_message_failed_login'); /* remove the remember me checkbox from the login screen*/ function remove_remember_me() { echo '<style type="text/css">.forgetmenot { display:none; }</style>' . "\n"; } add_action('login_head', 'remove_remember_me'); /* Change the wordpress login error message on incorrect password only */ function wp_modify_login_error_incorrect_password($user) { if ( is_wp_error( $user ) ) { $error_string = $user->get_error_message(); if ($user->get_error_code()=='incorrect_password') { $user = new WP_Error( 'invalid_username', $error_string); } } return $user; } add_filter('authenticate', 'wp_modify_login_error_incorrect_password', 25, 1); ?>
Top
Side note : In wordpress you can easily change the admin id to a name which is less hackable. But did you know this is of no use unless you have a huge user database with loads of dummy users in which you can hide your admin?

I have seen many video’s and instructions telling you to create a new admin, login and delete the old admin. Video’s that instruct you to create a admin with a name like ‘youdonotfindme’. Plugins like “Better WP Security” suggesting you to change the id and name. And they are all right to some extend. But the thing is that as long as your author pages can be called and you wrote articles with the admin username they are able to find you!! (even if the admin did not write a single article).

How to fix that you can read here : WordPress changing the Admin ID / Hiding author pages

Top
5 september 2020 BackuPs

Recent News

  • Configuring Virtual Hosts on Xampp – How to Run Multiple Domains
    Configuring Virtual Hosts on Xampp – How to Run Multiple Domains 4 januari 2016

    There are more then one tutorial on the internet on how to configure Xampp to ru...

  • Why am I Not Getting the Windows 10 November 2015 Update? Install it manually?
    Why am I Not Getting the Windows 10 November 2015 Update? Install it manually? 23 december 2015

    Beginning november 2015 Microsoft released the first major update for Windows 10...

  • Google mobile friendly misleads Webmasters
    Google mobile friendly misleads Webmasters 22 maart 2015

    Google was recently sending me messages in my webmaster account that my website...

  • Wordpress changing the admin-ID or hide author pages?
    Wordpress changing the admin-ID or hide author pages? 8 oktober 2013

    In wordpress you can easily change the admin id to a name which is less hackable...

  • Fiat Punto Evo, Grande Punto, Punto probleem ruitensproeier / ruitenwisser
    Fiat Punto Evo, Grande Punto, Punto probleem ruitensproeier / ruitenwisser 12 maart 2012

    Punto, Grande Punto, Punto Evo Fiat heeft een aantal auto’s op de markt ge...

Tag cloud

bankieren Muziek Grande Punto Stealth Fabrieksfout Fiat Carabao Youtube Internet Probleem Problemen admin Caelo Loso aziaten hacken Grappig Sek Loso Outlook Software Raadsel Punto Animatie Surfing Voorruit Invisible westerlingen Fabricagefout Thaise authorisatie Thai loginname Funstuff Evo Ruitensproeier Ontwerpfout admin id Video

Laatste nieuws

  • Configuring Virtual Hosts on Xampp – How to Run Multiple Domains
    Configuring Virtual Hosts on Xampp – How to Run Multiple Domains

    There are more then one tutorial on the internet on how to configure Xampp to ru...

  • Why am I Not Getting the Windows 10 November 2015 Update? Install it manually?
    Why am I Not Getting the Windows 10 November 2015 Update? Install it manually?

    Beginning november 2015 Microsoft released the first major update for Windows 10...

  • Google mobile friendly misleads Webmasters
    Google mobile friendly misleads Webmasters

    Google was recently sending me messages in my webmaster account that my website...

Tag cloud

authorisatie Ruitensproeier admin Ontwerpfout Muziek Punto Funstuff Loso Software Sek Loso admin id Internet Thai hacken Evo Carabao Probleem Surfing Raadsel westerlingen Thaise Fiat Voorruit loginname Fabricagefout Outlook Video Youtube Problemen Grande Punto Grappig Caelo aziaten Invisible bankieren Fabrieksfout Stealth Animatie

Popular News

  • Fiat Punto Evo, Grande Punto, Punto probleem ruitensproeier / ruitenwisser
    Fiat Punto Evo, Grande Punto, Punto probleem ruitensproeier / ruitenwisser 12 maart 2012
  • Westerlingen versus Aziaten
    Westerlingen versus Aziaten 30 november 2011
  • Het mysterie van de deur
    Het mysterie van de deur 30 november 2011
Volg mij via EmailVolg mij via X
Copyright
webontwerp door BackuPs