[RELEASE]Encrypted login strore without file

10/04/2012 12:25 d3m0n3#1
hi,

inspired by the recent discussion in which I was criticized, I rewrote the code for saving login data making significant changes.
In this new version of login files are not used for data storage, at frist use two keys are created randomly and stored in the system registry these are used to crypt the login data which are also saved in system registry

Note: for right work need to use lib in the attachment. All is tested on Win7 32/64 bit
Who want to discuss other work can create a discussion without make flame here thanks.

Code:
import os
import sys
import string
from _winreg import *

	def __OnClickSaveButton(self):	
		id = self.idEditLine.GetText()
		pwd = self.pwdEditLine.GetText()
		self.__SaveAccountInfo(id, pwd)

	def __SaveAccountInfo(self, user, passw):
		try:
			userid = self.__encrypt(user).replace(' ', '-')
			passwd = self.__encrypt(passw).replace(' ', '-')
			aReg = ConnectRegistry(None, HKEY_CURRENT_USER)
			aKey = CreateKey(aReg, "software\\MyClientName\\")
			SetValueEx(aKey, "user", 0, REG_SZ, userid)
			SetValueEx(aKey, "pass", 0, REG_SZ, passwd)
			CloseKey(aKey)
			CloseKey(aReg)
			self.PopupNotifyMessage("Info: Dati di Login salvati.")
		except:
			self.PopupNotifyMessage("Info: Errore Salvataggio dati di Login.")
			return

	def __LoadAccountInfo(self):
		try:
			login_data = os.popen('reg QUERY "HKEY_CURRENT_USER\software\MyClientName" /v user').readlines()
			login_line = login_data[2].split()
			login_value = login_line[2].replace('-', ' ').strip('\n')
			passw_data = os.popen('reg QUERY "HKEY_CURRENT_USER\software\MyClientName" /v pass').readlines()
			passw_line = passw_data[2].split()
			passw_value = passw_line[2].replace('-', ' ').strip('\n')
			
			user=self.__decrypt(login_value)
			passw=self.__decrypt(passw_value)
				
			return user, passw

		except:
			print "LoginWindow.__LoadAccountInfo - OpenError"
			return -1, -1
			
	def __encrypt(self, string):
		aReg = ConnectRegistry(None, HKEY_CURRENT_USER)
		try:
			aKey = OpenKey(aReg, "software\\MyClientName\\")
		except WindowsError:
			try:
				key1_value = app.GetRandom(1,127)
				key2_value = app.GetRandom(1,32768)
				aKey = CreateKey(aReg, "software\\MyClientName\\")
				SetValueEx(aKey, "key1", 0, REG_DWORD, key1_value)
				SetValueEx(aKey, "key2", 0, REG_DWORD, key2_value)
				CloseKey(aKey)
				CloseKey(aReg)
			except:
				CloseKey(aReg)
				return
				
		key1_data = os.popen('reg QUERY "HKEY_CURRENT_USER\software\MyClientName" /v key1').readlines()
		key1_line = key1_data[2].split()
		key1_value = int(key1_line[2], 16)
		key2_data = os.popen('reg QUERY "HKEY_CURRENT_USER\software\MyClientName" /v key2').readlines()
		key2_line = key2_data[2].split()
		key2_value = int(key2_line[2], 16)
		
		a = string
		new_string = ''
		for x in a:
			new_string = new_string+str(int(ord(x) + key1_value) * key2_value)+' '
			
		return new_string
		
	def __decrypt(self, string):
		aReg = ConnectRegistry(None, HKEY_CURRENT_USER)
		try:
			aKey = OpenKey(aReg, "software\\MyClientName\\")
		except WindowsError:
			CloseKey(aReg)
			return
			
		CloseKey(aKey)
		CloseKey(aReg)
		key1_data = os.popen('reg QUERY "HKEY_CURRENT_USER\software\MyClientName" /v key1').readlines()
		key1_line = key1_data[2].split()
		key1_value = int(key1_line[2], 16)
		key2_data = os.popen('reg QUERY "HKEY_CURRENT_USER\software\MyClientName" /v key2').readlines()
		key2_line = key2_data[2].split()
		key2_value = int(key2_line[2], 16)
		
		a = string
		new_string = ''
		b = a.split()
		for x in b:
			new_string = new_string+chr((int(x) / key2_value) - key1_value)
			
		return new_string
enjoy

d3m0n3
10/04/2012 12:29 almobd3#2
thanks
10/04/2012 13:14 CranK™#3
Still a file :awesome:
10/04/2012 13:39 d3m0n3#4
Quote:
Originally Posted by CranK™ View Post
Still a file :awesome:
yes, but we must know the system registry where it is stored for read the data and there are also encrypted i think is safer than having it in the root of the client .
we must remember which are talking about data access for a game not for a bank :D
10/04/2012 14:46 IgorGlock#5
I can read this *shit?*...
[Only registered and activated users can see links. Click Here To Register...]

Registry ist a good try, but not safe. By the way, u can safe something else and connect with another pass... :)
10/04/2012 15:11 d3m0n3#6
frankly I'm tired of kids who are whining because their ass burns

if you have constructive comments good otherwise I avoid even respond to these bla bla bla

N.b.: everyone are good to say this shit and that shit

have a nice day

d3m0n3
10/04/2012 15:44 [Patrick]#7
Nice thanks :awesome:
10/04/2012 17:21 .Secresy'#8
war das nicht schon public?
10/05/2012 11:42 ReckLess.#9
Nicht pub, so nur kritisieren beginnen zu schätzen.
05/03/2017 23:07 thehero09#10
How can i add it on my client ?