Browse Source

support for dumping all fields in file.

remove-cryptography-dependency
Herbert Poul 5 years ago
parent
commit
b7275a297f
  1. 17
      bin/kdbx.dart

17
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<void> 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'));

Loading…
Cancel
Save