def ukfolder(): print '\n' print ' It seems that your folder is locked.\n\ Press any key when you are ready to unlock it.' os.system('pause>NUL') print '\n' print ' Please wait...' lockmethod=file(prof,'r').readlines()[1] if lockmethod in ('standard','Standard','STANDARD'): os.rename(prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}',prof+'f\\'+prof+'f') else: zipfolder=chilkat.CkZip() zipfolder.UnlockComponent('ZIP-TEAMBEAN_3313FAF5910U') zipfolder.put_Encryption(4) zipfolder.put_EncryptKeyLength(256) zipfolder.SetPassword(finalpass) zipfolder.OpenZip(prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}\\'+prof) zipfolder.Unzip(prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}') os.remove(prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}\\'+prof) os.rename(prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}',prof+'f\\'+prof+'f') os.system('date /t >>'+prof+'f\\log.txt') os.system('time /t >>'+prof+'f\\log.txt') os.system('echo UNLOCKED >>'+prof+'f\\log.txt') os.system('echo. >>'+prof+'f\\log.txt') os.startfile(prof+'f\\'+prof+'f') lgprofile(' Folder unlocked successfully.')
def lkfolder(): os.startfile(prof+'f\\'+prof+'f') print '\n' print ' It seems that your folder is unlocked.\n\ Put your desired files in the opened folder and\n\ press any key when you are ready to lock it.' os.system('pause>NUL') print '\n' print ' Please wait...' os.system('cd '+prof+'f\\'+prof+'f') os.system('attrib -r /s') lockmethod=file(prof,'r').readlines()[1] if lockmethod in ('standard','Standard','STANDARD'): os.rename(prof+'f\\'+prof+'f',prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}') else: os.mkdir(prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}') zipfolder=chilkat.CkZip() zipfolder.UnlockComponent('ZIP-TEAMBEAN_3313FAF5910U') zipfolder.NewZip(prof+'f\\My Computer .{20d04fe0-3aea-1069-a2d8-08002b30309d}\\'+prof) zipfolder.put_Encryption(4) zipfolder.put_EncryptKeyLength(256) zipfolder.SetPassword(finalpass) zipfolder.AppendFiles(prof+'f\\'+prof+'f',True) zipfolder.WriteZip() shutil.rmtree(prof+'f\\'+prof+'f') os.system('date /t >>'+prof+'f\\log.txt') os.system('time /t >>'+prof+'f\\log.txt') os.system('echo LOCKED >>'+prof+'f\\log.txt') os.system('echo. >>'+prof+'f\\log.txt') lgprofile(' Folder locked successfully.')
def zip_encrypt(file_path, zip_path): filelist = "" if os.path.isfile(file_path): filelist = file_path else: filelist = file_path + "/*" zip = chilkat.CkZip() # Any string unlocks the component for the 1st 30-days. success = zip.UnlockComponent("Anything for 30-day trial") if (success != True): print(zip.lastErrorText()) Log.logger.error(zip.lastErrorText()) return False # sys.exit() success = zip.NewZip(zip_path) if (success != True): print(zip.lastErrorText()) Log.logger.error(zip.lastErrorText()) return False # sys.exit() # Set properties to indicate that the Zip should be # AES encrypted. # A value of 4 indicates WinZip compatible AES encryption. zip.put_Encryption(4) # Key length can be 128, 192, or 256 bits. zip.put_EncryptKeyLength(128) # Set the password for AES encryption: zip.put_EncryptPassword(encryptPassword) # Add a directory tree to be zipped. (The files # are not compressed at this point -- only references # to the files and directories are added to the zip object.) recurse = True success = zip.AppendFiles(filelist, recurse) if (success != True): print(zip.lastErrorText()) Log.logger.error(zip.lastErrorText()) return False # Create the encrypted zip ("/myZipDir/aes.zip") # The path of the zip is what was originally passed # to the NewZip method (above). success = zip.WriteZipAndClose() if (success != True): print(zip.lastErrorText()) Log.logger.error(zip.lastErrorText()) return False print("Created AES Encrypted Zip success.") Log.logger.info(zip_path + "Created AES Encrypted Zip success.") return True
def __init__(self, raw): self.files = [] self.zip = chilkat.CkZip() self.zip.UnlockComponent(CHILKAT_KEY) self.zip.OpenFromMemory(raw, len(raw)) filename = chilkat.CkString() e = self.zip.FirstEntry() while e != None: e.get_FileName(filename) self.files.append(filename.getString()) e = e.NextEntry()
def __init__(self, mode, keylen, padding, enc_mode): self.mode = mode if keylen != 128 or 192 or 265: self.keylen = 256 self.padding = padding self.enc_mode = enc_mode self.setup = False self.ivHex = None self.keyHex = None self.keylen = keylen self.session_flag = False self.crypt = chilkat.CkCrypt2() self.zip = chilkat.CkZip() self.UnlockComponents()
def zip_dencrypt(zip_file, unzip_dir): zip = chilkat.CkZip() # Any string unlocks the component for the 1st 30-days. success = zip.UnlockComponent("Anything for 30-day trial") if (success != True): print(zip.lastErrorText()) Log.logger.error(zip.lastErrorText()) return False success = zip.OpenZip(zip_file) if (success != True): print(zip.lastErrorText()) Log.logger.error(zip.lastErrorText()) return False # Set the password needed to unzip. # This password must match the password used when the zip # was created. zip.put_DecryptPassword(encryptPassword) # Unzip the .zip into /unzipDir. # Returns the number of files and directories unzipped. unzipCount = zip.Unzip(unzip_dir) if (unzipCount < 0): print(zip.lastErrorText()) Log.logger.error(zip.lastErrorText()) return False else: print("unzip dencrypted file success!") Log.logger.info(unzip_dir + ":unzip dencrypted file success!") return True # if __name__ == '__main__': # filePath = "12345678.90" # filename = "90" # length = len(filePath) - len(filename) - 1 # targetPath = filePath[0:length] + ".zip" # print(targetPath) # # zip_encrypt("D:\\test\\logs", "D:\\test\\logs.zip") # zip_encrypt( "D:\\test\\logs", "D:\\test\\logs.zip") # # zip_dencrypt(r'D:\\test\\zf_b2c\\logs.zip',r'D:\\test\\zf_b2c\\log')
def InstallServer(self): if self.fileType==".rar": unCompress=chilkat.CkRar() elif self.fileType==".zip": unCompress=chilkat.CkZip() print "begin installServer" dst=self.loc+self.Version+self.fileType unCompress.Open(dst) unCompress.Unrar(self.loc) print "install ok" if os.path.exists(self.loc+"robust"): for root, dirs, files in os.walk(self.loc+"robust", topdown=False): for name in files: os.remove(os.path.join(root, name)) for name in dirs: os.rmdir(os.path.join(root, name)) #os.chdir(self.loc) os.removedirs(self.loc+self.name) os.rename(self.loc+"bin",self.loc+self.name)
import sys import chilkat zip = chilkat.CkZip() # Any string unlocks the component for the 1st 30-days. success = zip.UnlockComponent("Anything for 30-day trial") if (success != True): print(zip.lastErrorText()) sys.exit() success = zip.NewZip("test.zip") if (success != True): print(zip.lastErrorText()) sys.exit() recurse = False zip.AppendFiles("*.txt",recurse) success = zip.WriteZipAndClose() if (success != True): print(zip.lastErrorText()) sys.exit() print("Created test.zip")