[php]Login met eigen salt doet het niet??

Gestart doorFreestyle14 reacties14 weergaven

15 berichten · pagina 1 van 1

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een salt
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] salt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$max[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]15[/COLOR][COLOR= #007700]) {[/COLOR]
    [COLOR= #0000BB]$characterList[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"eigensaltcode"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/do"]do[/URL] [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$characterList[/COLOR][COLOR= #007700]{[/COLOR][URL="http://www.php.net/mt_rand"]mt_rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$characterList[/COLOR][COLOR= #007700]))};[/COLOR]
        [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;
    }[/COLOR] [URL="http://www.php.net/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]$max[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$salt[/COLOR][COLOR= #007700];
}[/COLOR]
?>
En als ik dan inlog met deze code:
Spoiler tonen
if (isset($_SESSION["user"])) { //check of sessie al bestaat
?>
                    <h1>OEPS!</h1>
                        <div class="text">
                            <span>U bent al ingelogd!</span>
                          </div>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    
 [COLOR= #0000BB]$verzend[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"verzend"[/COLOR][COLOR= #007700]];[/COLOR]
 [COLOR= #0000BB]$user[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"user"[/COLOR][COLOR= #007700]];[/COLOR]
 [COLOR= #0000BB]$wachtwoord[/COLOR] [COLOR= #007700]=[/COLOR] salt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700]]);[/COLOR]
 [COLOR= #0000BB]$ip[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]]);[/COLOR]
 
 [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$verzend[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user[/COLOR][COLOR= #007700]) &&[/COLOR]  [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$wachtwoord[/COLOR][COLOR= #007700])) {[/COLOR] [COLOR= #FF8000]//check of $user enzo wel bestaan[/COLOR]
     [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM `leden` WHERE gebruiker = "$user" AND wachtwoord = "$wachtwoord" AND rang > 1"[/COLOR][COLOR= #007700];[/COLOR]
     [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//voer sql uit[/COLOR]
     [COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//zet sql resultaten in array[/COLOR]
     
     [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"gebruiker"[/COLOR][COLOR= #007700]] &&[/COLOR] [COLOR= #0000BB]$wachtwoord[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700]]) {[/COLOR] [COLOR= #FF8000]//check of $user en wachtwoord overeenkomt[/COLOR]
       [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$user[/COLOR][COLOR= #007700];[/COLOR]
        
    
        
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO 
                            logs (gebruiker, ip, datum, waar, gelukt)
                     VALUES(
                             "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]",
                             "[/COLOR][COLOR= #007700].([/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]",
                            NOW(),
                            inloggen,
                            Gelukt
                            )"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
                                
?>       
                        <h1>Succes vol ingelogd</h1>
                        <div class="text">
                            <span>Succes vol ingelogd op VanMarijn</span>
                          </div>
                        <div class="text">
                        U bent succes vol ingelogd op VanMarijn. <br />
                        U word binnen 5seconden doorgestuurd.
                        </div>
<meta http-equiv="refresh" content="2;URL=index" />
 </p>
[COLOR= #0000BB]<?php[/COLOR]
     [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<h1>OEPS</h1>[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="text">[/COLOR][COLOR= #007700];[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je hebt foute gegevens ingevuld!<br>"[/COLOR][COLOR= #007700];[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href="javascript:history.back(1)">Klik hier om terug te gaan</a> of<br>"[/COLOR][COLOR= #007700];[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href="aanmelden">Registreer</a><Br>"[/COLOR][COLOR= #007700];[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();[/COLOR]
         [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];
     }
 }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
 
 ?>

            
                <h1>Login op VanMarijn</h1>
                        <div class="text">
                
   <form method="POST" action="#">
   <table width="100%">
       <tr >
           <td width="30%">Gebruikersnaam:</td><td><input type="text" name="user" class="form" /></td>
       </tr>
       <tr>
           <td>Wachtwoord:</td><td><input type="password" name="wachtwoord" class="form" /></td>
       </tr>
       <tr>
           <td><input type="submit" name="verzend" value="Login" title="Login in op VanMarijn" /></td><td></td>
       </tr>
       </table>
       </form>
                </p>

                </div>
                
                <h1>Aanmelden op VanMarijn</h1>
                <div class="text">
                Bent u nog geen lid op VanMarijn??<br />
                Meld je dan <a href="registreer" title="Registreer je op VanMarijn - Marijn Kok">hier</a> aan.
                </div>
                </
            
[COLOR= #0000BB]<?php[/COLOR]
 [COLOR= #007700]}
}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br /><br />[/COLOR][COLOR= #007700];[/COLOR]
banner[COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
Maar hij geeft steeds aan dat ik een van de velden niet goed heb ingevult.
Licht het aan de salt of aan het login script?
0
Fass

Lid

Berichten
3.771
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je salt moet natuurlijk wel altijd hetzelfde zijn. Als je registreerd en als je inlogt.
Bijvoorbeeld:
Ik typ bij het registreren als wachtwoord: one2xs
Dat zet hij dan zo in de database: sha1("one2xs" . "DitIsDeSalt");
Dan staat er in de database bijvoorbeeld: 9ked83ds7fj3d8g39djw38

Bij het inloggen moet ik dus het wachtwoord invoeren,
vul ik bijvoorbeeld versio in, dan komt er uit: sha1("versio" . "DitIsDeSalt");
oftewel: 32f3b832kfg0se4g9f. Omdat dat niet in de database staat, (maar 9ked83ds7fj3d8g39djw38) moet hij dan niet inloggen.
Als ik dan wel one2xs invoer komt er sha1("one2xs" . "DitIsDeSalt"); oftewel 9ked83ds7fj3d8g39djw38, en dan moet hij dus wel inloggen.

Echter, als de salt anders is komt er uit: sha1("one2xs" . "eenAndereSalt"); en dat is dan bijvoorbeeld 93bvi3ij3s38d9vk0sdf32s92, dan logt hij dus ook niet in.

Ik hoop dat je het begrijpt.
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Fassdfds schreef:
Je salt moet natuurlijk wel altijd hetzelfde zijn. Als je registreerd en als je inlogt.
Bijvoorbeeld:
Ik typ bij het registreren als wachtwoord: one2xs
Dat zet hij dan zo in de database: sha1("one2xs" . "DitIsDeSalt");
Dan staat er in de database bijvoorbeeld: 9ked83ds7fj3d8g39djw38

Bij het inloggen moet ik dus het wachtwoord invoeren,
vul ik bijvoorbeeld versio in, dan komt er uit: sha1("versio" . "DitIsDeSalt");
oftewel: 32f3b832kfg0se4g9f. Omdat dat niet in de database staat, (maar 9ked83ds7fj3d8g39djw38) moet hij dan niet inloggen.
Als ik dan wel one2xs invoer komt er sha1("one2xs" . "DitIsDeSalt"); oftewel 9ked83ds7fj3d8g39djw38, en dan moet hij dus wel inloggen.

Echter, als de salt anders is komt er uit: sha1("one2xs" . "eenAndereSalt"); en dat is dan bijvoorbeeld 93bvi3ij3s38d9vk0sdf32s92, dan logt hij dus ook niet in.

Ik hoop dat je het begrijpt.

Hmm oke, maar als ik registreer staat er wel een salt in de database.
En de salt is ook een functie dus normaal moet je dat doen.
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] salt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]$%T@#FR2r3r4ed@#$E@#R%[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]$#%Y45t3$##$%R$[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]%#$FR@#$EFR@#43[/COLOR][COLOR= #007700]);
}[/COLOR]
?>


Zo moet het.
0
Fass

Lid

Berichten
3.771
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo moet het helemaal niet persee? Je kan ook:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] salt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]){[/COLOR]
  [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"oD5-"[/COLOR][COLOR= #007700]));
}[/COLOR]
?>


En er zijn nog veel meer mogelijkheden..
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik bedoel gewoon dat het op zon soort manier moet in plaats van die manier van Freestyle wat niet eens kan werken.
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Freestyle heeft in zijn functie met voor salt een random staan, daardoor is de salt elke keer anders!
Elke X als je het oproept doet hij opnieuw random, dus heb je elke X een andere salt, en zal het wachtwoord dus nooit kloppen!
Je moet alleen constante waardes gebruiken
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Eleky schreef:
Freestyle heeft in zijn functie met voor salt een random staan, daardoor is de salt elke keer anders!
Elke X als je het oproept doet hij opnieuw random, dus heb je elke X een andere salt, en zal het wachtwoord dus nooit kloppen!
Je moet alleen constante waardes gebruiken
Oo, bedankt eleky.

@fassdfds: Ik wil geen md5 etc, gebruiken
@wiitse: Ik denk dat ik opnieuw een funcite ga schrijven zonder random.
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] salt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR]hash[COLOR= #007700]([/COLOR][COLOR= #DD0000]sha256[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/base64_encode"]base64_encode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Ghsid$71$51*15!@([/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]^&(*HGfvhdg!$&UT*%fgsuGFhhjdsvH#7%^&33![/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]!#^%gsdvghgsBNFDjhdstcjgbsdyHDFHSjh#@%#&#$#@!!$^^%&[/COLOR][COLOR= #007700]))));
}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] salt[COLOR= #007700]([/COLOR][COLOR= #DD0000]Jeffrey[/COLOR][COLOR= #007700]);[/COLOR]
?>


Knappe kop als je die kan kraken.
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jponsen schreef:
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] salt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR]hash[COLOR= #007700]([/COLOR][COLOR= #DD0000]sha256[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/base64_encode"]base64_encode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Ghsid$71$51*15!@([/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]^&(*HGfvhdg!$&UT*%fgsuGFhhjdsvH#7%^&33![/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]!#^%gsdvghgsBNFDjhdstcjgbsdyHDFHSjh#@%#&#$#@!!$^^%&[/COLOR][COLOR= #007700]))));
}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] salt[COLOR= #007700]([/COLOR][COLOR= #DD0000]Jeffrey[/COLOR][COLOR= #007700]);[/COLOR]
?>
Knappe kop als je die kan kraken.

Maar je hebt zon triplemega password encoder helemaal niet nodig?
Qua veiligheid zal het met een extra hash erdoor ook niet veel verschillen lijkt mij.
Gewoon zorgen dat niemand achter die leuke salt komt
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Klopt, maar de mijne is sowieso wel veilig yummie
0
Fass

Lid

Berichten
3.771
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Net zo veilig als die van mij of van Wiitse...
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb die van wiitse en hij doet het nog niet??
Ik heb me opnieuw geregistreerd. En de goede file op de host gezet.
0
Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is de maximale lengte in de database wel lang genoeg?
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Die heb ik gewoon varchar 255 gedaan. Moet ik hem anders tekst doenxd
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren