Exemplo n.º 1
0
    def _run_command_execution(self):
        ####################################################################
        """Run function for class."""
        ####################################################################
        yield from self._confirm_pdb()
        self.recipient_list.append(str(self.args["identity"]))
        self.recipient_list = list(set(self.recipient_list))
        yield from self._confirm_recipients()
        for dist_pass, _ in tqdm(self.filtered_pdb.items()):
            password = PasswordEntry()
            password.read_password_data(dist_pass)
            if self.args["identity"] in password.recipients.keys():
                # we shouldn't modify escrow on distribute
                self.args["min_escrow"] = None
                self.args["escrow_users"] = None
                plaintext_pw = password.decrypt_entry(
                    self.identity,
                    passphrase=self.passphrase,
                    card_slot=self.args["card_slot"],
                )
                password.add_recipients(
                    secret=plaintext_pw,
                    distributor=self.args["identity"],
                    recipients=self.recipient_list,
                    session=self.session,
                    passphrase=self.passphrase,
                    card_slot=self.args["card_slot"],
                    pwstore=self.args["pwstore"],
                )

                password.write_password_data(dist_pass)
Exemplo n.º 2
0
 def _run_command_execution(self):
     """ Run function for class. """
     ####################################################################
     safe, owner = self.safety_check()
     if safe and owner:
         orig_pass = self.args['pwname']
         self.args['pwname'] = self.args['rename']
         resafe, reowner = self.safety_check()
         self.args['pwname'] = orig_pass
         if resafe or self.args['overwrite']:
             myidentity = self.identities.iddb[self.args['identity']]
             password = PasswordEntry()
             password.read_password_data(
                 os.path.join(self.args['pwstore'], self.args['pwname']))
             plaintext_pw = password.decrypt_entry(
                 identity=myidentity,
                 passphrase=self.passphrase,
                 card_slot=self.args['card_slot'])
             self._confirmation(plaintext_pw)
         else:
             raise NotThePasswordOwnerError(self.args['identity'], reowner,
                                            self.args['rename'])
     else:
         raise NotThePasswordOwnerError(self.args['identity'], owner,
                                        self.args['pwname'])
Exemplo n.º 3
0
    def _run_command_execution(self):
        ####################################################################
        """ Run function for class.                                      """
        ####################################################################

        password = PasswordEntry()
        password.read_password_data(
            os.path.join(self.args['pwstore'], self.args['pwname']))
        myidentity = self.identities.iddb[self.args['identity']]

        plaintext_pw = password.decrypt_entry(identity=myidentity,
                                              passphrase=self.passphrase,
                                              card_slot=self.args["card_slot"])

        if not self.args['noverify']:
            result = password.verify_entry(myidentity['uid'], self.identities)
            if not result['sigOK']:
                print(
                    "Warning:  Could not verify that '%s' correctly signed your password entry."
                    % result['distributor'])
            if not result['certOK']:
                print(
                    "Warning:  Could not verify the certificate authenticity of user '%s'."
                    % result['distributor'])

        oldclip = pyperclip.paste()
        try:
            pyperclip.copy(plaintext_pw)
            print("Password copied into paste buffer for %s seconds" %
                  self.args['time'])
            time.sleep(self.args['time'])
        finally:
            pyperclip.copy(oldclip)
Exemplo n.º 4
0
 def _run_command_execution(self):
     ####################################################################
     """Run function for class."""
     ####################################################################
     safe, owner = self.safety_check()
     if safe and owner:
         orig_pass = self.args["pwname"]
         self.args["pwname"] = self.args["rename"]
         resafe, reowner = self.safety_check()
         self.args["pwname"] = orig_pass
         if resafe or self.args["overwrite"]:
             password = PasswordEntry()
             password.read_password_data(
                 os.path.join(self.args["pwstore"], self.args["pwname"]))
             plaintext_pw = password.decrypt_entry(
                 identity=self.identity,
                 passphrase=self.passphrase,
                 card_slot=self.args["card_slot"],
             )
             self._confirmation(plaintext_pw)
         else:
             raise NotThePasswordOwnerError(self.args["identity"], reowner,
                                            self.args["rename"])
     else:
         raise NotThePasswordOwnerError(self.args["identity"], owner,
                                        self.args["pwname"])
Exemplo n.º 5
0
    def _run_command_execution(self):
        """ Run function for class.                                      """
        ####################################################################
        passworddb = PasswordDB()
        passworddb.load_from_directory(self.args['pwstore'])
        filtered_pdb = util.dictionary_filter(
            path.join(self.args['pwstore'], self.args['pwname']),
            passworddb.pwdb,
            [self.args['identity'], 'recipients']
        )
        self.recipient_list.append(str(self.args['identity']))
        self.recipient_list = list(set(self.recipient_list))
        print("The following users will receive the password:"******", ".join(self.recipient_list))
        print("The following password files have matched:")
        print(*filtered_pdb.keys(), sep="\n")
        correct_distribution = input("Are these lists correct? (y/N) ")
        if correct_distribution and correct_distribution.lower()[0] == 'y':
            passworddb.pwdb = filtered_pdb
            db_len = len(passworddb.pwdb.keys())
            i = 0
            self.progress_bar(i, db_len)
            for dist_pass, _ in passworddb.pwdb.items():
                password = PasswordEntry()
                password.read_password_data(dist_pass)
                if self.args['identity'] in password.recipients.keys():
                    # we shouldn't modify escrow on distribute
                    self.args['min_escrow'] = None
                    self.args['escrow_users'] = None
                    plaintext_pw = password.decrypt_entry(
                        self.identities.iddb[self.args['identity']],
                        passphrase=self.passphrase,
                        card_slot=self.args['card_slot'])

                    password.read_password_data(dist_pass)
                    password.add_recipients(secret=plaintext_pw,
                                            distributor=self.args['identity'],
                                            recipients=self.recipient_list,
                                            identitydb=self.identities,
                                            passphrase=self.passphrase,
                                            card_slot=self.args['card_slot'],
                                            pwstore=self.args['pwstore']
                                           )

                    password.write_password_data(dist_pass)
                    i += 1
                    self.progress_bar(i, db_len)
            # format the progress bar appropriately after the loop
            print("")
        else:
            print("Exiting due to wrong password list")
Exemplo n.º 6
0
 def _run_command_execution(self):
     ####################################################################
     """Run function for class."""
     ####################################################################
     password = PasswordEntry()
     password.read_password_data(
         path.join(self.args["pwstore"], self.args["pwname"]))
     distributor = password.recipients[self.identity["name"]]["distributor"]
     plaintext_pw = password.decrypt_entry(
         identity=self.identity,
         passphrase=self.passphrase,
         card_slot=self.args["card_slot"],
     )
     if not self.args["noverify"]:
         result = password.verify_entry(
             self.identity["name"],
             self.identities,
             distributor,
             self.session.query(Recipient).filter(
                 Recipient.name == distributor).first().certs,
         )
         if not result["sigOK"]:
             LOGGER.warning(
                 "Could not verify that %s correctly signed your password entry.",
                 result["distributor"],
             )
         if not result["certOK"]:
             LOGGER.warning(
                 "Could not verify the certificate authenticity of user '%s'.",
                 result["distributor"],
             )
     oldclip = paste()
     try:
         copy(plaintext_pw)
         yield f"Password copied into paste buffer for {self.args['time']} seconds"
         sleep(self.args["time"])
     finally:
         copy(oldclip)