miteru 0.12.4 → 0.12.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9e6b96b39d329d3003d0cec2d06f99814f7f9fb518cb80f8c465999a548e88f
4
- data.tar.gz: 5fb646c603f612f09de5c9da2cce8a0c3b379af7d9e3a31994ea2403da37e35a
3
+ metadata.gz: 652b5f4162ff0a7c62f95123c06b82f5f3c6c469442af3f9087767342550afb1
4
+ data.tar.gz: ef33a506c434a06bdf7c098b460d4174e76b0b813044b507aba5dccfe31e3438
5
5
  SHA512:
6
- metadata.gz: 173f0e24dba5aee1e5cfb126bc70d2e7ae0e7ebf13c59a55f60a023ce9705e84e86f645770c27f5026a48029124355ffa54e68f0b0dfc1675b397f7e6c9544ca
7
- data.tar.gz: c8c46730a108355c70696b2034cfd4bbf0a71c144e295c774cc214abb01600e97ecfb6747114bcec904a0852eb5db56fbe7b35aa45d4244f2763e4dff0cf0223
6
+ metadata.gz: b106d1f83405f51116ba9c0bcaaac1a2b7f0b8df524164d829755b3c7d82dd7dd68f2eb0ef4ea5da2d826615428731d92008f4c0313d716c6b674f7e5f905ca6
7
+ data.tar.gz: 35539e25834188e5ec42124ee7ee00791f08fd6993ede104de88eeaafb7f7f4990558e8672faa918442d77b5fe220924f04252a7033876a592a278a1947e6e14
@@ -21,7 +21,7 @@ module Miteru
21
21
  @threads = threads
22
22
  @verbose = verbose
23
23
 
24
- @feeds = Feeds.new(size, directory_traveling: directory_traveling)
24
+ @feeds = Feeds.new(size: size, directory_traveling: directory_traveling)
25
25
  @notifier = Notifier.new(post_to_slack)
26
26
  end
27
27
 
@@ -10,29 +10,31 @@ module Miteru
10
10
 
11
11
  def initialize(base_dir = "/tmp")
12
12
  @base_dir = base_dir
13
- raise ArgumentError, "#{base_dir} is not existing." unless Dir.exist?(base_dir)
13
+ raise ArgumentError, "#{base_dir} is not exist." unless Dir.exist?(base_dir)
14
14
  end
15
15
 
16
16
  def download_kits(kits)
17
- kits.each do |kit|
18
- filename = download_filename(kit)
19
- destination = filepath_to_download(filename)
20
- begin
21
- downloaded_filepath = HTTPClient.download(kit.url, destination)
22
- if duplicated?(downloaded_filepath)
23
- puts "Do not download #{kit.url} because there is a file that has a same hash value in the directory (SHA256: #{sha256(downloaded_filepath)})."
24
- FileUtils.rm downloaded_filepath
25
- else
26
- puts "Download #{kit.url} as #{downloaded_filepath}"
27
- end
28
- rescue Down::Error => e
29
- puts "Failed to download: #{kit.url} (#{e})"
30
- end
31
- end
17
+ kits.each { |kit| download_kit kit }
32
18
  end
33
19
 
34
20
  private
35
21
 
22
+ def download_kit(kit)
23
+ filename = download_filename(kit)
24
+ destination = filepath_to_download(filename)
25
+ begin
26
+ downloaded_filepath = HTTPClient.download(kit.url, destination)
27
+ if duplicated?(downloaded_filepath)
28
+ puts "Do not download #{kit.url} because there is a duplicate file in the directory (SHA256: #{sha256(downloaded_filepath)})."
29
+ FileUtils.rm downloaded_filepath
30
+ else
31
+ puts "Download #{kit.url} as #{downloaded_filepath}"
32
+ end
33
+ rescue Down::Error => e
34
+ puts "Failed to download: #{kit.url} (#{e})"
35
+ end
36
+ end
37
+
36
38
  def download_filename(kit)
37
39
  domain = URI(kit.base_url).hostname
38
40
 
@@ -6,16 +6,18 @@ require_relative "./feeds/urlscan"
6
6
 
7
7
  module Miteru
8
8
  class Feeds
9
- attr_reader :directory_traveling
10
-
11
- def initialize(urlscan_size = 100, directory_traveling: false)
9
+ def initialize(size: 100, directory_traveling: false)
12
10
  @feeds = [
13
11
  Ayashige.new,
14
- UrlScan.new(urlscan_size)
12
+ UrlScan.new(size)
15
13
  ]
16
14
  @directory_traveling = directory_traveling
17
15
  end
18
16
 
17
+ def directory_traveling?
18
+ @directory_traveling
19
+ end
20
+
19
21
  def suspicious_urls
20
22
  @suspicious_urls ||= [].tap do |arr|
21
23
  urls = @feeds.map do |feed|
@@ -34,7 +36,7 @@ module Miteru
34
36
  end
35
37
 
36
38
  base = "#{uri.scheme}://#{uri.hostname}"
37
- return [base] unless directory_traveling
39
+ return [base] unless directory_traveling?
38
40
 
39
41
  segments = uri.path.split("/")
40
42
  return [base] if segments.length.zero?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "0.12.4"
4
+ VERSION = "0.12.5"
5
5
  end
@@ -34,7 +34,7 @@ module Miteru
34
34
 
35
35
  def has_kits?
36
36
  ok? && index? && kits?
37
- rescue OpenSSL::SSL::SSLError, HTTP::Error, Addressable::URI::InvalidURIError => _e
37
+ rescue OpenSSL::SSL::SSLError, HTTP::Error, Addressable::URI::InvalidURIError, Encoding::CompatibilityError, LL::ParserError => _e
38
38
  false
39
39
  end
40
40
 
@@ -42,8 +42,8 @@ module Miteru
42
42
  return "It doesn't contain a phishing kit." unless kits?
43
43
 
44
44
  kit_names = kits.map(&:basename).join(", ")
45
- noun = kits.length == 1 ? "kit" : "kits"
46
- "It might contain phishing #{noun}: #{kit_names}."
45
+ noun = kits.length == 1 ? "a phishing kit" : "phishing kits"
46
+ "It might contain #{noun}: #{kit_names}."
47
47
  end
48
48
 
49
49
  private
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "glint", "~> 0.1"
30
30
  spec.add_development_dependency "rake", "~> 12.3"
31
31
  spec.add_development_dependency "rspec", "~> 3.8"
32
- spec.add_development_dependency "vcr", "~> 4.0"
33
- spec.add_development_dependency "webmock", "~> 3.5"
32
+ spec.add_development_dependency "vcr", "~> 5.0"
33
+ spec.add_development_dependency "webmock", "~> 3.6"
34
34
 
35
35
  spec.add_dependency "colorize", "~> 0.8"
36
36
  spec.add_dependency "down", "~> 4.8"
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.12.4
4
+ version: 0.12.5
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-06-03 00:00:00.000000000 Z
11
+ date: 2019-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '4.0'
89
+ version: '5.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '4.0'
96
+ version: '5.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.5'
103
+ version: '3.6'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.5'
110
+ version: '3.6'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: colorize
113
113
  requirement: !ruby/object:Gem::Requirement