Tag Archive for 'C/C++'

Accessing KeePass databases from PHP scripts

Always wanted to write an extension for PHP! :-) More precisely, an extension which allows PHP scripts to access KeePass databases. Today I finally found time to read some articles (here, here, and here) on PHP extension writing. I compiled PHP 5.x and KeePass 2., and started the project PHPpw, which is supposed to bring together these 2 worlds (PHP & KeePass). PHPpw (pw = password) is open source and available at SourceForge.net. The extension is a proof of concept and provides the following PHP functions:

  • keepass_open(): Opens a KeePass database. The first argument is the filename of the database; the second argument is the masterkey.
  • keepass_close(): Closes a previously opened KeePass database.
  • keepass_get_name(): Delivers the name of the root folder of the KeePass database.
1
2
3
4
5
if ( !keepass_open("test.kdbx", "test1234") ) die();
 
echo keepass_get_name();
 
keepass_close();

The project has several limitations, e.g., only one KeePass database can be used. Further, once a KeePass database is opened, it is accessible to all users. Anyway, check out the source code and feel free to join this project today!