Exemple #1
0
 def GenPass(self, params):
     wait = True
     #Generate password
     while(wait):
         generatedPassword = enc.GeneratePassword(params)
         console.out(48)
         console.SlowPrint(generatedPassword, 0.03, ">")
         console.out(49)
         inputVal = input("")
         if(inputVal.lower()=="n" or inputVal.lower()=="no"):
             wait = False
     #Give option to save password
     
     console.out(50)
     inputVal = input("")
     if(inputVal.lower()=="y" or inputVal.lower()=="yes"):
         titleSelected = False
         passTitles = File.GetPasswordTitles(self.GetFileEncryptionKey())
         while(not titleSelected):
             console.out(51) #Get user to enter a title
             inputVal = input("")
             if(inputVal.lower() == "c"):
                 return None #Quit routine
             if(passTitles == None or inputVal not in passTitles):
                 titleSelected = True            
         
         state = File.AmmendPasswordFile(inputVal, generatedPassword, self.GetFileEncryptionKey())
         if(state):
             console.PrintList([38, "Use 'EditPass' to add more information to this stored password"], 0.02)
         else:
             console.out(39)    
         
     console.out(2)
Exemple #2
0
 def EditPass(self, params): 
     #Similar to add pass, but overrites existing password
     userTitle = params[0]
     foundIndex = File.GetPasswordTitle(userTitle, self.GetFileEncryptionKey())
     if(foundIndex >= 0):        
         #password exists, therefore can overrite
         #First check if user used identifiers i.e. 'EditPass passwordTitle group=NewGroup'
         if(len(params) > 1 and '=' in params[1]):
             passw = ""
             usern = ""
             group = ""
             extra = ""
             #Does contain identifier
             for param in params:
                 #Need to check for all parameters
                 if("=" in param):
                     #Only consider value with = in parameter passed
                     splitParam = param.split("=")
                     if(splitParam[0].lower() == "pass" or splitParam[0].lower() == "passw" or splitParam[0].lower() == "password"):
                         passw = splitParam[1]
                     elif(splitParam[0].lower() == "user"):
                         usern = splitParam[1]
                     elif(splitParam[0].lower() == "group" or splitParam[0].lower() == "grp"):
                         group = splitParam[1]
                     elif(splitParam[0].lower() == "extra" or splitParam[0].lower() == "ext" or splitParam[0].lower() == "additional" or splitParam[0].lower() == "add"):
                         extra = splitParam[1]
             if(passw != "" or usern != "" or group != "" or extra != ""):
                 #Update file                    
                 state = File.AmmendPasswordFile(params[0], passw, self.GetFileEncryptionKey(), usern, extra, group, foundIndex)
             else:
                 state = False
         else:   
             if(len(params)==3):
                 state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2], "null","null", foundIndex)
             elif(len(params)==4):
                 state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2], params[3],"null", foundIndex)
             elif(len(params)==5):
                 state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2], params[3],params[4], foundIndex)    
             elif(len(params)==2):
                 state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), "null", "null","null", foundIndex)            
         if(state):
             console.out(41)
         else:
             console.out(42)
     else:
         #password doesn't exist
         console.outs([43,2])  
Exemple #3
0
    def AddPass(self, params):
        #Check if password title is already taken
        userTitle = params[0]

        passTitles = File.GetPasswordTitles(self.GetFileEncryptionKey())
        if(passTitles == None or userTitle.lower() not in (name.lower() for name in passTitles)): #Prevent passwords under the same name
            #password doesn't exist, can create
            if(len(params)==3):
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2])
            elif(len(params)==4):
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2], params[3])
            elif(len(params)==5):
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey(), params[2], params[3], params[4])
            else:
                state = File.AmmendPasswordFile(params[0], params[1], self.GetFileEncryptionKey())
            if(state):
                console.out(38)
            else:
                console.out(39)
        else:
            #password with title already exists
            console.out(40)      
        self.toClear = True