#!/bin/bash
#
# SCRIPT: wrapper for whatiswrong sdk command
# AUTHOR: Eric Partington
# DATE: 2017/01/25
# VERSION: 0.1
#
# PLATFORM: Linux Centos 6.x (Netwitness L P 10.6)
#
# PURPOSE: snort rules deployment script
# LICENSE: GNU Public License v2 (http://gnu.org/licenses/)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License for more details.
#
###########################################################################################################

# values
DATE=`date +%Y%m%d`
DAYS=2
PORTLIST="
==========================
Service Port Reference::
==========================
Archiver: 50008
Broker: 50003
Concentrator: 50005
Log Decoder: 50002
Log Collector: 50001
VLC: 50001
WLC: 50001
Packet Decoder: 50004

"

printf "Username: "
read USERNAME

stty -echo
printf "Password: "
read PASSWORD
stty echo
printf "\n"

printf "Hostname: "
read HOST


printf "$PORTLIST"
printf "Port: "
read PORT

#check for port to service mapping and name the file appropriately
case $PORT in
    50008)
        SERVICE="archiver"
        ;;
    50003)
        SERVICE="broker"
        ;;
    50005)
        SERVICE="concentrator"
        ;;
    50002)
        SERVICE="logdecoder"
        ;;
    50001)
        SERVICE="logcollector"
        ;;
    50004)
        SERVICE="packetdecoder"
        ;;
        *) ;;
esac

#read the file location to store the output from the script
#printf "OUTPUT ABSOLUTE PATH: "
#read OUTPUTPATH

#create the filename of the output file
OUTPUTSTRING=$DATE"-"$SERVICE"-"$HOST".txt"


#printf "\n"$USERNAME
#printf "\n"$PASSWORD

NwConsole -c "login $HOST:$PORT $USERNAME $PASSWORD" -c "whatiswrong days=$DAYS pathname=$OUTPUTSTRING" -c "exit"
