def changePassword(self, oldPass="", newPass=""): self.lock(); cmd = "\"" + __settings__.getSetting( "truecrypt" ) + "\" " cmd +="\"changepass\" " ; cmd += "\"" + self.filePath + "\" "; escapedOldPass = sutils.escapeCharsForShell(oldPass); escapedNewPass = sutils.escapeCharsForShell(newPass); if debug: print("Truecrypt executing shell script:\n" + cmd + ("\"" + escapedOldPass + "\" " + "\"" + escapedNewPass + "\"" if debugLogPassword else "\"*****\" \"*****\"")); cmd += "\"" + escapedOldPass + "\" "; cmd += "\"" + escapedNewPass + "\""; p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True); output, errors = p.communicate(); if debug: print("Truecrypt shell's err out:\n" + str(errors)); print("Truecrypt shell's std out:\n" + str(output)); self.unlock(); if errors != None: self.errorMessage= str(errors); else : self.errorMessage=""; returnCode = int(output[len(output)-2:]); # returnCode = 1; if returnCode == 0: return True; else : return False;
def changePassword(filePath, oldPass="", newPass="", keyFiles="", item=None): ''' The method executes changing of password in the volume through shell script. :param filePath: path to the volume :param oldPass: password to be changed :param newPass: new password :param keyFiles: key file path :param item: item on which task is executed (only for lock reasons) ''' if item != None: item.lock(__settings__.getLocalizedString(50122)) sutilsxbmc.refreshCurrentListing() cmd = "\"" + shellScript + "\" " cmd += "\"" + consts.commandChagePassword + "\" " cmd += "\"" + filePath + "\" " escapedOldPass = sutils.escapeCharsForShell(oldPass) escapedNewPass = sutils.escapeCharsForShell(newPass) # this is command for the debug log only tempcmd = consts.logExecutingScript + cmd + ( "\"" + escapedOldPass + "\" " + "\"" + escapedNewPass + "\"" if debugLogPassword else "\"*****\" \"*****\"") + ( " \"" + keyFiles + "\"" if debugLogKeyFiles else " \"*****\"") xbmc.log(consts.logExecutingScript + tempcmd, level=xbmc.LOGDEBUG) cmd += "\"" + escapedOldPass + "\" " cmd += "\"" + escapedNewPass + "\"" cmd += " \"" + keyFiles + "\"" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() xbmc.log(consts.logStandardOut + str(output), level=xbmc.LOGDEBUG) xbmc.log(consts.logErrorOut + str(errors), xbmc.LOGERROR if errors else xbmc.LOGDEBUG) if item != None: item.unlock() if errors: setErrorMessage(str(errors)) returnCode = int(output[len(output) - 2:]) # returnCode = 1; if returnCode == 0: return True else: return False
def mountAsHiddenProtected(filePath, mountPoint, passwordOuter="", keyFilesOuter="", passwordHidden="", keyFilesHidden="", item=None): ''' Method executes mounting of the volume with hidden volume protection it through the shell script. :param filePath: path to the volume :param mountPoint: mount point :param passwordOuter: password for the outer volume :param keyFilesOuter: key files path for the outer volume :param passwordHidden: password for the hidden volume :param keyFilesHidden: key files path for the hidden volume :param item: no longer needed ''' cmd = "\"" + shellScript + "\" " cmd += consts.commandMountHidden + " " cmd += "\"" + filePath + "\" " cmd += "\"" + mountPoint + "\" " escapedPasswordOuter = sutils.escapeCharsForShell(passwordOuter) escapedPasswordHidden = sutils.escapeCharsForShell(passwordHidden) # this is command for the debug log only tempcmd = cmd + ( "\"" + escapedPasswordOuter + "\"" if debugLogPassword else "\"*****\"" ) + (" \"" + keyFilesOuter + "\"" if debugLogKeyFiles else " \"*****\"" ) + (" \"" + escapedPasswordHidden + "\"" if debugLogPassword else "\"*****\"") + (" \"" + keyFilesHidden + "\"" if debugLogKeyFiles else " \"*****\" ") xbmc.log(consts.logExecutingScript + tempcmd, level=xbmc.LOGDEBUG) cmd += "\"" + escapedPasswordOuter + "\" " cmd += "\"" + keyFilesOuter + "\" " cmd += "\"" + escapedPasswordHidden + "\" " cmd += "\"" + keyFilesHidden + "\"" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() xbmc.log(consts.logStandardOut + str(output), level=xbmc.LOGDEBUG) xbmc.log(consts.logErrorOut + str(errors), xbmc.LOGERROR if errors else xbmc.LOGDEBUG) if errors != None: setErrorMessage(str(errors))
def mount(self, password=""): cmd = "\"" + __settings__.getSetting( "truecrypt" ) + "\" " cmd +="\"mount\" " ; cmd += "\"" + self.filePath + "\" "; cmd += "\"" + self.mountPoint + "\" "; escapedPassword = sutils.escapeCharsForShell(password); if debug: print("Truecrypt executing shell script:\n" + cmd + ("\"" + escapedPassword + "\"" if debugLogPassword else "\"*****\"")); cmd += "\"" + escapedPassword + "\""; p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True); output, errors = p.communicate(); if debug: print("Truecrypt shell's err out:\n" + str(errors)); print("Truecrypt shell's std out:\n" + str(output)); auxmnt = str(output); __settings__.setSetting("tc_aux_mnt" + str(self.index), auxmnt); if errors != None: self.errorMessage= str(errors); else : self.errorMessage="";
def createNewFile(filePath, mountPoint, size, password, keyFiles="", randomNumberGenerator="/dev/random", item=None): ''' This method executes creation of new simple volume through shell script. :param filePath: path to the volume :param mountPoint: mount point :param size: size of the file in MB :param password: password :param keyFiles: key file path :param randomNumberGenerator: ramdomness generator, default is /dev/ramdom can also be a user chosen file :param item: item it concerns (only for lock purposes) ''' if item != None: item.lock(__settings__.getLocalizedString(50123)) cmd = "\"" + shellScript + "\" " + consts.commandCreateContainer + " \"" + filePath + "\" \"" + mountPoint + "\" \"" escapedPassword = sutils.escapeCharsForShell(password) # this is command for the debug log only tempcmd = cmd + (escapedPassword + "\" " if debugLogPassword else "******\" ") tempcmd = tempcmd + str(size) tempcmd = tempcmd + (" \"" + keyFiles + "\"" if debugLogKeyFiles else " \"*****\"") tempcmd = tempcmd + " " + randomNumberGenerator xbmc.log(consts.logExecutingScript + tempcmd, level=xbmc.LOGDEBUG) cmd = cmd + escapedPassword + "\" " + str( size) + " \"" + keyFiles + "\" " + randomNumberGenerator p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() xbmc.log(consts.logStandardOut + str(output), level=xbmc.LOGDEBUG) xbmc.log(consts.logErrorOut + str(errors), xbmc.LOGERROR if errors else xbmc.LOGDEBUG) if item != None: item.unlock()
def createNewFile(self, size, password): self.lock(); cmd = "\"" + __settings__.getSetting( "truecrypt" ) + "\" create" + " \"" + self.filePath + "\" \"" + self.mountPoint + "\" \""; escapedPassword = sutils.escapeCharsForShell(password); if debug: print("Truecrypt executing shell script:\n" + cmd + (escapedPassword + "\" " if debugLogPassword else "******\" ") + str(size)); cmd = cmd + escapedPassword + "\" " + str(size); p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True); output, errors = p.communicate(); if debug: print("Truecrypt shell's err out:\n" + str(errors)); print("Truecrypt shell's std out:\n" + str(output)); self.unlock(); if not output == None: print(str(output)); if not errors == None: print(str(errors))
def mount(filePath, mountPoint, password="", keyFiles="", item=None): ''' Method executes mounting of the volume it through the shell script. :param filePath: volume path :param mountPoint: mount point :param password: password :param keyFiles: path to the key files :param item: item is no longer needed ''' cmd = "\"" + shellScript + "\" " cmd += consts.commandMount + " " cmd += "\"" + filePath + "\" " cmd += "\"" + mountPoint + "\" " escapedPassword = sutils.escapeCharsForShell(password) # this is command for the debug log only tempcmd = consts.logExecutingScript + cmd + ( "\"" + escapedPassword + "\"" if debugLogPassword else "\"*****\"") + ( " \"" + keyFiles + "\"" if debugLogKeyFiles else " \"*****\"") xbmc.log(consts.logExecutingScript + tempcmd, level=xbmc.LOGDEBUG) cmd += "\"" + escapedPassword + "\" " cmd += "\"" + keyFiles + "\"" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() xbmc.log(consts.logStandardOut + str(output), level=xbmc.LOGDEBUG) xbmc.log(consts.logErrorOut + str(errors), xbmc.LOGERROR if errors else xbmc.LOGDEBUG) # auxmnt = str(output); # __settings__.setSetting("tc_aux_mnt" + str(self.index), auxmnt); if errors != None: setErrorMessage(str(errors))
def createVolumeWithHiddenVolume(filePath, mountPoint, passOuter, keysOuter, sizeOuter, passHidden, keysHidden, sizeHidden, fileSys, randomDataGenerator="/dev/random"): ''' The method executes creation of truecrypt volume with hidden volume though shell script :param filePath: path to the volume :param mountPoint: mount point :param passOuter: pass for the outer volume :param keysOuter: key files path for the outer volume :param sizeOuter: size of the outer volume :param passHidden: pass for the hidden volume :param keysHidden: key file path fot the hidden volume :param sizeHidden: size of the hidden volume :param fileSys: file system to be used. ntfs makes problems and usually damages the volume :param randomDataGenerator:randomness generator to be used. Default is /dev/random. Any user file can be used ''' escapedOuterPass = sutils.escapeCharsForShell(passOuter) escapedHiddenPass = sutils.escapeCharsForShell(passHidden) pathPartPfCmd = "\"" + shellScript + "\" " + consts.commandCreateContWithHiddenVolume + " \"" + filePath + "\" \"" + mountPoint + "\"" passPartOfCmd1 = "\"" + escapedOuterPass + "\" \"" + keysOuter + "\"" passPartOfCmd2 = "\"" + escapedHiddenPass + "\" \"" + keysHidden + "\"" lastPartOfCmd = str(sizeHidden) + " " + fileSys + " " + randomDataGenerator # string for use in debug print hiddenPassKey = ( "\"" + escapedOuterPass + "\"" if debugLogPassword else "\"*****\"" ) + " " + ("\"" + keysOuter + "\"" if debugLogKeyFiles else " \"*****\"") + " " + str(sizeOuter) + " " + ( "\"" + passHidden + "\"" if debugLogPassword else "\"*****\"") + " " + ("\"" + keysHidden + "\"" if debugLogKeyFiles else " \"*****\"") # real command string cmd = pathPartPfCmd + " " + passPartOfCmd1 + " " + str( sizeOuter) + " " + passPartOfCmd2 + " " + lastPartOfCmd # string for use in debug print tempcmd = consts.logExecutingScript + pathPartPfCmd + " " + hiddenPassKey + " " + lastPartOfCmd xbmc.log(consts.logExecutingScript + tempcmd, level=xbmc.LOGDEBUG) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() xbmc.log(consts.logStandardOut + str(output), level=xbmc.LOGDEBUG) xbmc.log(consts.logErrorOut + str(errors), xbmc.LOGERROR if errors else xbmc.LOGDEBUG) returnCode = int(output[len(output) - 2:]) if returnCode == 0: return True else: return False