Guest User

Untitled

a guest
Oct 18th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #!/bin/bash
  2. DOMAIN="$1"
  3. MAILFILE="$2"
  4.  
  5. if [ "$1" = "" ]; then
  6.   echo usage: "mailgrep <domain.com> <mail.info.X>"
  7.   exit 1
  8. elif [ "$2" = "" ]; then
  9.   echo usage: "mailgrep <domain.com> mail.info"
  10.   exit 1
  11. fi
  12.  
  13. if [ "$DOMAIN" = "1" && "$MAILFILE" = "1" ]; then
  14.   cat /var/log/$MAILFILE |grep "$DOMAIN"  |cut -d " " -f6 |cut -d ":" -f1 |grep -v "postfix" sort -u > IDS.TXT
  15.   echo "IDS Found!"
  16. done
  17.  
  18. for i in `cat IDS.TXT`
  19. do
  20.    grep $i /var/log/$MAILFILE |grep -E 'from|to' |awk '!( NR % 2 ) {$0 = $0"\n"} 1' > $DOMAIN.parse
  21. done
  22.  
  23. echo "Complete ou will Find the results in $DOMAIN.parse"
Add Comment
Please, Sign In to add comment