#!/bin/bash
# ein kleines script zur auswertung wer denn da in den letzten logfiles an unbekanntem Mailadressen einliefern wollte  
# bitte passt es evtl. auf eure bedürfnisse an.
# Verbesserungsvorschläge nehme ich gerne entgegen unter driessen@fblan.de
# viel spaß damit


CURRLOG=/var/log/mail.log
LASTLOG=/var/log/mail.log.0
ARCHLOG=/var/log/mail.log.*.gz

cat $LASTLOG $CURRLOG | \
	egrep "User unknown" | \
	cut -d "<" -f 3 | \
	cut -d ">" -f 1 | \
	sort | \
	uniq | \
	awk '{print($1, $2, $3)}'


# mal angefangen aber nicht mehr fertig gemacht (noch nicht)

#bx-ob.rzone.de[81.169.146.155]
#|while read line
# awk '{print($1, $2)}' 
#do
#  ipaddress=`echo $line  | cut -d " " -f 2`
#  anzahl=`echo $line | cut -d " " -f 1`
#  reverse_dns=`dig +short -x ${ipaddress}`
#   echo "na wen haben wir denn da erwischt:	$anzahl		$ipaddress	$reverse_dns"
#done

#zcat $ARCHLOG | egrep "NOQUEUE: reject: RCPT from(.*): 550 5\.7\.1(.*)(dynamic IP|dynip|PTR\/rDNS|Spamer|Spammer|DNS MX settings)" | cut -d "[" -f 3 | cut -d "]" -f 1 | sort |uniq -c | awk '{print($1, $2)}'|while read line
# awk '{print($1, $2)}'
#do
#  ipaddress=`echo $line  | cut -d " " -f 2`
#  anzahl=`echo $line | cut -d " " -f 1`
#  reverse_dns=`dig +short -x ${ipaddress}`
#    echo "na wen haben wir denn da erwischt:	$anzahl	$ipaddress	$reverse_dns"
#done

