#!/bin/bash

for arg in "$@"; do
rm nms-"$@".log
ts=$(date +%Y-%m-%d-%T)
clear
echo "================================================================================" | tee nms-"$@".log
echo "DATE: $ts" | tee -a nms-"$@".log
echo "HOST: $@" | tee -a nms-"$@".log
echo "--------------------------------------------------------------------------------" | tee -a nms-"$@".log
#read x
echo "Running Nmap scan on $@..."
nmap -A -v -sV -sC -Pn --script vulners,http-sql-injection,http-unsafe-output-escaping,http-enum.nse "$@" | tee -a nms-"$@".log
echo "--------------------------------------------------------------------------------" 
echo " PRESS R FOR REPORT OR Q TO EXIT "
echo "================================================================================"
read -r -n 1 -s key
  if [ "$key" = "R" ] || [ "$key" = "r" ]; then
    echo "================================================================================"
    echo " GENERATING REPORT FILE: "$@".pdf..."
    echo "--------------------------------------------------------------------------------"
    soffice --headless --convert-to pdf --outdir ./ nms-"$@".log
    rm nms-"$@".log
    open nms-"$@".pdf
    exit
  else
    if [ "$key" = "q" ] || [ "$key" = "Q" ]; then
    rm nms-"$@".log
    exit
  fi
  fi
echo 'Done.'
#read -n1
#clear
rm nms-"$@".log
done
