Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DOMAIN="$1"
- MAILFILE="$2"
- if [ "$1" = "" ]; then
- echo usage: "mailgrep <domain.com> <mail.info.X>"
- exit 1
- elif [ "$2" = "" ]; then
- echo usage: "mailgrep <domain.com> mail.info"
- exit 1
- fi
- if [ "$DOMAIN" = "1" && "$MAILFILE" = "1" ]; then
- cat /var/log/$MAILFILE |grep "$DOMAIN" |cut -d " " -f6 |cut -d ":" -f1 |grep -v "postfix" sort -u > IDS.TXT
- echo "IDS Found!"
- done
- for i in `cat IDS.TXT`
- do
- grep $i /var/log/$MAILFILE |grep -E 'from|to' |awk '!( NR % 2 ) {$0 = $0"\n"} 1' > $DOMAIN.parse
- done
- echo "Complete ou will Find the results in $DOMAIN.parse"
Add Comment
Please, Sign In to add comment