antispam 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +72 -0
- data/Rakefile +18 -0
- data/app/assets/config/antispam_manifest.js +1 -0
- data/app/assets/images/antispam/captcha/a.gif +0 -0
- data/app/assets/images/antispam/captcha/b.gif +0 -0
- data/app/assets/images/antispam/captcha/blank.gif +0 -0
- data/app/assets/images/antispam/captcha/c.gif +0 -0
- data/app/assets/images/antispam/captcha/d.gif +0 -0
- data/app/assets/images/antispam/captcha/e.gif +0 -0
- data/app/assets/images/antispam/captcha/f.gif +0 -0
- data/app/assets/images/antispam/captcha/g.gif +0 -0
- data/app/assets/images/antispam/captcha/h.gif +0 -0
- data/app/assets/images/antispam/captcha/i.gif +0 -0
- data/app/assets/images/antispam/captcha/j.gif +0 -0
- data/app/assets/images/antispam/captcha/k.gif +0 -0
- data/app/assets/images/antispam/captcha/l.gif +0 -0
- data/app/assets/stylesheets/antispam/application.css +15 -0
- data/app/assets/stylesheets/antispam/blocks.css +4 -0
- data/app/assets/stylesheets/antispam/challenges.css +4 -0
- data/app/assets/stylesheets/antispam/clears.css +4 -0
- data/app/assets/stylesheets/scaffold.css +80 -0
- data/app/controllers/antispam/application_controller.rb +4 -0
- data/app/controllers/antispam/blocks_controller.rb +70 -0
- data/app/controllers/antispam/challenges_controller.rb +49 -0
- data/app/controllers/antispam/clears_controller.rb +63 -0
- data/app/controllers/antispam/validate_controller.rb +12 -0
- data/app/helpers/antispam/application_helper.rb +4 -0
- data/app/helpers/antispam/blocks_helper.rb +4 -0
- data/app/helpers/antispam/challenges_helper.rb +4 -0
- data/app/helpers/antispam/clears_helper.rb +4 -0
- data/app/jobs/antispam/application_job.rb +4 -0
- data/app/mailers/antispam/application_mailer.rb +6 -0
- data/app/models/antispam/application_record.rb +5 -0
- data/app/models/antispam/block.rb +4 -0
- data/app/models/antispam/challenge.rb +26 -0
- data/app/models/antispam/clear.rb +4 -0
- data/app/models/antispam/ip.rb +7 -0
- data/app/views/antispam/blocks/_form.html.erb +37 -0
- data/app/views/antispam/blocks/edit.html.erb +6 -0
- data/app/views/antispam/blocks/index.html.erb +37 -0
- data/app/views/antispam/blocks/new.html.erb +5 -0
- data/app/views/antispam/blocks/show.html.erb +24 -0
- data/app/views/antispam/challenges/_form.html.erb +32 -0
- data/app/views/antispam/challenges/edit.html.erb +6 -0
- data/app/views/antispam/challenges/index.html.erb +31 -0
- data/app/views/antispam/challenges/new.html.erb +5 -0
- data/app/views/antispam/challenges/show.html.erb +19 -0
- data/app/views/antispam/clears/_form.html.erb +42 -0
- data/app/views/antispam/clears/edit.html.erb +6 -0
- data/app/views/antispam/clears/index.html.erb +32 -0
- data/app/views/antispam/clears/new.html.erb +5 -0
- data/app/views/antispam/clears/show.html.erb +29 -0
- data/app/views/antispam/validate/index.html.erb +14 -0
- data/app/views/layouts/antispam/application.html.erb +15 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20210130213708_create_antispam_ips.rb +12 -0
- data/db/migrate/20210130214835_create_antispam_challenges.rb +11 -0
- data/db/migrate/20210130234107_create_antispam_blocks.rb +12 -0
- data/db/migrate/20210130235537_create_antispam_clears.rb +13 -0
- data/lib/antispam.rb +11 -0
- data/lib/antispam/blacklists/httpbl.rb +43 -0
- data/lib/antispam/engine.rb +5 -0
- data/lib/antispam/tools.rb +49 -0
- data/lib/antispam/version.rb +3 -0
- data/lib/tasks/antispam_tasks.rake +4 -0
- metadata +141 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
require_dependency "antispam/application_controller"
|
2
|
+
|
3
|
+
module Antispam
|
4
|
+
class ValidateController < ApplicationController
|
5
|
+
def index
|
6
|
+
respond_to do |format|
|
7
|
+
format.html
|
8
|
+
format.js { render js: 'window.location = "/antispam/validate"'}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Antispam
|
2
|
+
class Challenge < ApplicationRecord
|
3
|
+
before_create :generate
|
4
|
+
|
5
|
+
def generate
|
6
|
+
self.question = create_string
|
7
|
+
self.answer = self.question
|
8
|
+
end
|
9
|
+
def create_string
|
10
|
+
o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
|
11
|
+
(0...8).map { o[rand(o.length)] }.join
|
12
|
+
end
|
13
|
+
def get_image
|
14
|
+
require "image_processing/vips"
|
15
|
+
image = Vips::Image.text(self.answer, dpi: 300)
|
16
|
+
image.draw_line(255, 5+rand(20).to_i, 5+rand(20).to_i, 150+rand(50).to_i, 10+rand(10).to_i)
|
17
|
+
end
|
18
|
+
def validate?(check)
|
19
|
+
return false if self.answer.nil?
|
20
|
+
result = false
|
21
|
+
result = true if self.answer.downcase == check.downcase
|
22
|
+
self.update_column(:answer,nil)
|
23
|
+
return result
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<%= form_with(model: block) do |form| %>
|
2
|
+
<% if block.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(block.errors.count, "error") %> prohibited this block from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% block.errors.each do |error| %>
|
8
|
+
<li><%= error.full_message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= form.label :ip %>
|
16
|
+
<%= form.text_field :ip %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="field">
|
20
|
+
<%= form.label :provider %>
|
21
|
+
<%= form.text_field :provider %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="field">
|
25
|
+
<%= form.label :controllername %>
|
26
|
+
<%= form.text_field :controllername %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div class="field">
|
30
|
+
<%= form.label :actionname %>
|
31
|
+
<%= form.text_field :actionname %>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="actions">
|
35
|
+
<%= form.submit %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<div class="row">
|
4
|
+
<div class="cx">
|
5
|
+
<h1>Blocks</h1>
|
6
|
+
|
7
|
+
<table>
|
8
|
+
<thead>
|
9
|
+
<tr>
|
10
|
+
<th>Ip</th>
|
11
|
+
<th>Provider</th>
|
12
|
+
<th>Controllername</th>
|
13
|
+
<th>Actionname</th>
|
14
|
+
<th colspan="3"></th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
|
18
|
+
<tbody>
|
19
|
+
<% Antispam::Block.all.order(create_at: :desc).limit(50).each do |block| %>
|
20
|
+
<tr>
|
21
|
+
<td><%= block.ip %></td>
|
22
|
+
<td><%= block.provider %></td>
|
23
|
+
<td><%= block.controllername %></td>
|
24
|
+
<td><%= block.actionname %></td>
|
25
|
+
<td><%= time_ago_in_words block.created_at %> ago</td>
|
26
|
+
<!-- <td><%#= link_to 'Show', block %></td>-->
|
27
|
+
<!-- <td><%#= link_to 'Edit', edit_block_path(block) %></td>-->
|
28
|
+
<!-- <td><%#= link_to 'Destroy', block, method: :delete, data: { confirm: 'Are you sure?' } %></td>-->
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
31
|
+
</tbody>
|
32
|
+
</table>
|
33
|
+
</div>
|
34
|
+
<div class="cx">
|
35
|
+
<%= render template: '/antispam/clears/index.html' %>
|
36
|
+
</div>
|
37
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Ip:</strong>
|
5
|
+
<%= @block.ip %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Provider:</strong>
|
10
|
+
<%= @block.provider %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<strong>Controllername:</strong>
|
15
|
+
<%= @block.controllername %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<strong>Actionname:</strong>
|
20
|
+
<%= @block.actionname %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<%= link_to 'Edit', edit_block_path(@block) %> |
|
24
|
+
<%= link_to 'Back', blocks_path %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%= form_with(model: challenge) do |form| %>
|
2
|
+
<% if challenge.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(challenge.errors.count, "error") %> prohibited this challenge from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% challenge.errors.each do |error| %>
|
8
|
+
<li><%= error.full_message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= form.label :question %>
|
16
|
+
<%= form.text_field :question %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="field">
|
20
|
+
<%= form.label :answer %>
|
21
|
+
<%= form.text_field :answer %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="field">
|
25
|
+
<%= form.label :code %>
|
26
|
+
<%= form.text_field :code %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div class="actions">
|
30
|
+
<%= form.submit %>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Challenges</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th>Question</th>
|
9
|
+
<th>Answer</th>
|
10
|
+
<th>Code</th>
|
11
|
+
<th colspan="3"></th>
|
12
|
+
</tr>
|
13
|
+
</thead>
|
14
|
+
|
15
|
+
<tbody>
|
16
|
+
<% @challenges.each do |challenge| %>
|
17
|
+
<tr>
|
18
|
+
<td><%= challenge.question %></td>
|
19
|
+
<td><%= challenge.answer %></td>
|
20
|
+
<td><%= challenge.code %></td>
|
21
|
+
<td><%= link_to 'Show', challenge %></td>
|
22
|
+
<td><%= link_to 'Edit', edit_challenge_path(challenge) %></td>
|
23
|
+
<td><%= link_to 'Destroy', challenge, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br>
|
30
|
+
|
31
|
+
<%= link_to 'New Challenge', new_challenge_path %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Question:</strong>
|
5
|
+
<%= @challenge.question %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Answer:</strong>
|
10
|
+
<%= @challenge.answer %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<strong>Code:</strong>
|
15
|
+
<%= @challenge.code %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<%= link_to 'Edit', edit_challenge_path(@challenge) %> |
|
19
|
+
<%= link_to 'Back', challenges_path %>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%= form_with(model: clear) do |form| %>
|
2
|
+
<% if clear.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(clear.errors.count, "error") %> prohibited this clear from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% clear.errors.each do |error| %>
|
8
|
+
<li><%= error.full_message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= form.label :ip %>
|
16
|
+
<%= form.text_field :ip %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="field">
|
20
|
+
<%= form.label :result %>
|
21
|
+
<%= form.text_field :result %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="field">
|
25
|
+
<%= form.label :answer %>
|
26
|
+
<%= form.text_field :answer %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div class="field">
|
30
|
+
<%= form.label :threat_before %>
|
31
|
+
<%= form.number_field :threat_before %>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="field">
|
35
|
+
<%= form.label :threat_after %>
|
36
|
+
<%= form.number_field :threat_after %>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div class="actions">
|
40
|
+
<%= form.submit %>
|
41
|
+
</div>
|
42
|
+
<% end %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Clears</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th>Ip</th>
|
9
|
+
<th>Result</th>
|
10
|
+
<th>Answer</th>
|
11
|
+
<th>Threat before</th>
|
12
|
+
<th>Threat after</th>
|
13
|
+
<th colspan="3"></th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
|
17
|
+
<tbody>
|
18
|
+
<% Antispam::Clear.all.order(create_at: :desc).limit(50).each do |clear| %>
|
19
|
+
<tr>
|
20
|
+
<td><%= clear.ip %></td>
|
21
|
+
<td><%= clear.result %></td>
|
22
|
+
<td><%= clear.answer %></td>
|
23
|
+
<td><%= clear.threat_before %></td>
|
24
|
+
<td><%= clear.threat_after %></td>
|
25
|
+
<td><%= time_ago_in_words clear.created_at %> ago</td>
|
26
|
+
<!-- <td><%#= link_to 'Show', clear %></td>-->
|
27
|
+
<!-- <td><%#= link_to 'Edit', edit_clear_path(clear) %></td>-->
|
28
|
+
<!-- <td><%#= link_to 'Destroy', clear, method: :delete, data: { confirm: 'Are you sure?' } %></td>-->
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
31
|
+
</tbody>
|
32
|
+
</table>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Ip:</strong>
|
5
|
+
<%= @clear.ip %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Result:</strong>
|
10
|
+
<%= @clear.result %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<strong>Answer:</strong>
|
15
|
+
<%= @clear.answer %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<strong>Threat before:</strong>
|
20
|
+
<%= @clear.threat_before %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
<strong>Threat after:</strong>
|
25
|
+
<%= @clear.threat_after %>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
<%= link_to 'Edit', edit_clear_path(@clear) %> |
|
29
|
+
<%= link_to 'Back', clears_path %>
|