Ejemplo n.º 1
0
 def __init__(self, user, passw):
     salt = enc.GenerateSALT()
     self.sessionSALT = salt
     self.user = enc.AESEncrypt(user, salt)
     self.passw = enc.AESEncrypt(passw, salt)
     self.toClear = False
     
     #Define all commands, add to self
     commandList = []
     for cmds in GetCommandList():            
         commandList.append(CommandInfo.Command(cmds[0], getattr(self, cmds[0]), cmds[1], cmds[2], cmds[3], cmds[4]))
     self.commandList = commandList
Ejemplo n.º 2
0
def RenamePassTitle(newPassTitle, lineNum, encryptionKey):
    AESEncryptionKey = Encryptor.BindKey(Encryptor.GetKey(), encryptionKey)
    if (not DoesProgramFileExist(passFile)):
        return False

    #Get Current File
    with open((GetFileLocation() + passFile), "r") as f:
        data = f.readline()
    fileContent = Encryptor.DecryptFile(data, AESEncryptionKey)

    if (lineNum < 0 or lineNum >= len(fileContent)):
        return False

    #Get password locker line
    fullLine = SplitString(fileContent[lineNum], sep2)

    lineToWrite = fullLine[0] + sep2 + Encryptor.AESEncrypt(
        newPassTitle, AESEncryptionKey) + sep2 + fullLine[2]

    #Write back to file
    fileContent[lineNum] = lineToWrite

    writeFileString = Encryptor.EncryptFile(fileContent, AESEncryptionKey)
    with open((GetFileLocation() + passFile), "w") as f:
        f.write(writeFileString)

    return True
Ejemplo n.º 3
0
def CreateTestFile():
    if (not DoesProgramFileExist(testFile, workingPath)):
        #If test file doesn't exist, create one
        toWrite = Encryptor.AESEncrypt("PASS", Encryptor.GetKey())
        checkFile = open(workingPath + testFile, "w+")
        checkFile.write(toWrite + "\n")
        checkFile.close()
Ejemplo n.º 4
0
def CreateSecurityFile(EncrpytedPassKey, AESKey):
    if (DoesProgramFileExist(securityFile)):
        os.remove(GetFileLocation() +
                  securityFile)  #Old file is useless, remove it if it exists
    #Now build file contents
    fileContents = [
        "#Active Session, DO NOT EDIT",
        Encryptor.AESEncrypt("Security_Session_Key", Encryptor.GenerateSALT())
    ]
    encKey = Encryptor.AESEncrypt(
        EncrpytedPassKey, AESKey)  #Again, doesn't need to be overly secure
    fileContents.append(encKey)

    sessionFile = open((GetFileLocation() + securityFile), "w+")
    for x in fileContents:
        sessionFile.write(x + "\n")
    sessionFile.close()
Ejemplo n.º 5
0
def CreateUserAccount(username, encryptedPass, salt):
    #Account does not already exist, therefore need to create account
    accountString = salt + seperator + encryptedPass + seperator + username
    #Must encrypt data via AES using unique identifying password (It's actually just the username - Doesn't need to be overly secure)
    encAccString = Encryptor.AESEncrypt(accountString, username)

    #Now save data in file
    accFile = open((GetFileLocation() + accountFile), "w+")
    accFile.write(encAccString)
    accFile.close()
Ejemplo n.º 6
0
def CreateSFFPSL(FilePath):
    global securityPath
    securityPath = FilePath

    newKey = Encryptor.GenerateSecurityKey()

    fillKey = Encryptor.GenerateSALT(64, True)
    toSave = ""
    for idx, val in enumerate(newKey):
        toGrab = 2 * idx
        toSave += val + fillKey[toGrab] + fillKey[toGrab + 1]

    toSave = Encryptor.AESEncrypt(toSave, sep2)

    #Now write to file
    SFFPSLFile = open(securityPath + exSecFile, "w+")
    SFFPSLFile.write(toSave + "\n")
    SFFPSLFile.close()

    UpdateSecurityKey(newKey)
    UpdateSecurityPath(FilePath)
Ejemplo n.º 7
0
def AmmendPasswordFile(passTitle,
                       password,
                       encryptionKey,
                       inputUsername="******",
                       inputExtra="null",
                       inputGroup="null",
                       lineNum=-1):
    AESEncryptionKey = Encryptor.BindKey(Encryptor.GetKey(), encryptionKey)
    #Returns successful runs,
    if (not DoesProgramFileExist(passFile)):
        #Will create the file if it doesn't exist
        toWrite = ["#Locker.psl"]
        encryptedLineWrite = Encryptor.EncryptFile(toWrite, AESEncryptionKey)
        with open((GetFileLocation() + passFile), "w+") as pF:
            pF.write(encryptedLineWrite)

    #Get Current File
    with open((GetFileLocation() + passFile), "r") as f:
        data = f.readline()
    fileContent = Encryptor.DecryptFile(data, AESEncryptionKey)

    #lineNum = -1 denotes a new password to be added
    if (lineNum >= 0 and lineNum < len(fileContent)
            and (password == "" or inputUsername == "" or inputGroup == ""
                 or inputExtra == "")):
        #Check what values = '' and overrite with stored data
        #First seperate fileContent by sep2
        sep2Content = SplitString(fileContent[lineNum], sep2)
        #Now update group values
        if (inputGroup == ""):
            inputGroup = sep2Content[0]
        #Now get user/pass segment
        userPassSeg = Encryptor.AESDecrypt(sep2Content[2],
                                           AESEncryptionKey).split(userpassSep)
        if (password == ""):
            password = userPassSeg[0]
        if (inputUsername == ""):
            inputUsername = userPassSeg[1]
        if (inputExtra == ""):
            inputExtra = userPassSeg[2]
            print(inputExtra)

    lineWrite = inputGroup + sep2 + Encryptor.AESEncrypt(
        passTitle, AESEncryptionKey) + sep2 + Encryptor.AESEncrypt(
            password + userpassSep + inputUsername + userpassSep + inputExtra,
            AESEncryptionKey)

    #Ammend file contents
    if (lineNum == -1):
        fileContent.append(lineWrite)
    elif (lineNum >= 0):
        if (lineNum > len(fileContent)):
            return False
        fileContent[lineNum] = lineWrite
    else:
        raise ValueError("Invalid edit number, use '-1' to add new password")

    #Write back to file
    writeFileString = Encryptor.EncryptFile(fileContent, AESEncryptionKey)
    with open((GetFileLocation() + passFile), "w") as f:
        f.write(writeFileString)

    return True