block 0.0.8 → 0.0.9

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,46 @@
1
+ block
2
+ =====
3
+
4
+ To install - first off make sure you have Redis available to you. Then:
5
+
6
+ gem install block
7
+
8
+ From there, here's how you run it:
9
+
10
+ NAME
11
+ block - Ruby Gem to block IP addresses that are requesting URLs you determine are bad.
12
+
13
+ SYNOPSIS
14
+ block [global options] command [command options] [arguments...]
15
+
16
+ VERSION
17
+ 0.0.9
18
+
19
+ GLOBAL OPTIONS
20
+ -d, --[no-]disable - Disable adding firewall rules
21
+ -e, --expiry=10 - Expiry time in seconds (default: 10)
22
+ -f, --file=filename.txt - The filename to watch (default: none)
23
+ --help - Show this message
24
+ -r, --redis=redis://127.0.0.1:6379 - Redis server location (default: redis://127.0.0.1:6379)
25
+ -s, --search=passwd,acunetrix - The searches - separated by commas. (default: none)
26
+ -t, --threshold=30 - Block threshold number (default: 30)
27
+ --version -
28
+
29
+ COMMANDS
30
+ help - Shows a list of commands or help for one command
31
+ watch - Watch and (optionally) block bad IP addresses
32
+
33
+ Monitor an Apache logfile and block IP addresses that are requesting pages that match strings you pass on the command line.
34
+
35
+ block -f logfile-to-watch.txt -s passwd,acunetrix watch
36
+
37
+ We watch the logs and increment a counter each time there's a match for a particular IP address and string, once they hit a certain number of matches they're blocked using Linux's iptables.
38
+
39
+ If you're not sure whether it's tuned correctly, you can run it with the `-d` flag and watch what **would** happen.
40
+
41
+ Requires
42
+ --------
43
+
44
+ Ruby 1.8.7 or 1.9.x
45
+
46
+ Redis
data/bin/block CHANGED
@@ -4,8 +4,6 @@ require 'block'
4
4
 
5
5
  include GLI::App
6
6
 
7
- $redis = Redis.new
8
-
9
7
  program_desc 'Ruby Gem to block IP addresses that are requesting URLs you determine are bad.'
10
8
 
11
9
  version Block::VERSION
@@ -19,8 +17,8 @@ arg_name 'filename.txt'
19
17
  flag [:f,:file]
20
18
 
21
19
  desc 'Redis server location'
22
- arg_name '127.0.0.1:6379'
23
- default_value '127.0.0.1:6379'
20
+ arg_name 'redis://127.0.0.1:6379'
21
+ default_value 'redis://127.0.0.1:6379'
24
22
  flag [:r,:redis]
25
23
 
26
24
  desc 'Expiry time in seconds'
@@ -44,7 +42,7 @@ pre do |global,command,options,args|
44
42
  searches = check_for_searches(global)
45
43
 
46
44
  # Make sure redis is available.
47
- redis = check_for_redis
45
+ redis = check_for_redis(global)
48
46
  end
49
47
 
50
48
  desc 'Watch and (optionally) block bad IP addresses'
@@ -5,7 +5,9 @@ require 'redis'
5
5
  # Add requires for other files you add to your project here, so
6
6
  # you just need to require this one file in your bin file
7
7
 
8
- def check_for_redis
8
+ def check_for_redis(args)
9
+ uri = URI.parse(args[:redis])
10
+ $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
9
11
  begin
10
12
  $redis.ping
11
13
  true
@@ -1,3 +1,3 @@
1
1
  module Block
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -145,14 +145,14 @@ executables:
145
145
  - block
146
146
  extensions: []
147
147
  extra_rdoc_files:
148
- - README.rdoc
148
+ - README.markdown
149
149
  - block.rdoc
150
150
  files:
151
151
  - bin/block
152
152
  - lib/block/version.rb
153
153
  - lib/block/reader.rb
154
154
  - lib/block.rb
155
- - README.rdoc
155
+ - README.markdown
156
156
  - block.rdoc
157
157
  homepage: https://github.com/darron/block
158
158
  licenses: []
@@ -161,7 +161,7 @@ rdoc_options:
161
161
  - --title
162
162
  - block
163
163
  - --main
164
- - README.rdoc
164
+ - README.markdown
165
165
  - -ri
166
166
  require_paths:
167
167
  - lib
@@ -1,6 +0,0 @@
1
- = block
2
-
3
- Describe your project here
4
-
5
- :include:block.rdoc
6
-