Giter VIP home page Giter VIP logo

python-keepass's Introduction

keepassc and python-keepass

This provides command line and Python interfaces for operating on files in KeePass format v3 (used by KeePass 1.x, and KeePassX). Note, this is not the format used by the KeePass application version 2.x.

Notes of caution

Before using this code, understand the its (known) security and correctness limitations:

  • Unlike the KeePass/KeePassX GUI applications this code makes no attempt to secure its memory. Input files read in are stored in memory fully decrypted.

  • It is quite easy to display the stored passwords in plain text, although the defaults try to avoid this.

  • Specifying the master key on the command line will leave traces in your shells history and in the process list.

  • While input files are treated as read-only, keep backups of any files written by KeePass/KeePassX until you are assured that files written by this code are usable.

  • Key files are not currently supported.

Prerequisites and Installation

You will need to install the python-crypto package (providing the "Crypto" module). On a well behaved system do:

sudo apt-get install python-crypto

If installing into a virtualenv this prerequisite will be installed for you:

virtualenv /path/to/venv
source /path/to/venv/bin/activate
cd python-keepass
python setup.py install

Command line

The command line interface is run like:

keepassc [general_options] [command command_options] ...

Multiple commands can be specified and will be executed in order. They operate on an in-memory instance of the database file. An example,

keepass open -m secret file.kdb \
        dump -p -f '%(username)s password is: %(password)s' \
        save -m newsecret backup.kdb

Online help:

keepass -h      # short usage
keepass help    # full usage

Python Modules

Low level file access

from keepass import kpdb
db = kpdb.Database(filename,masterkey)
print db   # warning: displayed passwords in plaintext!

References and Credits

PyCrypto help

The giants on whose shoulders this works stands

First, thanks to the original authors, contributors and community behind KeePass and KeePassX. I am merely a user of KeePassX.

A big credit is due to rudi & shirou (same hacker?) for the following:

Looking through KeePass/KeePassX source made my head swim. Only after reviewing their work could I get started.

See also

  • kppy Python interface and KeepassC command line interface.

License

This package is Free Software licensed to you under the GPL v2 or later at your discretion. See the LICENSE.txt file for details.

python-keepass's People

Contributors

brettviren avatar friz-zy avatar steelpangolin avatar timgates42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-keepass's Issues

License

Hi,
I would like to use this module in my code, but i create project under LGPL v3.
So, may i change license in my fork?

Best regards,
Filipp Frizzy

Add and edit database

As fas as I can tell, this program only allows me to view the database, and change the master password.
It's not very useful until it can actually add new entries and edit them.

Input strings must be a multiple of 16 in length

Hi. Does this code work on Windows?
I'm attempting to run it on:

  • Windows 7
  • Python 2.7
  • PyCrypto 2.6 for Python 2.7
  • A Keepass 1.24 database file

I get the following stack trace:

Traceback (most recent call last):
File "keepassc.py", line 10, in
cliobj()
File "./python\keepass\cli.py", line 78, in call
meth(cmdopts)
File "./python\keepass\cli.py", line 143, in _open
self.db = kpdb.Database(files[0],opts.masterkey)
File "./python\keepass\kpdb.py", line 29, in init
self.read(filename)
File "./python\keepass\kpdb.py", line 55, in read
self.header.encryption_iv)
File "./python\keepass\kpdb.py", line 99, in decrypt_payload
payload = self.decrypt_payload_aes_cbc(payload, finalkey, iv)
File "./python\keepass\kpdb.py", line 116, in decrypt_payload_aes_cbc
payload = cipher.decrypt(payload)
File "C:\Python27\lib\site-packages\Crypto\Cipher\blockalgo.py", line 295, in decrypt
return self._cipher.decrypt(ciphertext)
ValueError: Input strings must be a multiple of 16 in length

keepassc.py doesn't import sys

I get an error while trying to run keepassc.py

keepassc.py -h
Traceback (most recent call last):
  File "/Library/Frameworks/EPD64.framework/Versions/Current/bin/keepassc.py", line 12, in <module>
    cliobj = cli.Cli(sys.argv[1:])
NameError: name 'sys' is not defined

looks like it needs an import sys

Bad sigs

Hi guys, first of all great work on this project. I know it's not been worked on for a little while but it's the only module like it that I have found.

When I open my example blank database I created with the latest KeePass program I get the below error:

./keepassc.py open blank.kdbx 
Traceback (most recent call last):
  File "./keepassc.py", line 16, in <module>
    cliobj()
  File "./python/keepass/cli.py", line 86, in __call__
    meth(cmdopts)
  File "./python/keepass/cli.py", line 151, in _open
    self.db = kpdb.Database(files[0],opts.masterkey)
  File "./python/keepass/kpdb.py", line 36, in __init__
    self.read(filename)
  File "./python/keepass/kpdb.py", line 50, in read
    self.header = DBHDR(headbuf)
  File "./python/keepass/header.py", line 79, in __init__
    if buf: self.decode(buf)
  File "./python/keepass/header.py", line 130, in decode
    raise IOError,msg
IOError: Bad sigs:
2594363651 3041655653
2594363651 3041655655

I presume the sigs that need to be changed are in the header.py file but I was kind of hoping for a plug and play solution so I'm not sure what needs to be done. Any help would be greatly appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.