From 67c584a2b2a90f8dd545110c14241514d4889024 Mon Sep 17 00:00:00 2001 From: Patrick Neumann Date: Mon, 16 Sep 2019 12:08:56 +0200 Subject: [PATCH] some bugfixes exclude mawk, fix for empty desc in mmls, fixed some bash calculations (base of 10 inseead of 8) --- tsk2html | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) mode change 100644 => 100755 tsk2html diff --git a/tsk2html b/tsk2html old mode 100644 new mode 100755 index 095dfc3..4452568 --- a/tsk2html +++ b/tsk2html @@ -29,6 +29,7 @@ # EXIT STATES: # 0 = success # 1 = (t)csh is not supported +# 16 = mawk is not supported # 2 = base64 is not installed # 3 = openssl is not installed # 4 = sleuthkit is not installed @@ -49,9 +50,9 @@ # istat and icat (The Sleuth Kit) out of a supplied image. # # REQUIREMENTS (Linux): -# awk, base64, basename, cat, date, dirname, file, fls, fsstat, grep, icat, -# img_stat, istat, ln, mkdir, mmls, openssl, printf, ps, sed, stat, tail -# and uname +# (g)awk (mawk is not supported!), base64, basename, cat, date, dirname, file, +# fls, fsstat, grep, icat, img_stat, istat, ln, mkdir, mmls, openssl, +# printf, ps, sed, stat, tail and uname # # BUGS: # --- @@ -79,7 +80,7 @@ # (privately) # # VERSION: -# 1.0 +# 1.1 # # LINK TO THE MOST CURRENT VERSION: # (Sorry, I bet, I'm not allowed to publish it over GitHub!) @@ -87,8 +88,11 @@ # CREATED: # 2016-11-11 # +# LAST MODIFIED: +# 2019-09-12 +# # COPYRIGHT (C): -# 2016 - Patrick Neumann +# 2016-2019 - Patrick Neumann # # LICENSE: # This program is free software: you can redistribute it and/or modify @@ -114,6 +118,9 @@ # # HISTORY: # 1.0 - Patrick Neumann - Initial (for the trainers eyes only) release +# 1.1 - Patrick Neumann - added exit 16 if only mawk is available +# - fixed support for empty desc in mmls +# - fixed some calculation (base of 10 inseead of 8) # #=============================================================================== @@ -167,6 +174,12 @@ readonly BIN_UNAME="$( ${BIN_WHICH} "uname" )" # common #------------------------------------------------------------------------------- # Check(s) for the existence of additional mandatory software. #------------------------------------------------------------------------------- +# mawk is not supported! +if ${BIN_AWK} -W version 2>/dev/null | grep -E "^mawk" > /dev/null 2>&1 ; then + ${BIN_PRINTF} "\n\033[01;31;40mERROR: please install gawk instead of mawk and retry... EXIT!!!\033[00m\n\n" + exit 16 +fi + # uncommon on FreeBSD 11 if [ -z "${BIN_BASE64}" ] ; then ${BIN_PRINTF} "\n\033[01;31;40mERROR: please install base64 and retry... EXIT!!!\033[00m\n\n" @@ -835,7 +848,7 @@ render_partition_table() { if [ -f "${FOLDER}/PART_${cnt}/fsstat.html" ] ; then line="${line}|[fsstat]" line="${line} [fls]" - LC_ALL=C cnt="$( ${BIN_PRINTF} "%03d" "$(( cnt + 1 ))" )" + LC_ALL=C cnt="$( ${BIN_PRINTF} "%03d" "$(( 10#$cnt + 1 ))" )" else line="${line}|-----" fi @@ -1018,7 +1031,7 @@ if [ -n "${MMLS}" ] ; then readonly UNITS="$( ${BIN_PRINTF} "%s" "${MMLS}" | ${BIN_SED} -n "3p" )" readonly PARTITIONS_DATA="$( ${BIN_PRINTF} "%s" "${MMLS}" \ | ${BIN_GREP} --extended-regexp "^[[:digit:]]" \ - | ${BIN_AWK} 'BEGIN{ OFS="|"; CNT=1; } { description = substr( $0, index( $0, $6 ) ); gsub( /\|/, " ", description ); print CNT++, $2, $3, $4, $5, description }' )" + | ${BIN_AWK} 'BEGIN{ OFS="|"; CNT=1; } { if ($6) description = substr( $0, index( $0, $6 ) ); else description = "-"; gsub( /\|/, " ", description ); print CNT++, $2, $3, $4, $5, description }' )" # Filesystem (or whatever) without a partition else readonly SCHEME="No partition type found" @@ -1084,7 +1097,7 @@ EOF render_template "${FLS}" >> "${FOLDER}/PART_${cnt}/fls.html" render_template "${FOOTER}" >> "${FOLDER}/PART_${cnt}/fls.html" fi - LC_ALL=C cnt="$( ${BIN_PRINTF} "%03d" "$(( cnt + 1 ))" )" + LC_ALL=C cnt="$( ${BIN_PRINTF} "%03d" "$(( 10#$cnt + 1 ))" )" done #-------------------------------------------------------------------------------