From b7b635b90f16b0795a4a5415147e20590ca7fe42 Mon Sep 17 00:00:00 2001 From: apriestman <apriestman@basistech.com> Date: Mon, 10 Aug 2020 14:07:07 -0400 Subject: [PATCH] Restore password option to the usage statement. Generate error if password is given without file system type. --- tools/fstools/fls.cpp | 8 +++++++- tools/fstools/fsstat.cpp | 8 +++++++- tools/fstools/icat.cpp | 8 +++++++- tools/fstools/istat.cpp | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/fstools/fls.cpp b/tools/fstools/fls.cpp index a988f85d2..ece240bee 100644 --- a/tools/fstools/fls.cpp +++ b/tools/fstools/fls.cpp @@ -67,7 +67,7 @@ usage() "\t-z: Time zone of original machine (i.e. EST5EDT or GMT) (only useful with -l)\n"); tsk_fprintf(stderr, "\t-s seconds: Time skew of original machine (in seconds) (only useful with -l & -m)\n"); - //tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); + tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); exit(1); } @@ -255,6 +255,12 @@ main(int argc, char **argv1) usage(); } + /* Passwords only work if the file system type has been specified */ + if (strlen(password) > 0 && fstype == TSK_FS_TYPE_DETECT) { + tsk_fprintf(stderr, "File system type must be specified to use a password\n"); + usage(); + } + /* Set the full flag to print the full path name if recursion is ** set and we are only displaying files or deleted files diff --git a/tools/fstools/fsstat.cpp b/tools/fstools/fsstat.cpp index e6a1afa24..fcdae9e53 100644 --- a/tools/fstools/fsstat.cpp +++ b/tools/fstools/fsstat.cpp @@ -39,7 +39,7 @@ usage() "\t-B pool_volume_block: Starting block (for pool volumes only)\n"); tsk_fprintf(stderr, "\t-v: verbose output to stderr\n"); tsk_fprintf(stderr, "\t-V: Print version\n"); - //tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); + tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); exit(1); } @@ -173,6 +173,12 @@ main(int argc, char **argv1) usage(); } + /* Passwords only work if the file system type has been specified */ + if (strlen(password) > 0 && fstype == TSK_FS_TYPE_DETECT) { + tsk_fprintf(stderr, "File system type must be specified to use a password\n"); + usage(); + } + if ((img = tsk_img_open(argc - OPTIND, &argv[OPTIND], imgtype, ssize)) == NULL) { diff --git a/tools/fstools/icat.cpp b/tools/fstools/icat.cpp index 44e6809c5..2f6622cf2 100644 --- a/tools/fstools/icat.cpp +++ b/tools/fstools/icat.cpp @@ -56,7 +56,7 @@ usage() tsk_fprintf(stderr, "\t-S snap_id: Snapshot ID (for APFS only)\n"); tsk_fprintf(stderr, "\t-v: verbose to stderr\n"); tsk_fprintf(stderr, "\t-V: Print version\n"); - //tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); + tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); exit(1); } @@ -203,6 +203,12 @@ main(int argc, char **argv1) usage(); } + /* Passwords only work if the file system type has been specified */ + if (strlen(password) > 0 && fstype == TSK_FS_TYPE_DETECT) { + tsk_fprintf(stderr, "File system type must be specified to use a password\n"); + usage(); + } + /* Get the inode address */ if (tsk_fs_parse_inum(argv[argc - 1], &inum, &type, &type_used, &id, &id_used)) { diff --git a/tools/fstools/istat.cpp b/tools/fstools/istat.cpp index 9a0f702c0..75fb6c4b6 100644 --- a/tools/fstools/istat.cpp +++ b/tools/fstools/istat.cpp @@ -55,7 +55,7 @@ usage() tsk_fprintf(stderr, "\t-S snap_id: Snapshot ID (for APFS only)\n"); tsk_fprintf(stderr, "\t-v: verbose output to stderr\n"); tsk_fprintf(stderr, "\t-V: print version\n"); - //tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); + tsk_fprintf(stderr, "\t-k password: Decryption password for encrypted volumes\n"); exit(1); } @@ -216,6 +216,12 @@ main(int argc, char **argv1) usage(); } + /* Passwords only work if the file system type has been specified */ + if (strlen(password) > 0 && fstype == TSK_FS_TYPE_DETECT) { + tsk_fprintf(stderr, "File system type must be specified to use a password\n"); + usage(); + } + /* if we are given the inode in the inode-type-id form, then ignore * the other stuff w/out giving an error * -- GitLab