#!/bin/bash
# Example for a KILL_RUN_CMD in /etc/portsentry/portsentry.conf
# by  Peter Gerhardt <peter.gerhardt@uni-konstanz.de>
# and Guido Guenther <guido.guenther@uni-konstanz.de>
#
# $Id: kill_cmd,v 1.3 2001/07/19 21:02:34 agx Exp $

# grep into /etc/services to check which port was scanned
MODE=${3/[sa]/}		# get rid of s and a
SERVICEINFO=`grep "[[:space:]]$2/$MODE" /etc/services` 

# can we get some info about the attacker?
FINGERINFO=`/usr/sbin/safe_finger -l @$1 2>/dev/null`

cat <<EOF | mail root -s "PortSentry: $1 scanned $HOSTNAME:$2/$3"

Someone @$1 scanned on host $HOSTNAME

the service (from /etc/services): 
$SERVICEINFO

additional information (from reverse finger):
$FINGERINFO

Cheers,
	Portsentry
EOF
