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/f7cd7eaca37766b2661a196f6befebf0 to your computer and use it in GitHub Desktop.
Save woohooyeah/f7cd7eaca37766b2661a196f6befebf0 to your computer and use it in GitHub Desktop.
## make-spammers-list-ipv6.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-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | sort | uniq ) > /root/spammers-new-ipv6.txt
else
echo -e "Failed!\nReason: /var/log/mail.log not found"
exit 1
fi
if [ -e /root/spammers-new-ipv6.txt ]; then
sort /root/spammers-new-ipv6.txt | uniq >> /root/spammers-masterlist-ipv6.txt
else
echo -e "Failed!\nReason: /root/spammers-new-ipv6.txt not found"
exit 1
fi
if [ -e /root/spammers-masterlist-ipv6.txt ]; then
sort /root/spammers-masterlist-ipv6.txt | uniq > /root/spammers-ipv6.txt
cp /root/spammers-ipv6.txt /root/spammers-masterlist-ipv6.txt
else
echo -e "Failed!\nReason: /root/spammers-masterlist-ipv6.txt not found"
exit 1
fi
if [ -e /root/spammers-ipv6.txt ]; then
wc -l /root/spammers-ipv6.txt
else
echo -e "Failed!\nReason: /root/spammers-ipv6.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