Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorFelix Geyer <debfx@fobos.de>2011-07-06 22:23:29 +0400
committerFelix Geyer <debfx@fobos.de>2011-07-06 22:23:29 +0400
commit87ee9b7c85bf5455bca7015141099048fbd87e15 (patch)
tree34045f281c6d7728c2b4e6fa063151f1587d56a5 /utils
parentef8935431cf0643ca2ee88b3441bdf9a43dbebd9 (diff)
Add kdbx-extract utility.
It dumps the raw xml string of a kdbx database to stdout.
Diffstat (limited to 'utils')
-rw-r--r--utils/CMakeLists.txt19
-rw-r--r--utils/kdbx-extract.cpp68
2 files changed, 87 insertions, 0 deletions
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
new file mode 100644
index 000000000..0eafdb14d
--- /dev/null
+++ b/utils/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 or (at your option)
+# version 3 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+include_directories(../src)
+
+add_executable( kdbx-extract kdbx-extract.cpp )
+target_link_libraries( kdbx-extract keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${LIBGCRYPT_LIBS} ${ZLIB_LIBRARIES} )
diff --git a/utils/kdbx-extract.cpp b/utils/kdbx-extract.cpp
new file mode 100644
index 000000000..a35a571ed
--- /dev/null
+++ b/utils/kdbx-extract.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 or (at your option)
+ * version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QFile>
+#include <QtCore/QStringList>
+#include <QtCore/QTextStream>
+
+#include "crypto/Crypto.h"
+#include "format/KeePass2Reader.h"
+#include "keys/CompositeKey.h"
+#include "keys/PasswordKey.h"
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ if (app.arguments().size() != 3) {
+ qCritical("Usage: kdbx-extract <password> <kdbx file>");
+ return 1;
+ }
+
+ Crypto::init();
+
+ CompositeKey key;
+ PasswordKey password;
+ password.setPassword(app.arguments().at(1));
+ key.addKey(password);
+
+ QFile dbFile(app.arguments().at(2));
+ if (!dbFile.exists()) {
+ qCritical("File does not exist.");
+ return 1;
+ }
+ if (!dbFile.open(QIODevice::ReadOnly)) {
+ qCritical("Unable to open file.");
+ return 1;
+ }
+
+ KeePass2Reader reader;
+ reader.setSaveXml(true);
+ reader.readDatabase(&dbFile, key);
+
+ if (reader.error()) {
+ qCritical("Error while reading the database.");
+ return 1;
+ }
+
+ QTextStream out(stdout);
+ out << reader.xmlData().constData() << "\n";
+
+ return 0;
+}