예제 #1
0
 def __on_input_button_clicked(self):
     self.input_file_path = FileService.openAnyFileNameDialog(self, self)
     self.input_file_path_line_edit.setText(self.input_file_path)
    def EmitSwitchNext(
            self):  # implement event that will emit the switch window signal
        password = self.encryptionKeyTextEdit.toPlainText()
        privateKey = self.privateKeyLineEdit.text()
        publicKey = self.publicKeyLineEdit.text()
        if (self.Config == "Encode"):
            if (self.fileRadioButton.isChecked()):
                #Show Browser to select payload and pass it to next page (pass payload directory)
                payloadDir = FileService.openAnyFileNameDialog(
                    self.Form, self.Form)
                if (payloadDir != ''):
                    #### Adding cryptographic components
                    if (self.cryptographyCheckBox.isChecked()):
                        payloadDirCrypt = re.sub(r'\/(?=[^/]*$).*',
                                                 '/EncryptedFile', payloadDir)
                        if self.algorithmComboBox.currentIndex() == 0:  # AES
                            AesManager.write_encrypted_text(
                                password.encode('ascii'), payloadDirCrypt,
                                payloadDir)
                            self.show_encode_file.emit(self.imagedata,
                                                       self.Config,
                                                       self.carrierDir,
                                                       payloadDirCrypt)
                        elif (self.algorithmComboBox.currentIndex() == 1
                              ):  #DES
                            DesManager.write_encrypted_text(
                                password.encode('ascii'), payloadDirCrypt,
                                payloadDir)
                            self.show_encode_file.emit(self.imagedata,
                                                       self.Config,
                                                       self.carrierDir,
                                                       payloadDirCrypt)

                        elif (self.algorithmComboBox.currentIndex() == 2
                              ):  #RSA
                            if self.publicKeyLineEdit.hasAcceptableInput():
                                public_key_file_path = self.publicKeyLineEdit.text(
                                )
                                public_key_file = open(public_key_file_path,
                                                       'rb')
                                public_key = public_key_file.read()
                                public_key_file.close()
                                RsaManager.write_encrypted_stream(
                                    public_key, payloadDirCrypt, payloadDir)
                                self.show_encode_file.emit(
                                    self.imagedata, self.Config,
                                    self.carrierDir, payloadDirCrypt)

                    else:
                        self.show_encode_file.emit(self.imagedata, self.Config,
                                                   self.carrierDir, payloadDir)
            else:
                if (self.cryptographyCheckBox.isChecked()):
                    if self.algorithmComboBox.currentIndex() == 0:  # AES
                        self.show_encode_text.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 1,
                                                   password, publicKey)
                    elif self.algorithmComboBox.currentIndex() == 1:  # DES
                        self.show_encode_text.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 2,
                                                   password, publicKey)
                    elif self.algorithmComboBox.currentIndex() == 2:  # RSA
                        self.show_encode_text.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 3,
                                                   password, publicKey)
                else:
                    self.show_encode_text.emit(self.imagedata, self.Config,
                                               self.carrierDir, 0, password,
                                               publicKey)
        else:
            if (self.fileRadioButton.isChecked()):
                if (self.cryptographyCheckBox.isChecked()):
                    if self.algorithmComboBox.currentIndex() == 0:  # AES
                        self.show_decode_file.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 1,
                                                   password, privateKey)
                    elif self.algorithmComboBox.currentIndex() == 1:  # DES
                        self.show_decode_file.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 2,
                                                   password, privateKey)
                    elif self.algorithmComboBox.currentIndex() == 2:  # RSA
                        self.show_decode_file.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 3,
                                                   password, privateKey)
                else:
                    self.show_decode_file.emit(self.imagedata, self.Config,
                                               self.carrierDir, 0, password,
                                               privateKey)
            else:
                if (self.cryptographyCheckBox.isChecked()):
                    if self.algorithmComboBox.currentIndex() == 0:  # AES
                        self.show_decode_text.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 1,
                                                   password, privateKey)
                    elif self.algorithmComboBox.currentIndex() == 1:  # DES
                        self.show_decode_text.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 2,
                                                   password, privateKey)
                    elif self.algorithmComboBox.currentIndex() == 2:  # RSA
                        self.show_decode_text.emit(self.imagedata, self.Config,
                                                   self.carrierDir, 3,
                                                   password, privateKey)
                else:
                    self.show_decode_text.emit(self.imagedata, self.Config,
                                               self.carrierDir, 0, password,
                                               privateKey)
예제 #3
0
 def __on_pvk_button_clicked(self):
     self.private_key_path = FileService.openAnyFileNameDialog(self, self)
     self.private_key_line_edit.setText(self.private_key_path)
 def privateKeyButtonClicked(self):
     privateKeyFile = FileService.openAnyFileNameDialog(
         self.Form, self.Form)
     self.privateKeyLineEdit.setText(privateKeyFile)