Sarebbe incredibilmente semplice. È anche possibile registrare il valore della password tentata. Modifica la tua funzione di accesso in qualche modo, a seconda della lingua. 
  Ricorda, questo è uno pseudo codice non verificato, ma il concetto funzionerà : 
- 
 Coppia di elementi di sicurezza: 
private boolean properLength(String u, String p)
{
     return ((u.length > 3 && u.length <= 12) && (p.length > 8 && p.length <= 30)) ? true : false;
}
private boolean properFormat(String u, String p)
{
    return (regex.Valid(u, usernameRegex) && regex.Valid(p, passwordRegex)) ? true : false; 
}
private String stripBadStuff(String stuff)
{
    // Just in case or something...
    return EncodingFunction.ToASCII(stuff).regexReplace(badCharacaterRegex, ""); 
}
 
- 
 E il login: 
public String login(String user, String pass) 
{ 
   if (!loginTriesExceeded) // Currently unhandled for example.
   {
       if ((user != null && pass != null) && properLength(user, pass) && properFormat(user, pass))
       {
            if (!userLoginTriesExceeded)
            {
                // Strips potential hacker injection attempts. You may want to find another way to log this attempt. You wouldn't want to log this to a database without parameters/bound variables. That's beyond the scope of this answer. Google it.
                String newUser = stripBadStuff(user);
                String newPass = stripBadStuff(pass);
               // Would be changing DB.lookup() to return true if valid login is detected. DB.lookup(newUser,newPass) will now be assumed that it tests the plaintext password against the salted hash. 
                if (DB.lookup(newUser, newPass)) 
                { 
                    // Prevent injection. This will assume DB.lookup() tests the password against the stored hash.
                    return "Hello " + newUser; 
                }
                else 
                {
                    logInvalidAttempt(newUser, newPass);
                    return "Invalid login.";
                }
           }
           else
           {
                return "User login attempts exceeded.";
           }
        }
        else
        {
            return "Invalid login.";
        }
    }
    else
    {
        // Do nothing, or inform the visitor that they've exceeded max global logins based on their IP / cookie 
        return null;
    }
} 
 
 Dovresti semplicemente usare   logInvalidAttempt(user, pass);    quando fallisce. Quindi, invece di dire "login fallito", dovresti dire "login fallito"  e  registrare il tentativo, ma fai attenzione a non implementare alcun difetto di sicurezza con questo. Dovrai assicurarti che i dati siano inseriti correttamente. 
 In generale, solo la disinfezione dell'input non è la risposta, ma a volte la aggiungo come livello aggiuntivo dopo che tutto il resto è finito, per ogni evenienza. Non sempre, solo qualche volta. L'esempio qui è per scopi di apprendimento. 
 Ricorda che dovrai scrivere la tua funzione   logInvalidAttempt()   ; è troppo ampio per questa risposta. 
 Puoi farlo anche per  qualsiasi    Content Management System    come   joomla   ,   WordPress   ,   Drupal   ,   Django   , et al. Dopo tutto, sono open source. Quindi tutto ciò che devi fare è modificare la funzione di accesso appropriata. 
 Devi anche assicurarti che non vengano registrati troppi dati. Dovrai tagliarlo a un certo punto. 
  TLDR : 
-  Modifica la funzione login (). 
 
-  Quando l'utente tenta di accedere utilizzando credenziali non valide, registrarlo da qualche parte.
-  Se accedi a un database  SQL Server , parametrizza le tue query. 
 
-  Se accedi a un  database Oracle , collega le tue variabili e usa le istruzioni preparate. 
 
-  Se accedi a un  database MySQL , usa le istruzioni preparate e associa i tuoi parametri. 
 
-  Se lo si registra in un  file ,  o in qualsiasi database , non consentire l'inserimento di troppi dati. Devi tagliarlo a un certo punto. 
 
 
-  Leggi i registri / database.