From 3544014fe34863e95fdfdf61d2227ee84d4d3087 Mon Sep 17 00:00:00 2001 From: Dirk Date: Sun, 25 Jul 2021 16:40:16 +0200 Subject: [PATCH] Fix problem when nmap file has .txt extension (3.0) This addresses a bug filed in #1935 in 3.1dev when the supplied file has a .txt extension. In this scenario the input file was nulled as from the input file in nmap format an internal input file was generated which has a .txt extension, in the same directory. The idea was to persist the file for the user. Now, this internal input file is ephemeral and only written to $TEMPDIR. --- testssl.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/testssl.sh b/testssl.sh index 82268b3..4c9e61a 100755 --- a/testssl.sh +++ b/testssl.sh @@ -19003,17 +19003,12 @@ nmap_to_plain_file() { else fatal "Nmap file $FNAME is not in grep(p)able format (-oG filename.g(n)map)" $ERR_FNAMEPARSE fi - # strip extension and create output file *.txt in same folder + # create ${FNAME%.*}.txt in $TEMPDIR target_fname="${FNAME%.*}.txt" - > "${target_fname}" - if [[ $? -ne 0 ]]; then - # try to just create ${FNAME%.*}.txt in the same dir as the gnmap file failed. - # backup is using one in $TEMPDIR - target_fname="${target_fname##*\/}" # strip path (Unix) - target_fname="${target_fname##*\\}" # strip path (Dos) - target_fname="$TEMPDIR/$target_fname" - > "${target_fname}" || fatal "Cannot create \"${target_fname}\"" $ERR_FCREATE - fi + target_fname="${target_fname##*\/}" # strip path (Unix) + target_fname="${target_fname##*\\}" # strip path (Dos) + target_fname="$TEMPDIR/$target_fname" + > "${target_fname}" || fatal "Cannot create \"${target_fname}\"" $ERR_FCREATE # Line x: "Host: AAA.BBB.CCC.DDD () Status: Up" # Line x+1: "Host: AAA.BBB.CCC.DDD () Ports: 443/open/tcp//https///"