From b7275a297f48c0b9bcf372bd4e645b1d77d9e4a7 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Thu, 4 Jun 2020 11:38:31 +0200 Subject: [PATCH] support for dumping all fields in file. --- bin/kdbx.dart | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/kdbx.dart b/bin/kdbx.dart index 18a97c0..3181c99 100644 --- a/bin/kdbx.dart +++ b/bin/kdbx.dart @@ -106,6 +106,8 @@ class CatCommand extends KdbxFileCommand { CatCommand() { argParser.addFlag('decrypt', help: 'Force decryption of all protected strings.'); + argParser.addFlag('all-fields', + help: 'Force decryption of all protected strings.'); } @override @@ -116,6 +118,8 @@ class CatCommand extends KdbxFileCommand { bool get forceDecrypt => argResults['decrypt'] as bool; + bool get allFields => argResults['all-fields'] as bool; + @override Future runWithFile(KdbxFile file) async { catGroup(file.body.rootGroup); @@ -127,10 +131,19 @@ class CatCommand extends KdbxFileCommand { for (final group in group.groups) { catGroup(group, depth: depth + 1); } + final valueToSting = (StringValue value) => + forceDecrypt ? value?.getText() : value?.toString(); + for (final entry in group.entries) { final value = entry.getString(KdbxKey('Password')); - print( - '$indent `- ${entry.getString(KdbxKey('Title'))?.getText()}: ${forceDecrypt ? value?.getText() : value?.toString()}'); + print('$indent `- ${entry.getString(KdbxKey('Title'))?.getText()}: ' + '${valueToSting(value)}'); + if (allFields) { + print(entry.stringEntries + .map((field) => + '$indent ${field.key} = ${valueToSting(field.value)}') + .join('\n')); + } print(entry.binaryEntries .map((b) => '$indent `- file: ${b.key} - ${b.value.value.length}') .join('\n'));