Skip to content

Instantly share code, notes, and snippets.

@woohooyeah
Created September 10, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woohooyeah/817a367725103a639cc6c7fde98f92d7 to your computer and use it in GitHub Desktop.
Save woohooyeah/817a367725103a639cc6c7fde98f92d7 to your computer and use it in GitHub Desktop.
## make-spammers-list.sh v0.1
## Dorian Harmans <contact@dorianharmans.nl>
##
#!/bin/bash
if [ -e /var/log/mail.log ]; then
( cat /var/log/mail.log | grep "helo=1 auth=0/1 quit=1 commands=2/3" | \
egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort | uniq ) \
> /root/spammers-new.txt
else
echo -e "Failed!\nReason: /var/log/mail.log not found"
exit 1
fi
if [ -e /root/spammers-new.txt ]; then
sort /root/spammers-new.txt | uniq >> /root/spammers-masterlist.txt
else
echo -e "Failed!\nReason: /root/spammers-new.txt not found"
exit 1
fi
if [ -e /root/spammers-masterlist.txt ]; then
sort /root/spammers-masterlist.txt | uniq > /root/spammers.txt
cp /root/spammers.txt /root/spammers-masterlist.txt
else
echo -e "Failed!\nReason: /root/spammers-masterlist.txt not found"
exit 1
fi
if [ -e /root/spammers.txt ]; then
wc -l /root/spammers.txt
else
echo -e "Failed!\nReason: /root/spammers.txt not found"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment