miteru 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile +3 -1
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/docker/Dockerfile +1 -1
- data/lib/miteru.rb +1 -0
- data/lib/miteru/crawler.rb +7 -21
- data/lib/miteru/notifier.rb +40 -0
- data/lib/miteru/version.rb +1 -1
- data/miteru.gemspec +2 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c0d220bd3b7a0ea6ca5b394e27f2bf86ad2f11f4c7ea524226c843f430d5c4e
|
4
|
+
data.tar.gz: 9c295c3913fb784eb66a17341d14c89955befbb7daed8d443996f27205e1a4a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2a4d9344b6e46da84e052d09335fa20637da4bcca905bc40b23ae8422fb7d420ffff25bed3e103e4e672eba1eb6456e34eba303be883f6abeda2dcd5366c79
|
7
|
+
data.tar.gz: e4dc6c7bbc95ba5a7185c44f9ecc7f8ded173278e756544a1c2c4232b31b3725a12a12b73b8b1e8e74e4842943334402aab36bb8a4b13b0d41a98393c5aee92a
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in miteru.gemspec
|
6
8
|
gemspec
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/docker/Dockerfile
CHANGED
data/lib/miteru.rb
CHANGED
data/lib/miteru/crawler.rb
CHANGED
@@ -18,12 +18,12 @@ module Miteru
|
|
18
18
|
@auto_download = auto_download
|
19
19
|
@directory_traveling = directory_traveling
|
20
20
|
@downloader = Downloader.new(download_to)
|
21
|
-
@post_to_slack = post_to_slack
|
22
21
|
@size = size
|
23
22
|
@threads = threads
|
24
23
|
@verbose = verbose
|
25
24
|
|
26
25
|
@feeds = Feeds.new(size, directory_traveling: directory_traveling)
|
26
|
+
@notifier = Notifier.new(post_to_slack)
|
27
27
|
end
|
28
28
|
|
29
29
|
def execute
|
@@ -32,13 +32,13 @@ module Miteru
|
|
32
32
|
Parallel.each(feeds.suspicious_urls, in_threads: threads) do |url|
|
33
33
|
website = Website.new(url)
|
34
34
|
if website.has_kit?
|
35
|
-
message = "#{website.url}: it might contain phishing kit(s) (#{website.compressed_files.join(', ')})."
|
36
|
-
puts message.colorize(:light_red)
|
37
|
-
post_a_message_to_slack(message) if post_to_slack? && valid_slack_setting?
|
38
35
|
downloader.download_compressed_files(website.url, website.compressed_files) if auto_download?
|
36
|
+
notify(website.url, website.compressed_files)
|
39
37
|
else
|
40
|
-
|
38
|
+
notify(website.url, website.compressed_files) if verbose
|
41
39
|
end
|
40
|
+
rescue OpenSSL::SSL::SSLError, HTTP::Error, LL::ParserError => _
|
41
|
+
next
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -54,26 +54,12 @@ module Miteru
|
|
54
54
|
).execute
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
58
|
-
|
59
|
-
raise ArgumentError, "Please set the Slack webhook URL via SLACK_WEBHOOK_URL env" unless webhook_url
|
60
|
-
|
61
|
-
channel = ENV["SLACK_CHANNEL"] || "#general"
|
62
|
-
|
63
|
-
payload = { text: message, channel: channel }
|
64
|
-
HTTPClient.post(webhook_url, json: payload)
|
65
|
-
end
|
66
|
-
|
67
|
-
def post_to_slack?
|
68
|
-
@post_to_slack
|
57
|
+
def notify(url, message)
|
58
|
+
@notifier.notify(url, message)
|
69
59
|
end
|
70
60
|
|
71
61
|
def auto_download?
|
72
62
|
@auto_download
|
73
63
|
end
|
74
|
-
|
75
|
-
def valid_slack_setting?
|
76
|
-
ENV["SLACK_WEBHOOK_URL"] != nil
|
77
|
-
end
|
78
64
|
end
|
79
65
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "colorize"
|
4
|
+
require "slack/incoming/webhooks"
|
5
|
+
|
6
|
+
module Miteru
|
7
|
+
class Notifier
|
8
|
+
def initialize(post_to_slack = false)
|
9
|
+
@post_to_slack = post_to_slack
|
10
|
+
end
|
11
|
+
|
12
|
+
def notify(url, compressed_files)
|
13
|
+
message = compressed_files.empty? ? "it doesn't contain a phishing kit." : "it might contain phishing kit(s): (#{compressed_files.join(', ')})."
|
14
|
+
|
15
|
+
if post_to_slack? && !compressed_files.empty?
|
16
|
+
slack = Slack::Incoming::Webhooks.new(slack_webhook_url, channel: slack_channel)
|
17
|
+
slack.post url, attachments: [{ text: message }]
|
18
|
+
end
|
19
|
+
|
20
|
+
message = message.colorize(:light_red) unless compressed_files.empty?
|
21
|
+
puts "#{url}: #{message}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def post_to_slack?
|
25
|
+
@post_to_slack && slack_webhook_url?
|
26
|
+
end
|
27
|
+
|
28
|
+
def slack_webhook_url
|
29
|
+
ENV.fetch "SLACK_WEBHOOK_URL"
|
30
|
+
end
|
31
|
+
|
32
|
+
def slack_channel
|
33
|
+
ENV.fetch "SLACK_CHANNEL", "#general"
|
34
|
+
end
|
35
|
+
|
36
|
+
def slack_webhook_url?
|
37
|
+
ENV.key? "SLACK_WEBHOOK_URL"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/miteru/version.rb
CHANGED
data/miteru.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler", "~>
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
28
28
|
spec.add_development_dependency "coveralls", "~> 0.8"
|
29
29
|
spec.add_development_dependency "glint", "~> 0.1"
|
30
30
|
spec.add_development_dependency "rake", "~> 12.3"
|
@@ -37,5 +37,6 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "http", "~> 4.0"
|
38
38
|
spec.add_dependency "oga", "~> 2.15"
|
39
39
|
spec.add_dependency "parallel", "~> 1.12"
|
40
|
+
spec.add_dependency "slack-incoming-webhooks", "~> 0.2"
|
40
41
|
spec.add_dependency "thor", "~> 0.19"
|
41
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miteru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coveralls
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '1.12'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: slack-incoming-webhooks
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.2'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.2'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: thor
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,6 +235,7 @@ files:
|
|
221
235
|
- lib/miteru/feeds/feed.rb
|
222
236
|
- lib/miteru/feeds/urlscan.rb
|
223
237
|
- lib/miteru/http_client.rb
|
238
|
+
- lib/miteru/notifier.rb
|
224
239
|
- lib/miteru/version.rb
|
225
240
|
- lib/miteru/website.rb
|
226
241
|
- miteru.gemspec
|