mirror of https://github.com/fail2ban/fail2ban
- removing this file. Replaced by fail2ban.py
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@11 a942ae1a-1317-0410-a47c-b1dcaea8d6050.6
parent
012301b644
commit
5fc0a65163
74
fail2ban
74
fail2ban
|
@ -1,74 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# This file is part of Fail2Ban.
|
||||
#
|
||||
# Fail2Ban is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Fail2Ban is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Fail2Ban; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
# Author: Cyril Jaquier
|
||||
#
|
||||
# $Revision$
|
||||
|
||||
__author__ = "Cyril Jaquier"
|
||||
__version__ = "$Revision$"
|
||||
__date__ = "$Date$"
|
||||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
||||
__license__ = "GPL"
|
||||
|
||||
import posix, time, sys
|
||||
|
||||
from firewall.iptables import Iptables
|
||||
from logreader.metalog import Metalog
|
||||
|
||||
def checkForRoot():
|
||||
""" Check for root user.
|
||||
"""
|
||||
uid = `posix.getuid()`
|
||||
if uid == '0':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
fireWall = Iptables(600)
|
||||
logFile = Metalog("./log-test/test", 600)
|
||||
|
||||
if not checkForRoot():
|
||||
print "You must be root."
|
||||
#sys.exit(-1)
|
||||
|
||||
logFile.addIgnoreIP("127.0.0.1")
|
||||
|
||||
while True:
|
||||
try:
|
||||
fireWall.checkForUnBan()
|
||||
|
||||
if not logFile.isModified():
|
||||
time.sleep(1)
|
||||
continue
|
||||
|
||||
failList = logFile.getPwdFailure()
|
||||
|
||||
iterFailList = failList.iteritems()
|
||||
for i in range(len(failList)):
|
||||
element = iterFailList.next()
|
||||
if element[1][0] > 2:
|
||||
fireWall.addBanIP(element[0])
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print 'Restoring iptables...'
|
||||
fireWall.flushBanList()
|
||||
print 'Exiting...'
|
||||
sys.exit(0)
|
Loading…
Reference in New Issue