File: gmap2testssl.sh

package info (click to toggle)
testssl.sh 3.0.4%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,740 kB
  • sloc: sh: 18,734; perl: 980; makefile: 11
file content (42 lines) | stat: -rwxr-xr-x 1,020 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#/bin/sh -e

# utility which converts grepable nmap outout to testssl's file input

usage() {
     cat << EOF

usage:

    "$0 filename<.gmap>":               looks for filename/filename.gmap and converts into basename \$(filename)-testssl.txt"
    "$0 filename<.gmap>" "scan option": same as before, only adds testssl.sh scan option in front of IPs"

EOF
     exit 0
}

[ -z "$1" ] && usage
FNAME="$1"
OPT2ADD="${2:-}"

if ! grep -q gmap <<< "$FNAME"; then
     FNAME="$FNAME.gmap"
fi
[ ! -e $FNAME ] && echo "$FNAME not readable" && exit 2


TARGET_FNAME=${FNAME%.*}-testssl.txt

# test whether there's more than one "open" per line
while read -r oneline; do
     if [ $(echo "${oneline}" | tr ',' '\n' | grep -wc 'open') -gt 1 ]; then
          # not supported currently
          echo "$FNAME contains at least on one line more than 1x\"open\""
          exit 3
     fi
done < "$FNAME"

awk '/\<open\>/ { print "'"${OPT2ADD}"' " $2":"$5 }' "$FNAME" | sed 's/\/open.*$//g' >"$TARGET_FNAME"
exit $?

#  vim:ts=5:sw=5