Was ist ein Saltsystem? Diese Frage ist leicht beantwortet.
Man hat einmal das Passwort und einen einmaligen String aus Zahlen und Buchstaben. Damit ist sichergestellt das der Hash des Passwortes immer unterschiedlich ist auch wenn das eigentliche Passwort das selbe ist.
Nutzt man diese Methode, so sind Hashdatenbanken nutzlos und man erzielt da keinen Fund des original Passworts.
Denkt vorher an ein Backup!
input_auth.cpp
suchen nach:
Code:
DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,
"SELECT PASSWORD('%s'),password,securitycode,social_id,id,status,availDt - NOW() > 0,"
"UNIX_TIMESTAMP(silver_expire),"
"UNIX_TIMESTAMP(gold_expire),"
"UNIX_TIMESTAMP(safebox_expire),"
"UNIX_TIMESTAMP(autoloot_expire),"
"UNIX_TIMESTAMP(fish_mind_expire),"
"UNIX_TIMESTAMP(marriage_fast_expire),"
"UNIX_TIMESTAMP(money_drop_rate_expire),"
"UNIX_TIMESTAMP(create_time)"
" FROM account WHERE login='%s'",
szPasswd, szLogin);
Code:
DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p, "SELECT password,salt,securitycode,social_id,id,status,availDt - NOW() > 0," "UNIX_TIMESTAMP(silver_expire)," "UNIX_TIMESTAMP(gold_expire)," "UNIX_TIMESTAMP(safebox_expire)," "UNIX_TIMESTAMP(autoloot_expire)," "UNIX_TIMESTAMP(fish_mind_expire)," "UNIX_TIMESTAMP(marriage_fast_expire)," "UNIX_TIMESTAMP(money_drop_rate_expire)," "UNIX_TIMESTAMP(create_time)" " FROM account WHERE login='%s'", szLogin);
suchen nach:
Code:
#include <sstream>
Code:
#include "sha1.h"// new hash #include "md5.h"// new hash
Code:
char szEncrytPassword[45 + 1]; char szPassword[45 + 1]; char szMatrixCode[MATRIX_CODE_MAX_LEN + 1]; char szSocialID[SOCIAL_ID_MAX_LEN + 1]; char szStatus[ACCOUNT_STATUS_MAX_LEN + 1]; DWORD dwID = 0;;
Code:
// new hash std::string szEncrytPassword;// new hash char szPassword[45 + 1]; char szSalt[45 + 1]; char szMatrixCode[MATRIX_CODE_MAX_LEN + 1]; char szSocialID[SOCIAL_ID_MAX_LEN + 1]; char szStatus[ACCOUNT_STATUS_MAX_LEN + 1]; DWORD dwID = 0;
Code:
strlcpy(szEncrytPassword, row[col++], sizeof(szEncrytPassword));
if (!row[col])
{
sys_err("error column %d", col);
M2_DELETE(pinfo);
break;
}
strlcpy(szPassword, row[col++], sizeof(szPassword));
Code:
strlcpy(szPassword, row[col++], sizeof(szPassword));
strlcpy(szSalt, row[col++], sizeof(szSalt));
if (!row[col])
{
sys_err("error column %d Salt", col);
M2_DELETE(pinfo);
break;
}
Code:
nPasswordDiff = strcmp(szEncrytPassword, szPassword);
Code:
// new hash szEncrytPassword.append(sha1(szSalt)); szEncrytPassword.append(md5(pinfo->passwd)); int nPasswordDiff = strcmp(md5(szEncrytPassword).c_str(), szPassword);
öffnet die Makefile und fügt "sha1.cpp md5.cpp" dem CPPFILE define hinzu.Quote:
sha1.h
sha1.cpp
md5.h
md5.cpp
nun muss der Datenbank account.account noch das Feld salt hinzugefügt werden:
und dann könnt ihr Kompilieren.Quote:
salt varchar(45) NOT NULL DEFAULT ''
Für eure Webseite müsst ihr je einen Salt pro Account erzugen zb so (und in der account.account->salt speichern):
PHP Code:
function get_salt()
{
$characters = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$characters_length = strlen($characters) - 1;
$rand = '';
for ($i = 0; $i < 45; $i++)
{
$rand .= $characters[mt_rand(0, $characters_length)];
}
return md5($rand);
}
PHP Code:
$pw = md5(sha1($salt).md5($pw))
Hier einmal ein übertriebenes Beispiel:
Code:
szEncrytPassword.append(sha1(szSalt)); szEncrytPassword.append(sha1(szSalt)); szEncrytPassword.append(sha1(szSalt)); szEncrytPassword.append(sha1(szSalt)); szEncrytPassword.append(sha1(szSalt)); szEncrytPassword.append(md5(pinfo->passwd));
Code:
szEncrytPassword.append(sha1(szSalt));
szEncrytPassword.append(md5(pinfo->passwd));
szEncrytPassword.append(sha1("PwGehtSoNurAufMeinemServer"));
für die im Code beschriebene Variante habe ich euch noch ein PWGen beigelegt damit ihr es direkt testen könnt.
lg black






