[SRC]Salt-System

02/09/2016 13:36 blackout85#1
Da ein kleiner Hobbit meint er könnte mich ärgern werde ich ihn eines besseren belehren...

Was ist ein Saltsystem? Diese Frage ist leicht beantwortet.

[Only registered and activated users can see links. Click Here To Register...]

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);
und ersetzen durch:
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);
db.cpp

suchen nach:
Code:
#include <sstream>
darunter einfügen:
Code:
#include "sha1.h"// new hash
#include "md5.h"// new hash
dann hiernach suchen:
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;;
und hiermit ersetzen:
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;
suchen:
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));
und ersetzen mit dem hier:
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;
	}
suchen nach:
Code:
	nPasswordDiff = strcmp(szEncrytPassword, szPassword);
und ersetzen durch:
Code:
	// new hash
	szEncrytPassword.append(sha1(szSalt));
	szEncrytPassword.append(md5(pinfo->passwd));

	int nPasswordDiff = strcmp(md5(szEncrytPassword).c_str(), szPassword);
ladet die 4 Daten aus dem Anhang game_src.rar in den game src:
Quote:
sha1.h
sha1.cpp
md5.h
md5.cpp
öffnet die Makefile und fügt "sha1.cpp md5.cpp" dem CPPFILE define hinzu.

nun muss der Datenbank account.account noch das Feld salt hinzugefügt werden:
Quote:
salt varchar(45) NOT NULL DEFAULT ''
und dann könnt ihr Kompilieren.

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);

das Passwort hasht ihr in diesem Fall so:
PHP Code:
$pw md5(sha1($salt).md5($pw)) 
Oben im Code ist nur ein Beispiel, es geht natürlich nach Lust und Laune.

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));
oder auch:

Code:
	szEncrytPassword.append(sha1(szSalt));
	szEncrytPassword.append(md5(pinfo->passwd));
	szEncrytPassword.append(sha1("PwGehtSoNurAufMeinemServer"));
viel Spaß damit ;)

für die im Code beschriebene Variante habe ich euch noch ein PWGen beigelegt damit ihr es direkt testen könnt.

lg black
02/09/2016 14:12 BizepsSupportAccount#2
was istn das fürn system?..

€dit: hat sich geklärt habs beim überflogen nicht gesehen.

nice danke!
02/09/2016 15:22 worldend#3
Nice one. Thx
02/09/2016 15:22 .Various#4
Stellt sich nur die Frage, was hat das Ganze mit Salz zutun?

Spaß beiseite, schönes Release, danke. Werden wir ja wie schon gesagt benutzen! :)
02/09/2016 15:35 DeadBreakZz#5
Sehr cool
02/09/2016 16:24 galetlefrancais#6
Danke für der guide

Aber ich benutze ein methode mit cryptopp :D

Thanks for the tutorial, However I'm using a method with cryptopp, but your method is still really usefull because you're using salt + md5 in addition of sha1

Carry on men !
02/11/2016 12:17 #Metho#7
Quote:
Originally Posted by galetlefrancais View Post
Danke für der guide

Aber ich benutze ein methode mit cryptopp :D

Thanks for the tutorial, However I'm using a method with cryptopp, but your method is still really usefull because you're using salt + md5 in addition of sha1

Carry on men !
Wo sollte den der Unterschied zu Crypto++ sein?^^

Gutes Release, ich hoffe der Ein oder Andere lernt was draus.