Encrypting met Whirlpool-probleem

Gestart doorJacmob13 reacties9 weergaven

14 berichten · pagina 1 van 1

Jacmob

Lid · Topicstarter

Berichten
916
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ik ben gestopt met die xenforo login (teveel werk)

nu is het dus gelukt om van een minecraft plugin die op mijn server word gebruikt te connecte met het login script van mijn website nu is er alleen een probleem : de encrypting

de wachtwoorden worden dus omgezet in whirepool
https://github.com/CypherX/xAuth/wiki/Password-Hashing
(onderaan)

nu wil ik dat dus invoegen in mijn login script
http://www.phpeasystep.com/phptu/6.html (dit login systeem gebruik ik )

alleen nu mijn vraag ik weet niet hoe ik die whirepool ding erin moet krijgen en op welke plek

~jacmob

//sjoerdedit: Titel aangepast.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Pas je titel even aan.. Zulke nonsens hoort niet in een titel.

Wat heb je al geprobeerd? Een snelle blik levert me een functie op die je in een vergelijking kan gebruiken.
0
Jacmob

Lid · Topicstarter

Berichten
916
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ik heb de encrypting

function encryptPassword($password) {
    $salt = substr(hash(whirlpool, uniqid(rand(), true)), 0, 12);
    $hash = hash(whirlpool, $salt . $password);
    $saltPos = (strlen($password) >= strlen($hash) ? strlen($hash) : strlen($password));
    return substr($hash, 0, $saltPos) . $salt . substr($hash, $saltPos);
}


in de config gezet (checklogin.php maar dat werkte dus niet
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Omdat je de functie ook niet aanroept:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] encryptPassword[COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]) {[/COLOR]
    [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR]hash[COLOR= #007700]([/COLOR][COLOR= #DD0000]whirlpool[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/uniqid"]uniqid[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700](),[/COLOR] true[COLOR= #007700])),[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]12[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$hash[/COLOR] [COLOR= #007700]=[/COLOR] hash[COLOR= #007700]([/COLOR][COLOR= #DD0000]whirlpool[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$password[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$saltPos[/COLOR] [COLOR= #007700]= ([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]) >=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700]) ?[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700]) :[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]));[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$saltPos[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$saltPos[/COLOR][COLOR= #007700]);
}[/COLOR]

encryptPassword[COLOR= #007700]([/COLOR][COLOR= #DD0000] hier het wachtwoord[/COLOR][COLOR= #007700]);[/COLOR]
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En heb je de functie ook aangeroepen? laat je ***relevante*** code eens zien.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php

$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Host name [/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql username [/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Mysql password [/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"test"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Database name [/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"members"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// Table name 

// Connect to server and select databse.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$host"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"$username"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"$password"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$db_name"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);

function[/COLOR] encryptPassword[COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]) {[/COLOR]
    [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR]hash[COLOR= #007700]([/COLOR][COLOR= #DD0000]whirlpool[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/uniqid"]uniqid[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700](),[/COLOR] true[COLOR= #007700])),[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]12[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$hash[/COLOR] [COLOR= #007700]=[/COLOR] hash[COLOR= #007700]([/COLOR][COLOR= #DD0000]whirlpool[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$password[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$saltPos[/COLOR] [COLOR= #007700]= ([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]) >=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700]) ?[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700]) :[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]));[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$saltPos[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #0000BB]$salt[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hash[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$saltPos[/COLOR][COLOR= #007700]);
}[/COLOR]



[COLOR= #FF8000]// username and password sent from form [/COLOR]
[COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]myusername[/COLOR][COLOR= #007700]];[/COLOR] 
[COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]=[/COLOR] encryptPassword[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]mypassword[/COLOR][COLOR= #007700]]);[/COLOR] 

[COLOR= #FF8000]// To protect MySQL injection (more detail about MySQL injection)[/COLOR]
[COLOR= #0000BB]$myusername[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$mypassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$myusername[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$mypassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT * FROM $tbl_name WHERE username=$myusername and password= $mypassword"[/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]// Mysql_num_row is counting table row[/COLOR]
[COLOR= #0000BB]$count[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]// If result matched $myusername and $mypassword, table row must be 1 row[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]

[COLOR= #FF8000]// Register $myusername, $mypassword and redirect to file "login_success.php"[/COLOR]
[URL="http://www.php.net/session_register"]session_register[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"myusername"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/session_register"]session_register[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mypassword"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"location:login_success.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]"Wrong Username or Password"[/COLOR][COLOR= #007700];
}[/COLOR]
?>


zoiets yummie
toevoeging op 5 augustus 2012, 14:21:06:
Oh wait.

toevoeging op 5 augustus 2012, 14:22:00:
Zo!
0
Jacmob

Lid · Topicstarter

Berichten
916
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
moet ik die code ook gewoon in checklogin zetten of niet?

aarclay kijk de 2 links in begin post de onderste is de login script nog precies yummie
dylanh nop werkt niet yummie
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Jacmob schreef:
moet ik die code ook gewoon in checklogin zetten of niet?

aarclay kijk de 2 links in begin post de onderste is de login script nog precies yummie
dylanh nop werkt niet yummie
Dat is checklogin.php

maar waarschijnelijk werkt dit niet nee. maar dat komt zeker om dat je in de tabel password gewoon je wachtwoord hebt staan dus doe even dit:

function encryptPassword($password) {
$salt = substr(hash(whirlpool, uniqid(rand(), true)), 0, 12);
$hash = hash(whirlpool, $salt . $password);
$saltPos = (strlen($password) >= strlen($hash) ? strlen($hash) : strlen($password));
return substr($hash, 0, $saltPos) . $salt . substr($hash, $saltPos);
}

echo encryptPassword(doe hier jou wachtwoord);
?>

dan krijg je een code te zien en zet je die in die colom password en try dan again biggrin
0
Jacmob

Lid · Topicstarter

Berichten
916
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
gedaan en werkt niet yummie
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
wat werkt er dan niet?
0
Jacmob

Lid · Topicstarter

Berichten
916
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hij zegt telkens foute pass terwel de pass gewoon zelfde is de password zijn in de database in het whirlpools dus voglens mij meot de pass decrypted worden zodat de login script hem herkent
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Afbeelding

Welke zie je bij je db? Gewoon jou wachtwoord of die andere code?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Wat een verouderd script:

session_register("myusername");
session_register("mypassword");


Deze zijn bejaard, man.

toevoeging op 5 augustus 2012, 14:34:46:
Jacmob schreef:
moet ik die code ook gewoon in checklogin zetten of niet?
aarclay kijk de 2 links in begin post de onderste is de login script nog precies yummie
dylanh nop werkt niet yummie
Kan je ook wat duidelijker typen, en je interpuncties eens gebruiken in het vervolg?
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