sys.stderr = sys.stdout print "Content-Type: text/html\n" params = cgi.FieldStorage() u = params.getvalue('u') c = params.getvalue('c') m = params.getvalue('m') n = params.getvalue('n') # Create new cloak service cfg = Config() db = DB(cfg) # Get user password from database usr = db.get_user_from_username(u) if usr == False: print "INVALID USER" sys.exit(0) password = getUserPassword(usr) # Verifies password decrypted = aes.decrypt( c, password, 256 ) if decrypted != m: print "AUTH ERR" sys.exit(0) # Generates random session key and save to database sessionkey = base64.b64encode( os.urandom(64) ) wid = db.insert_websession( usr[0], sessionkey )
from cloak.db import DB sys.stderr = sys.stdout print "Content-Type: text/html\n" params = cgi.FieldStorage() r = base64.b64decode( params.getvalue('r') ) j1 = json.loads(r) # Create new cloak service cfg = Config() db = DB(cfg) cloak.alias.cfgdata = cfg # Get user from database usr = db.get_user_from_username(j1['user']) if usr == False: print "ERR: INVALID USER" sys.exit(0) # Get session key from database sessionkey = db.get_websession(usr[0], j1['w'])[0] if sessionkey == None: print "ERR: NO SESSION" sys.exit(0) # Decrypt p = aes.decrypt(j1['c'], sessionkey, 256) # Load json string j2 = json.loads(p)
#readable_ip = ipstr_to_name(ip_addr) rand_ip = ipstr_to_rand(ip_addr) os.chdir('/home/john/cloak/src/Scripts') cfg = Config() db = DB(cfg) cloak.alias.cfgdata = cfg cloak.address.cfgdata = cfg con_user = db.get_user(username=CONTACTSUSER) # if not created yet, create new user; if not con_user: p = subprocess.Popen(['/home/john/cloak/src/Scripts/tools/user-add.py', '-d', cfg.DBSRC, '-u', CONTACTSUSER, '-p', CONTACTSUSER, '-a', 'PLAIN', '-f', '*****@*****.**'], stdout=subprocess.PIPE) res, err = p.communicate() #print res con_user = db.get_user_from_username(username=CONTACTSUSER) pass con_user = User(**con_user) ip_alias = create_alias_helper(con_user, CON_ALIASNAME, rand_ip) #print readable_ip print str(ip_alias) testo = ip_alias.localpart.split('.')[1] print rand_to_ipstr(testo)