Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. [root:a17924e746f0:~]# cat /etc/fail2ban/action.d/404.conf
  2. # Fail2Ban action configuration file for Subzero/Core
  3.  
  4. [Definition]
  5. actionstart =
  6. actionstop =
  7. actioncheck =
  8. actionban = /root/ban_modify.rb ban <ip>
  9. actionunban = /root/ban_modify.rb unban <ip>
  10.  
  11. #!/usr/bin/env ruby
  12.  
  13. command = ARGV[0]
  14. ip_address = ARGV[1]
  15.  
  16. blacklist = File.open("/root/blacklist.txt").read.split("n")
  17.  
  18. if command == "unban"
  19. if blacklist.include? "#{ip_address} deny"
  20. blacklist.delete "#{ip_address} deny"
  21. end
  22. elsif command == "ban"
  23. blacklist << "#{ip_address} deny"
  24. end
  25.  
  26. File.open("/root/blacklist.txt", "w") {|f| f.write(blacklist.join("n"))}
  27.  
  28. 2019-08-19 20:56:43,508 fail2ban.utils [16176]: Level 39 7ff7395873f0 -- exec: ban_modify.rb ban <myip>
  29. 2019-08-19 20:56:43,509 fail2ban.utils [16176]: ERROR 7ff7395873f0 -- stderr: '/bin/sh: 1: ban_modify.rb: not found'
  30. 2019-08-19 20:56:43,509 fail2ban.utils [16176]: ERROR 7ff7395873f0 -- returned 127
  31. 2019-08-19 20:56:43,509 fail2ban.utils [16176]: INFO HINT on 127: "Command not found". Make sure that all commands in 'ban_modify.rb ban <myip>' are in the PATH of fail2ban-server process (grep -a PATH= /proc/`pidof -x fail2ban-server`/environ). You may want to start "fail2ban-server -f" separately, initiate it with "fail2ban-client reload" in another shell session and observe if additional informative error messages appear in the terminals.
  32. 2019-08-19 20:56:43,509 fail2ban.actions [16176]: ERROR Failed to execute ban jail '404' action '404' info 'ActionInfo({'ip': '<myip>', 'family': 'inet4', 'ip-rev': '<myip>.', 'ip-host': '<myip>', 'fid': '<myip>', 'failures': 1, 'time': 1566266203.3465006, 'matches': '', 'restored': 0, 'F-*': {'matches': [], 'failures': 1}, 'ipmatches': '', 'ipjailmatches': '', 'ipfailures': 1, 'ipjailfailures': 1})': Error banning <myip>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement