mirror of https://github.com/fail2ban/fail2ban
Merge pull request #134 from grooverdan/misc-fixes
BF: fail2ban client can't handle multi word setcinfo or action[*] valuespull/121/merge
commit
5e5eaaf838
|
@ -40,6 +40,7 @@ protocol = [
|
||||||
["stop", "stops all jails and terminate the server"],
|
["stop", "stops all jails and terminate the server"],
|
||||||
["status", "gets the current status of the server"],
|
["status", "gets the current status of the server"],
|
||||||
["ping", "tests if the server is alive"],
|
["ping", "tests if the server is alive"],
|
||||||
|
["help", "return this output"],
|
||||||
['', "LOGGING", ""],
|
['', "LOGGING", ""],
|
||||||
["set loglevel <LEVEL>", "sets logging level to <LEVEL>. 0 is minimal, 4 is debug"],
|
["set loglevel <LEVEL>", "sets logging level to <LEVEL>. 0 is minimal, 4 is debug"],
|
||||||
["get loglevel", "gets the logging level"],
|
["get loglevel", "gets the logging level"],
|
||||||
|
|
|
@ -124,13 +124,13 @@ port = ???
|
||||||
userid = 0
|
userid = 0
|
||||||
|
|
||||||
# Option: myip
|
# Option: myip
|
||||||
# Notes.: TThe target IP for the attack (your public IP). Should be provided
|
# Notes.: The target IP for the attack (your public IP). Should be provided
|
||||||
# either in the jail config or in a .local file unless your PUBLIC IP
|
# either in the jail config or in a .local file unless your PUBLIC IP
|
||||||
# is the first IP assigned to eth0
|
# is the first IP assigned to eth0
|
||||||
# Values: [ an IP address ] Default: Tries to find the IP address of eth0,
|
# Values: [ an IP address ] Default: Tries to find the IP address of eth0,
|
||||||
# which in most cases will be a private IP, and therefore incorrect
|
# which in most cases will be a private IP, and therefore incorrect
|
||||||
#
|
#
|
||||||
myip = `ip -4 addr show dev eth0 | grep inet | head -1 | sed -r 's/.*inet ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`
|
myip = `ip -4 addr show dev eth0 | grep inet | head -n 1 | sed -r 's/.*inet ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`
|
||||||
|
|
||||||
# Option: protocol
|
# Option: protocol
|
||||||
# Notes.: The protocol over which the attack is happening
|
# Notes.: The protocol over which the attack is happening
|
||||||
|
|
|
@ -102,13 +102,13 @@ mnwlogin =
|
||||||
mnwpass =
|
mnwpass =
|
||||||
|
|
||||||
# Option: myip
|
# Option: myip
|
||||||
# Notes.: TThe target IP for the attack (your public IP). Should be overridden
|
# Notes.: The target IP for the attack (your public IP). Should be overridden
|
||||||
# either in the jail config or in a .local file unless your PUBLIC IP
|
# either in the jail config or in a .local file unless your PUBLIC IP
|
||||||
# is the first IP assigned to eth0
|
# is the first IP assigned to eth0
|
||||||
# Values: [ an IP address ] Default: Tries to find the IP address of eth0,
|
# Values: [ an IP address ] Default: Tries to find the IP address of eth0,
|
||||||
# which in most cases will be a private IP, and therefore incorrect
|
# which in most cases will be a private IP, and therefore incorrect
|
||||||
#
|
#
|
||||||
myip = `ip -4 addr show dev eth0 | grep inet | head -1 | sed -r 's/.*inet ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`
|
myip = `ip -4 addr show dev eth0 | grep inet | head -n 1 | sed -r 's/.*inet ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`
|
||||||
|
|
||||||
# Option: protocol
|
# Option: protocol
|
||||||
# Notes.: The protocol over which the attack is happening
|
# Notes.: The protocol over which the attack is happening
|
||||||
|
|
|
@ -380,7 +380,9 @@ class Fail2banClient:
|
||||||
if cmd == "exit" or cmd == "quit":
|
if cmd == "exit" or cmd == "quit":
|
||||||
# Exit
|
# Exit
|
||||||
return True
|
return True
|
||||||
if not cmd == "":
|
if cmd == "help":
|
||||||
|
self.dispUsage()
|
||||||
|
elif not cmd == "":
|
||||||
self.__processCommand(shlex.split(cmd))
|
self.__processCommand(shlex.split(cmd))
|
||||||
except (EOFError, KeyboardInterrupt):
|
except (EOFError, KeyboardInterrupt):
|
||||||
print
|
print
|
||||||
|
|
|
@ -477,10 +477,19 @@ class FileFilter(Filter):
|
||||||
# Try to open log file.
|
# Try to open log file.
|
||||||
try:
|
try:
|
||||||
container.open()
|
container.open()
|
||||||
except Exception, e:
|
# see http://python.org/dev/peps/pep-3151/
|
||||||
|
except IOError, e:
|
||||||
logSys.error("Unable to open %s" % filename)
|
logSys.error("Unable to open %s" % filename)
|
||||||
logSys.exception(e)
|
logSys.exception(e)
|
||||||
return False
|
return False
|
||||||
|
except OSError, e: # pragma: no cover - requires race condition to tigger this
|
||||||
|
logSys.error("Error opening %s" % filename)
|
||||||
|
logSys.exception(e)
|
||||||
|
return False
|
||||||
|
except OSError, e: # pragma: no cover - Requires implemention error in FileContainer to generate
|
||||||
|
logSys.error("Internal errror in FileContainer open method - please report as a bug to https://github.com/fail2ban/fail2ban/issues")
|
||||||
|
logSys.exception(e)
|
||||||
|
return False
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
line = container.readline()
|
line = container.readline()
|
||||||
|
|
|
@ -189,7 +189,7 @@ class Transmitter:
|
||||||
elif command[1] == "setcinfo":
|
elif command[1] == "setcinfo":
|
||||||
act = command[2]
|
act = command[2]
|
||||||
key = command[3]
|
key = command[3]
|
||||||
value = command[4]
|
value = " ".join(command[4:])
|
||||||
self.__server.setCInfo(name, act, key, value)
|
self.__server.setCInfo(name, act, key, value)
|
||||||
return self.__server.getCInfo(name, act, key)
|
return self.__server.getCInfo(name, act, key)
|
||||||
elif command[1] == "delcinfo":
|
elif command[1] == "delcinfo":
|
||||||
|
@ -199,27 +199,27 @@ class Transmitter:
|
||||||
return None
|
return None
|
||||||
elif command[1] == "actionstart":
|
elif command[1] == "actionstart":
|
||||||
act = command[2]
|
act = command[2]
|
||||||
value = command[3]
|
value = " ".join(command[3:])
|
||||||
self.__server.setActionStart(name, act, value)
|
self.__server.setActionStart(name, act, value)
|
||||||
return self.__server.getActionStart(name, act)
|
return self.__server.getActionStart(name, act)
|
||||||
elif command[1] == "actionstop":
|
elif command[1] == "actionstop":
|
||||||
act = command[2]
|
act = command[2]
|
||||||
value = command[3]
|
value = " ".join(command[3:])
|
||||||
self.__server.setActionStop(name, act, value)
|
self.__server.setActionStop(name, act, value)
|
||||||
return self.__server.getActionStop(name, act)
|
return self.__server.getActionStop(name, act)
|
||||||
elif command[1] == "actioncheck":
|
elif command[1] == "actioncheck":
|
||||||
act = command[2]
|
act = command[2]
|
||||||
value = command[3]
|
value = " ".join(command[3:])
|
||||||
self.__server.setActionCheck(name, act, value)
|
self.__server.setActionCheck(name, act, value)
|
||||||
return self.__server.getActionCheck(name, act)
|
return self.__server.getActionCheck(name, act)
|
||||||
elif command[1] == "actionban":
|
elif command[1] == "actionban":
|
||||||
act = command[2]
|
act = command[2]
|
||||||
value = command[3]
|
value = " ".join(command[3:])
|
||||||
self.__server.setActionBan(name, act, value)
|
self.__server.setActionBan(name, act, value)
|
||||||
return self.__server.getActionBan(name, act)
|
return self.__server.getActionBan(name, act)
|
||||||
elif command[1] == "actionunban":
|
elif command[1] == "actionunban":
|
||||||
act = command[2]
|
act = command[2]
|
||||||
value = command[3]
|
value = " ".join(command[3:])
|
||||||
self.__server.setActionUnban(name, act, value)
|
self.__server.setActionUnban(name, act, value)
|
||||||
return self.__server.getActionUnban(name, act)
|
return self.__server.getActionUnban(name, act)
|
||||||
raise Exception("Invalid command (no set action or not yet implemented)")
|
raise Exception("Invalid command (no set action or not yet implemented)")
|
||||||
|
|
Loading…
Reference in New Issue