Created
April 8, 2015 09:57
-
-
Save KrzaQ/304d28a49600ba4e85ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __FILE__ == $0 | |
| ip = ARGV[0] | |
| if not ip =~ /^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$/ | |
| $stderr.puts "'#{ip}' is not a valid IP" | |
| exit | |
| end | |
| `/etc/init.d/denyhosts stop` | |
| DenyHostsDir = '/var/lib/denyhosts/' | |
| Files = ['hosts', 'hosts-restricted', 'hosts-root', 'hosts-valid', 'users-hosts'].map{ |fn| | |
| "#{DenyHostsDir}#{fn}" | |
| }.push('/etc/hosts.deny') | |
| Files.each{|fn| | |
| data = File.open(fn,'r'){|f| f.read }.lines.select{|l| not l =~ /#{ip}/ }.join("\n") | |
| File.open(fn,'w'){|f| f.write data } | |
| } | |
| `/etc/init.d/denyhosts start` | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment