fail2ban-geoip 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d68c3bcb86d8c4bef1064ff20a4d78642e259b7c
4
+ data.tar.gz: 644ce85aa508fbd5f744ac6d3c33ff84ed0bf07d
5
+ SHA512:
6
+ metadata.gz: ce9a8b376b18a26115f41d3f84a1c1bf8cdd89717dd40868d16253cb42d01dfb39a3c6420c91265fba1915f93247a5e64127356bab9f5df19d56824301f84902
7
+ data.tar.gz: a33191136ae655c0839c7adbe1844061a8efdc24c6ac03ed025da6291c19f629d79ac913d1878633e41e2a7e6031026cd833bd7ebd586610b3e43ee930fb1cdc
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fail2ban-geoip.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # Fail2ban::Geoip
2
+
3
+ Identify the country of origin for an IP address that got banned by fail2ban
4
+
5
+ ## Installation
6
+
7
+ First, make sure that you have both `fail2ban` and a copy of the geoip database. On Debian-based distributions, this is installed by the `geoip-database` package:
8
+
9
+
10
+ $ apt-get install fail2ban
11
+ $ apt-get install geoip-database
12
+
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'fail2ban-geoip'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install fail2ban-geoip
27
+
28
+ ## Usage
29
+
30
+ $ fail2ban-geoip.rb
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/[my-github-username]/fail2ban-geoip/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+ ##############################################################################
3
+ ## Author: Robert Miesen
4
+ ## Date Created: 07/30/2014
5
+ ## Time-stamp: <07/31/2014 02:26:23 rmiesen>
6
+ ##
7
+ ## Comments:
8
+ ## This program assumes that you have the 'geoip-database' Debian package
9
+ ## installed, or your platform's equivilent, installed at /usr/share/GeoIP/
10
+ ## If this assumption is unreasonable, please file a bug report agiainst this
11
+ ## program with a suggestion on how to fix it for your platform.
12
+ ##############################################################################
13
+
14
+ require 'rubygems'
15
+ require 'commander/import'
16
+ require 'ascii_charts'
17
+ require 'awesome_print'
18
+ require 'geoip'
19
+ require_relative '../lib/fail2ban/geoip/version'
20
+
21
+
22
+
23
+ program :version, Fail2ban::Geoip::VERSION
24
+ program :description, 'Identify the country of origin (*cough* China *cough*) for an IP address that got banned by fail2ban'
25
+ default_command :run
26
+
27
+
28
+ command :run do |c|
29
+ c.syntax = 'identifyCountryOfFail2BanBanees.rb run [options]'
30
+ c.summary = ''
31
+ c.description = ''
32
+ c.example 'identifyCountryOfFail2BanBanees.rb run', 'command example'
33
+ c.option '-l FILE', '--fail2ban-log FILE', String, 'Specify an alternative location for the fail2ban log to be analyzed. Defaults to /var/log/fail2ban.log'
34
+
35
+ c.option '--[no-]ascii-chart-output', 'Output an ascii chart aggregating each countries number of banees. On by default.'
36
+
37
+ c.option '--[no-]awesome-print-output', 'Outputs the details of the banee\'s country of origin'
38
+ c.option '--force-color-output', "Forces the use of ascii color output. Useful for piping to other programs that can parse ascii color output, such as less with the '-r' option supplied"
39
+
40
+ c.action do |args, options|
41
+ options.default(:fail2ban_log => "/var/log/fail2ban.log", :ascii_chart_output => true)
42
+ $fail2ban_log = options.fail2ban_log
43
+
44
+ ##LEFT_OFF_HERE: Put under rspec tests, handle cases where the $fail2ban_log file doesn't exist.
45
+ geoip_contry_database = GeoIP.new('/usr/share/GeoIP/GeoIP.dat')
46
+
47
+ fail2ban_banees = File.readlines($fail2ban_log).collect do |s|
48
+ s =~ /Ban ((?:\d{1,3}\.?){4})/
49
+ $1
50
+ end.delete_if { |s| s == nil }
51
+
52
+ countries_and_ips_banned_by_fail2ban = Hash.new
53
+ countries_and_ips_banned_by_fail2ban.default_proc = lambda {|h,k| h[k] = Array.new}
54
+ fail2ban_banees.each do |ip|
55
+ banee_country = geoip_contry_database.country(ip)
56
+ countries_and_ips_banned_by_fail2ban[banee_country[:country_name]] << ip
57
+ end
58
+
59
+ if options.ascii_chart_output
60
+ puts AsciiCharts::Cartesian.new(countries_and_ips_banned_by_fail2ban.collect {|k,v| [k,v.count]}, :bar => true, :hide_zero => true, :title => "Number of Banees per country").draw
61
+ puts "\n\n"
62
+ end
63
+
64
+ if options.awesome_print_output
65
+ AwesomePrint::force_colors! options.force_color_output
66
+ puts "Detailed bannee information:"
67
+ ap countries_and_ips_banned_by_fail2ban, :indent => -2
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fail2ban/geoip/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fail2ban-geoip"
8
+ spec.version = Fail2ban::Geoip::VERSION
9
+ spec.authors = ["Robert Jeffrey Miesen"]
10
+ spec.email = ["robert.miesen@gmail.com"]
11
+ spec.summary = %q{Identify the country of origin for an IP address that got banned by fail2ban}
12
+ spec.description = %q{Identify the country of origin for an IP address that got banned by fail2ban}
13
+ spec.homepage = "https://github.com/rmiesen/fail2ban-geoip"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_runtime_dependency "commander", "~> 4.2", ">= 4.2.0"
25
+ spec.add_runtime_dependency "awesome_print", "~> 1.2", ">= 1.2.0"
26
+ spec.add_runtime_dependency "geoip", "~> 1.4", ">= 1.4.0"
27
+ spec.add_runtime_dependency "ascii_charts", "~> 0.9", ">= 0.9.1"
28
+ end
@@ -0,0 +1,7 @@
1
+ require "fail2ban/geoip/version"
2
+
3
+ module Fail2ban
4
+ module Geoip
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Fail2ban
2
+ module Geoip
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ ##############################################################################
3
+ ## Author: Robert Miesen
4
+ ## Date Created: 07/30/2014
5
+ ## Time-stamp: <07/30/2014 18:25:56 rmiesen>
6
+ ##############################################################################
7
+
8
+ require 'rspec'
9
+ require_relative '../bin/fail2ban-geoip'
10
+
11
+
12
+
13
+
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fail2ban-geoip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Robert Jeffrey Miesen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: commander
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.2'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 4.2.0
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '4.2'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 4.2.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: awesome_print
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.2'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.2.0
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '1.2'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 1.2.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: geoip
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.4'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.4.0
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.4'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.4.0
101
+ - !ruby/object:Gem::Dependency
102
+ name: ascii_charts
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.9'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.1
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.9'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 0.9.1
121
+ description: Identify the country of origin for an IP address that got banned by fail2ban
122
+ email:
123
+ - robert.miesen@gmail.com
124
+ executables:
125
+ - fail2ban-geoip.rb
126
+ extensions: []
127
+ extra_rdoc_files: []
128
+ files:
129
+ - ".gitignore"
130
+ - Gemfile
131
+ - LICENSE.txt
132
+ - README.md
133
+ - Rakefile
134
+ - bin/fail2ban-geoip.rb
135
+ - fail2ban-geoip.gemspec
136
+ - lib/fail2ban/geoip.rb
137
+ - lib/fail2ban/geoip/version.rb
138
+ - spec/describe-fail2ban-geoip.rb
139
+ homepage: https://github.com/rmiesen/fail2ban-geoip
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.2.2
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Identify the country of origin for an IP address that got banned by fail2ban
163
+ test_files:
164
+ - spec/describe-fail2ban-geoip.rb
165
+ has_rdoc: