#!/bin/sh
#
# 
# insight.sara: version 1.0, 10 Apr 00 Steve Lodin (Steven.Lodin@roche.com)
# modified Jan 01, Oct 01 Sam Kline
#
#  Searches for Compaq Insight Manager (CIM) web servers that
#  serve up password files
#

. config/paths.sh

$ECHO "BEGIN"
GETSTR="GET / HTTP/1.0\n\n"
tmp_file="./tmp_file.$$"
status="OK"
target=$1
port=2301

if $TEST "X$target" = "X" ; then
        $ECHO Usage $0 target
        exit 1
fi

$TCP_SCAN -b -s "$GETSTR" $target $port > $tmp_file 2> /dev/null
# If no "OK", then not running CIM
VERSION=`$GREP VersionCheck $tmp_file|$GREP var`
if [ -z "$VERSION" ]; then
  $RM -f $tmp_file
  exit 0
fi

if [ "`$ECHO $VERSION | $GREP [^.]1\.[0-9]`" ]; then
   status=BAD
elif [ "`$ECHO $VERSION | $GREP [^.]2\.[012]`" ]; then
   status=MAYBE
elif [ "`$ECHO $VERSION | $GREP [^.]5\.[2-9]`" ]; then
   status=OK
else
   status=MAYBE
fi
if [ "$status" = BAD ]; then
	service="http"
	status="a"
	trustee="ANY@ANY"
	trusted="ANY@ANY"
	service_output="Compaq Insight Manager http server"
	text="Compaq Insight Manager is vulnerable"
       	severity="bo"
	$ECHO "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text"
elif [ "$status" = MAYBE ]; then
 	service="http"
        status="a"
        trustee="ANY@ANY"
        trusted="ANY@ANY"
	service_output="Compaq Insight Manager http server"
        text="Compaq Insight Manager may be vulnerable"
        severity="zcio"
        $ECHO "$target|$service|$status|$severity|$trustee|$trusted|$service_output|$text"
fi

$RM -f $tmp_file
exit 0

# finish
