Ejemplo n.º 1
0
def login_accept(mother_win, username, psswrd):
	secure_connection = db.connect('secure.db')

	# Attempt secure user validation
	seed = hashlib.sha224(('%s%s' % (username, psswrd)).encode('utf-8')).hexdigest()
	fruit = hashlib.sha224(psswrd.encode('utf-8')).hexdigest()
	harvest_fruit = db.read(secure_connection, '002', seed)
	db.close(secure_connection)
	if harvest_fruit:
		harvest_fruit = harvest_fruit[0]
		if harvest_fruit[1] == fruit:
			# Update logs and update key
			fb = db.read(LOGS_CONNECTION, '003')[0][0]
			if fb == None:
				fb = 0
			else:
				fb += 1
			items = \
				'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'.split(',')
			random.shuffle(items)
			rnd = ''.join(items)
			sd = (fb, str(datetime.date.today()), username, rnd)
			db.write(LOGS_CONNECTION, '003', sd)
			db.close(LOGS_CONNECTION)
			with open('data/key.dat', 'wt') as f:
				key = hashlib.sha224(('%s%s%s' % (sd[1], sd[2], sd[3])).\
					encode('utf-8')).hexdigest()
				print(key, file=f,sep='')
			mother_win.active[0].win.accept()
			mother_win.create_window('main')
		else:
			print('User not created by root, proceed to delete')
	else:
		print('Either user not existent or password incorrect')
Ejemplo n.º 2
0
import hashlib, random, datetime
from utils import db_management as db
from classes.User import User

LOGS_CONNECTION = db.connect('logs.db')

def login_accept(mother_win, username, psswrd):
	secure_connection = db.connect('secure.db')

	# Attempt secure user validation
	seed = hashlib.sha224(('%s%s' % (username, psswrd)).encode('utf-8')).hexdigest()
	fruit = hashlib.sha224(psswrd.encode('utf-8')).hexdigest()
	harvest_fruit = db.read(secure_connection, '002', seed)
	db.close(secure_connection)
	if harvest_fruit:
		harvest_fruit = harvest_fruit[0]
		if harvest_fruit[1] == fruit:
			# Update logs and update key
			fb = db.read(LOGS_CONNECTION, '003')[0][0]
			if fb == None:
				fb = 0
			else:
				fb += 1
			items = \
				'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'.split(',')
			random.shuffle(items)
			rnd = ''.join(items)
			sd = (fb, str(datetime.date.today()), username, rnd)
			db.write(LOGS_CONNECTION, '003', sd)
			db.close(LOGS_CONNECTION)
			with open('data/key.dat', 'wt') as f:
Ejemplo n.º 3
0
from PySide import QtCore, QtGui
from utils import db_management as db
from classes.User import User
from gui.constructor import Gui_Constructor
import gui_constructor, sqlite3, glob, hashlib, datetime, sys

LOGS_CONNECTION = db.connect('logs.db')
USER_CONNECTION = db.connect('users.db')

# if not, initiate databases and tables, check status of background program (init it)
# if not already. Check compliance of screen properties and GUI element placement.
# Parse tasks of background program to the task list
# Connection to startup required dbs

# Create the tables of users.db in case they do not exists
db.write(LOGS_CONNECTION, '000')
db.write(USER_CONNECTION, '001')

# Create the tables of secure.db in case they do not exists, close connection
# immediately
secure_connection = db.connect('secure.db')
db.write(secure_connection, '002')
db.close(secure_connection) # Close connection

# Verify if a session has been opened in the current date
session_exists = False
fb = db.read(LOGS_CONNECTION, '001')
if fb:
	fb = fb[-1]
	if fb[1] == str(datetime.date.today()):