Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
self.controls_state(tk.DISABLED)
for i in sel:
file_ = self.crypts[i]
fname = os.path.basename(file_)
file_ext = file_.split('.')[-1].lower()
decrypter = self.supported.get(file_ext)
if decrypter:
try:
wadec = decrypter(file_, self.key_file)
if wadec.decrypt():
vals = self.file_box.item(i)['values']
vals[1] = True
self.file_box.item(i, values=vals, tags='success')
logger.info(f'WhatsAppCrypt: {fname} successfully decrypted.')
except decrypts.WhatsAppCryptError as err:
logger.error(f'WhatsAppCrypt: {err}')
self.file_box.item(i, tags='failure')
messagebox.showerror('WhatsApp decryption error', str(err))
except Exception as err:
logger.error(f'WhatsAppCrypt: {fname}: {err}')
self.file_box.item(i, tags='failure')
finally:
self.file_box.selection_set()
self.controls_state(tk.NORMAL)
drill = driller.ChainExecution(
output_dir,
src_dir=src_dir,
status_msg=self.StatusMsg,
logger=logger)
drill.CreateWorkDir()
drill.ExtractFromDir()
drill.DataDecoding()
drill.GenerateHtmlReport()
drill.GenerateXlsxReport()
drill.CleanUp()
# WhatsApp Crypt --------------------------------------------------------------
class WhatsAppCrypt(BaseWindow):
KEY_SIZE = decrypts.WhatsAppCrypt.KEY_SIZE
SUFFIX = decrypts.WhatsAppCrypt.SUFFIX
def __init__(self, root=None, title='WhatsApp Crypt Decryptor'):
super().__init__(root=root, title=title)
self.guide = statics.WHATSAPP_CRYPT
self.work_dir = None
self.crypts = {}
self.key_file = None
self.supported = self.get_supported()
self._info = tk.StringVar()
self._info_but = tk.StringVar()
self._info_but.set('Show Info')
ttk.Label(self.mainframe, text=title, font=self.FontTitle).grid(row=1, column=0, columnspan=2)
tk.Button(self.mainframe, textvariable=self._info_but, relief='flat', command=self.info_toggle)\
.grid(row=1, column=2, columnspan=1, sticky=tk.E)
def get_supported(self):
return {kls.CRYPT: kls for kls in decrypts.WhatsAppCrypt.__subclasses__()}