SA-MP Forums Archive
Any password or no password accepted. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Any password or no password accepted. (/showthread.php?tid=516520)



Any password or no password accepted. - Stuffs - 31.05.2014

pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);

                TogglePlayerSpectating(playerid, false);
            }
My problem is this part:
pawn Код:
new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
Any password or no password allows you into the account.


Re: Any password or no password accepted. - Aerotactics - 31.05.2014

That boolean is the ignore case. When set to true, it ignores case sensitivity.

pawn Код:
if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],false)



Re: Any password or no password accepted. - Stuffs - 31.05.2014

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
That boolean is the ignore case. When set to true, it ignores case sensitivity.

pawn Код:
if(!strcmp(escapedPassword,PlayerInfo[playerid][pPass],false)
Still, any password is accepted.


Re: Any password or no password accepted. - Koala818 - 31.05.2014

Strcmp returns 0 if the strings you compare match and 1/-1 if they don't. So bassicaly if you introduce your good password you won't be able to login. Change the if condition
pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);

                TogglePlayerSpectating(playerid, false);
            }
https://sampwiki.blast.hk/wiki/Strcmp


Re: Any password or no password accepted. - Stuffs - 31.05.2014

Quote:
Originally Posted by Koala818
Посмотреть сообщение
Strcmp returns 0 if the strings you compare match and 1/-1 if they don't. So bassicaly if you introduce your good password you won't be able to login. Change the if condition
pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(strcmp(escapedPassword,PlayerInfo[playerid][pPass],true))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);

                TogglePlayerSpectating(playerid, false);
            }
https://sampwiki.blast.hk/wiki/Strcmp
Now nothing lets me log in. Even the correct password or no password.


Re: Any password or no password accepted. - Aerotactics - 31.05.2014

Quote:
Originally Posted by Koala818
Посмотреть сообщение
Strcmp returns 0 if the strings you compare match and 1/-1 if they don't. So bassicaly if you introduce your good password you won't be able to login.
Oh I misread that. Remove the exclamation point, and change your "true" to "false."


Re: Any password or no password accepted. - Stuffs - 31.05.2014

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
Oh I misread that. Remove the exclamation point, and change your "true" to "false."
Still the same, nothing allows me to login.

EDIT:
pawn Код:
if(dialogid == LOGIN_DIALOG)
    {
        if(!response)
        {
            ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
        }
        else
        {
            new escapedPassword[129];
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            if(strcmp(escapedPassword,PlayerInfo[playerid][pPass],false))
            {
                SendClientMessage(playerid, -1, "Incorrect Password Entered - Please try again.");
                ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_PASSWORD, "Login", "Type in your password", "Login", "Cancel");
            }
            else
            {
                LoadPlayer(playerid);
                format(GlobalString, sizeof(GlobalString), "Welcome "COL_LIGHTBLUE"%s!",GetName(playerid));
                SendClientMessage(playerid, -1, GlobalString);

                SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                mysql_format(sqldb, query, sizeof(query), "SELECT * FROM vehicles WHERE owner = '%s'", GetName(playerid));
                mysql_tquery(sqldb, query, "VehicleCheck", "i", playerid);

                TogglePlayerSpectating(playerid, false);
            }
        }
        return 1;
    }



Re: Any password or no password accepted. - Calgon - 31.05.2014

Add this code to check if [pPass] is not empty:

pawn Код:
printf("Password Length: %d", strlen(PlayerInfo[playerid][pPass]));



Re: Any password or no password accepted. - Stuffs - 31.05.2014

IT's reading 23. The hash is 24 characters long and my password is 6 in total.


Re: Any password or no password accepted. - Calgon - 31.05.2014

That isn't correct. pPass should be 129 characters (as WP_Hash hashes the string to 129 characters), and the newly hashed password should be 129 characters also... Are you actually using Whirlpool or have you just renamed a function?