How to use the pykeepass.PyKeePass function in pykeepass

To help you get started, we’ve selected a few pykeepass examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libkeepass / pykeepass / tests / tests.py View on Github external
def open(self):
        self.kp = PyKeePass(
            os.path.join(base_dir, 'test_attachment.kdbx'),
            password=self.password,
            keyfile=os.path.join(base_dir, self.keyfile)
        )
github libkeepass / pykeepass / tests / tests.py View on Github external
def test_ctx_manager(self):
        with PyKeePass(os.path.join(base_dir, 'test4.kdbx'), password='password', keyfile=base_dir + '/test4.key') as kp:
            results = kp.find_entries_by_username('foobar_user', first=True)
            self.assertEqual('foobar_user', results.username)
github libkeepass / pykeepass / tests / tests.py View on Github external
def setUp(self):
        self.kp = PyKeePass(
            os.path.join(base_dir, self.database),
            password=self.password,
            keyfile=os.path.join(base_dir, self.keyfile)
        )
github libkeepass / pykeepass / tests / tests.py View on Github external
def test_open_error(self):
        with self.assertRaises(CredentialsIntegrityError):
            database = 'test4.kdbx'
            invalid_password = 'foobar'
            keyfile = os.path.join(base_dir, 'test4.key')
            PyKeePass(
                os.path.join(base_dir, database),
                password=invalid_password,
                keyfile=keyfile
            )
        with self.assertRaises(CredentialsIntegrityError):
            database = 'test4.kdbx'
            password = 'password'
            invalid_keyfile = os.path.join(base_dir, 'test3.key')
            PyKeePass(
                os.path.join(base_dir, database),
                password=password,
                keyfile=invalid_keyfile
            )
github libkeepass / pykeepass / tests / tests.py View on Github external
def setUp(self):
        shutil.copy(
            os.path.join(base_dir, self.database),
            os.path.join(base_dir, 'change_creds.kdbx')
        )
        self.kp = PyKeePass(
            os.path.join(base_dir, self.database),
            password=self.password,
            keyfile=os.path.join(base_dir, self.keyfile)
        )
        self.kp_tmp = PyKeePass(
            os.path.join(base_dir, 'change_creds.kdbx'),
            password=self.password,
            keyfile=os.path.join(base_dir, self.keyfile)
        )
github Evidlo / passhole / passhole / passhole.py View on Github external
password_file = os.path.expanduser('~/.passhole.kdbx')

base_dir = os.path.dirname(os.path.realpath(__file__))
# taken from http://www.mit.edu/~ecprice/wordlist.10000
wordlist = os.path.join(base_dir, 'wordlist.10000')
template_password_file = os.path.join(base_dir, '.passhole.kdbx')

# create database if necessary
if not os.path.exists(password_file):
    log.info("No database file found at {0}".format(password_file))
    log.info("Creating it...")
    shutil.copy(template_password_file, password_file)

# load database
kp = PyKeePass(password_file, password='shatpass')


# select an entry using `prog`, then type the password
# if `tabbed` is True, type out username, TAB, password
def dmenu_entries(args):
    entry_paths = [entry.path for entry in kp.entries]
    items = '\n'.join(entry_paths)

    # get the entry from dmenu
    p = Popen(args.prog, stdout=PIPE, stdin=PIPE, stderr=STDOUT)
    stdout = p.communicate(input=items)[0].decode()
    selection_path = stdout.rstrip('\n').lstrip('[').rstrip(']')

    # if nothing was selected, return None
    if not selection_path:
        return None
github fopina / kdbxpasswordpwned / kdbxpasswordpwned.py View on Github external
def main(args=None):
    opt = build_parser().parse_args(args)

    with pykeepass.PyKeePass(opt.kdbx, password=getpass.getpass(), keyfile=opt.keyfile) as kdb:
        for entry in kdb.entries:
            if not entry.password:
                continue
            r = check_hash(entry.password)
            if r > 0:
                m = 'Password for %s seen %d times before' % (entry.title, r)
                if opt.show_user:
                    m += ' - %s' % entry.username
                if opt.show_password:
                    m += ' - %s' % entry.password
                print(m)
github FalkAlexander / PasswordSafe / passwordsafe / database_manager.py View on Github external
def __init__(self, database_path, password=None, keyfile=None, logging_manager=None):
        self.logging_manager = logging_manager
        self.db = PyKeePass(database_path, password, keyfile)
        self.database_path = database_path
        self.database_file_descriptor = Gio.File.new_for_path(database_path)
        self.password = password
github libkeepass / pykeepass / pykeepass / pkpwrite.py View on Github external
def write_entry(kdbx_file, kdbx_password, group_path,
                entry_title, entry_username, entry_password, entry_url,
                entry_notes, entry_tags, kdbx_keyfile=None,
                force_creation=False, outfile=None):
    logging.info(
        'Attempt to write entry "{}: {}:{}" to {}'.format(
            entry_title, entry_username, entry_password, group_path
        )
    )
    samba_db = False
    if kdbx_file.startswith('smb://'):
        samba_db = True
        smb_kdbx_file = smb_retrieve(kdbx_file)
    kp = PyKeePass(
        smb_kdbx_file if samba_db else kdbx_file,
        password=kdbx_password,
        keyfile=kdbx_keyfile
    )
    dest_group = kp.find_groups_by_path(group_path, first=True)
    kp.add_entry(
        destination_group=dest_group,
        title=entry_title,
        username=entry_username,
        password=entry_password,
        url=entry_url,
        notes=entry_notes,
        tags=entry_tags,
        force_creation=force_creation
    )