Beispiel #1
0
    def check_user_name_and_password(self,list_info):

        user_name=list_info[0]
        password_temp=list_info[1]

        m = hashlib.md5()
        m.update(str(password_temp))
        password=m.hexdigest()

        data_base_temp=data_base()
        check_exists_user_name=data_base_temp.Check_user_name("All_User_Info",user_name)
        if check_exists_user_name==0:
            return 14 #user name not exists


        data_base_temp=data_base()
        check_exists_user_name=data_base_temp.Check_password_correct_by_user_name("All_User_Info",user_name,password)
        if check_exists_user_name==0:
            return 15 #wrong password

        return 106
Beispiel #2
0
    def check_account_info_exist(self,list_vars):
        #checks if email and user name exists
        user_name=list_vars[0]
        email=list_vars[4]

        data_base_temp=data_base()
        check_exists_email=data_base_temp.Check_email("All_User_Info",email)

        if check_exists_email==1:
            return 9 #email already exists

        data_base_temp=data_base()
        check_exists_user_name=data_base_temp.Check_user_name("All_User_Info",user_name)
        if check_exists_user_name==1:
            return 10 #user name already exists

        else:

            code=self.create_new_account(list_vars)

            return code
Beispiel #3
0
    def check_email_and_answer_correct(self,list_info):
        email=list_info[0]
        secret_answer=list_info[1]

        data_base_temp=data_base()
        check_exists_email=data_base_temp.Check_email("All_User_Info",email)

        if check_exists_email==0:
            return 11 #email not exists

        data_base_temp=data_base()
        Check_secret_answer=data_base_temp.check_email_and_answer("All_User_Info",secret_answer,email)
        if Check_secret_answer==0:
            return 13 #secret answer not correct
        else:
            password=self.genreate_random_password()
            data_base_temp=data_base()
            data_base_temp.set_password_by_email("All_User_Info",email,password)

            code=self.send_email("Help.Mist1802","Tomerzabo1",str(email)+"@gmail.com","Recovery Password from MIST","Hello user,\nthis is your new password for your account\n Password =  "+str(password))
            return code
Beispiel #4
0
    def create_new_account(self,user_info_list):

        #creates new account
        user_name=user_info_list[0]


        password2=user_info_list[1] #this is how we encrypt the password into the database
        m = hashlib.md5()
        m.update(str(password2))
        password=m.hexdigest()


        l_name=user_info_list[2]
        f_name=user_info_list[3]
        email=user_info_list[4]
        secret_answer=user_info_list[5]

        data_base_temp=data_base()
        data_base_temp.Add_new_user("All_User_Info",user_name,password,f_name,l_name,email,secret_answer)
        code=self.send_email("Help.Mist1802","Tomerzabo1",str(email)+"@gmail.com","New Account Created  MIST","Hello user,\
        \nThank you for joining the MIST community\nThis is your account \nPassword =  "******"\nUser Name= "+user_name)


        return 104 #all good
Beispiel #5
0
    def DoAction(self,data1):


        if(self.state == State_enum.start):
            to_send= "Action~Rsa key please"



        else:
            to_send= "????"


        to_close_after_send = False


        data_len=len(data1)
        data=data1.split('~')
        if self.key_sent==False:

            if self.check_key(data[1]):

                self.Client_public_key=rsa.PublicKey.load_pkcs1(data[1],format='PEM')
                self.state=State_enum.after_key
                print "Got public key from "+ self.ip +" thread number "+ self.tid
                to_send="Action~"+self.serv_pubk.save_pkcs1(format='PEM')


        else:
            if data_len < 5:

                if self.state == State_enum.start:
                    to_send= "Action~Rsa key please"
                else:
                    to_send="Action~nothing"

            else:

                if data[0].startswith("Create Account"):
                     to_send=rsa.encrypt("Action~send all user info",self.Client_public_key)
                     self.conn.send(to_send)
                     account_info=[]
                     for i in range(0,6):

                         data=self.conn.recv(1024)
                         data=rsa.decrypt(data,self.serv_privk)
                         account_info.append(data)

                     code=self.check_account_info_exist(account_info)

                     to_send="Action~Code~"+str(code)

                elif data[0].startswith("Recover Password"):
                     to_send=rsa.encrypt("Action~send email and answer",self.Client_public_key)
                     self.conn.send(to_send)
                     account_info=[]
                     for i in range(0,2):

                         data=self.conn.recv(1024)
                         data=rsa.decrypt(data,self.serv_privk)
                         account_info.append(data)

                     code=self.check_email_and_answer_correct(account_info)
                     to_send="Action~Code~"+str(code)


                elif data[0].startswith("Login"):
                     to_send=rsa.encrypt("Action~send user info",self.Client_public_key)
                     self.conn.send(to_send)
                     account_info=[]
                     for i in range(0,2):

                         data=self.conn.recv(1024)
                         data=rsa.decrypt(data,self.serv_privk)
                         account_info.append(data)

                     code=self.check_user_name_and_password(account_info)
                     to_send="Action~Code~"+str(code)

                elif data[0].startswith("My Profile"):
                    print "i am here"
                    to_send=rsa.encrypt("send user name",self.Client_public_key)
                    self.conn.send(to_send)
                    print "send >>> send user name"
                    data=self.conn.recv(1024)

                    user_name=rsa.decrypt(data,self.serv_privk)
                    print "recv <<<< "+str(user_name)

                    data_base_temp=data_base()
                    all_user_info=data_base_temp.get_all_info_by_user_name("All_User_Info",user_name)
                    print all_user_info
                    for i in range(0,4):
                        print "4444 "+ str(all_user_info[i])
                        to_send=rsa.encrypt("Append~"+str(all_user_info[i]),self.Client_public_key)
                        self.conn.send(to_send)
                        time.sleep(0.05)


                    to_send="None"






        return to_close_after_send,to_send