Yax
2017-09-06 b8b614309acd67eafa4aa4197426100aaff5af80
Vilain reporting
3 files modified
16 ■■■■■ changed files
Makefile 8 ●●●● patch | view | raw | blame | history
vilain 2 ●●● patch | view | raw | blame | history
vilain.py 6 ●●●● patch | view | raw | blame | history
Makefile
@@ -2,7 +2,7 @@
# See LICENSE file for copyright and license details.
#
# vilain version
VERSION = 0.6
VERSION = 0.7
# Customize below to fit your system
# paths
@@ -13,10 +13,14 @@
    @echo installing executable file to ${DESTDIR}${PREFIX}/bin
    @mkdir -p ${DESTDIR}${PREFIX}/bin
    @cp -f vilain ${DESTDIR}${PREFIX}/bin
    @cp -f vilainreport ${DESTDIR}${PREFIX}/bin
    @echo installing script file to ${DESTDIR}${PREFIX}/sbin
    @cp -f vilain.py ${DESTDIR}${PREFIX}/sbin
    @cp -f vilainreport.py ${DESTDIR}${PREFIX}/sbin
    @chmod 755 ${DESTDIR}${PREFIX}/bin/vilain
    @chmod 755 ${DESTDIR}${PREFIX}/bin/vilainreport
    @chmod 644 ${DESTDIR}${PREFIX}/sbin/vilain.py
    @chmod 644 ${DESTDIR}${PREFIX}/sbin/vilainreport.py
    @echo installing init script in /etc/rc.d
    @cp -f vilain.rc /etc/rc.d/vilain
    @chmod 755 /etc/rc.d/vilain
@@ -29,7 +33,9 @@
uninstall:
    @echo removing executable file from ${DESTDIR}${PREFIX}/bin
    @rm -f ${DESTDIR}${PREFIX}/bin/vilain
    @rm -f ${DESTDIR}${PREFIX}/bin/vilainreport
    @rm -f ${DESTDIR}${PREFIX}/sbin/vilain.py
    @rm -f ${DESTDIR}${PREFIX}/sbin/vilainreport.py
    @echo removing manual page to ${DESTDIR}${MANPREFIX}/
    @rm -f ${DESTDIR}${MANPREFIX}/vilain.1
vilain
@@ -1,5 +1,5 @@
#!/bin/sh
# script to launch vilain with the latest python3 version avaiable
# script to launch vilain with the latest python3 version available
PYTHONVERSION=$(ls -l /usr/local/bin/python3.* |grep -Eo "3\.[0-9]" |tail -n1)
PYTHON="/usr/local/bin/python$PYTHONVERSION"
vilain.py
@@ -30,7 +30,7 @@
import time
CONFIGFILE = "/etc/vilain.conf"
VERSION = "0.6"
VERSION = "0.7"
vilain_table = "vilain_bruteforce"
LOGFILE = "/var/log/daemon"
@@ -46,7 +46,7 @@
    log_handler = logging.handlers.WatchedFileHandler(LOGFILE)
    formatter = logging.Formatter(
            '%(asctime)s %(module)s:%(funcName)s:%(message)s',
            '%b %d %H:%M:%S')
            '%Y-%m-%d %H:%M:%S')
    log_handler.setFormatter(formatter)
    logger.addHandler(log_handler)
    logger.setLevel(logging.INFO)
@@ -182,7 +182,7 @@
            logger.info("{} detected, reason {}, count: {}, maxtries: {}".format(ip, reason, n_ip, maxtries))
            if n_ip >= maxtries:
                ret = subprocess.call(["pfctl", "-t", self.vilain_table, "-T", "add", ip])
                logger.info("Blacklisting {}, return code:{}".format(ip, ret))
                logger.info("Blacklisting {}, reason {}, return code:{}".format(ip, reason, ret))
            #for debugging, this line allow us to see if the script run until here
            logger.debug('ban_ips end:{}'.format(self.ip_seen_at))