miteru 0.12.10 → 0.12.11

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: 1c03dbd0645b9e1caac2f4cfd73df781c43efc1a19aa0f057856572a7ae76d7d
4
- data.tar.gz: bd43177680ca857b77627cfbfd7feb0e03d80a1f39ac12d6eb2cb4fd859c26da
3
+ metadata.gz: 80ce8c8350165a57da77e2f4c7e86acd36e48b921a114fc8299ac7925847b696
4
+ data.tar.gz: 5c1efd6135cef875a7d425ee5f22c65553b05564afcff2b6ccc8234990db0fc2
5
5
  SHA512:
6
- metadata.gz: 15b3980e86a77668edc3b6752efae2b8dc200eb374cc586774c499bbba3979d2dc479c5395b1f1ab1c1b6797d37ab2016a0ef9813982bdc4808187b71a6cb944
7
- data.tar.gz: 2d31cba9f757afc300fccc0e86d9845d3b2ef99894bec11fd5214864d8f852b09b5a762894b81364f2c827f93277ece09aa09a19837990cebb55d6764528bc00
6
+ metadata.gz: 7bcf546a3dedf9cc4e9b1bc5aeb52806846fba4828279fc75afcf6c113c9ddf87646ecd2c737f8078c77ef391e13d56aafea00eba00073884cd2ada0acfd11b2
7
+ data.tar.gz: 220a3b82b01ec336d98217edb2a8940bab3ba46ab786aa5ed34aec93a23d55fadd9fb4a1668ca96f90f0c2f1679b8048d3b418970f2d79ee4819df779f49607d
data/README.md CHANGED
@@ -71,12 +71,9 @@ https://dummy4.com: it might contain a phishing kit (dummy.zip).
71
71
  ## Using Docker (alternative if you don't install Ruby)
72
72
 
73
73
  ```bash
74
- $ git clone https://github.com/ninoseki/miteru.git
75
- $ cd miteru/docker
76
- $ docker build -t miteru .
77
- $ docker run miteru
74
+ $ docker pull ninoseki/miteru
78
75
  # ex. auto-download detected phishing kit(s) into host machines's /tmp directory
79
- $ docker run -v /tmp:/tmp miteru execute --auto-download
76
+ $ docker run --rm -v /tmp:/tmp ninoseki/miteru execute --auto-download
80
77
  ```
81
78
 
82
79
  ## Configuration
@@ -1,6 +1,12 @@
1
- FROM ruby:2.6
2
-
3
- RUN gem install miteru
1
+ FROM ruby:2.6-alpine3.10
2
+ RUN apk --no-cache add git build-base ruby-dev \
3
+ && cd /tmp/ \
4
+ && git clone https://github.com/ninoseki/miteru.git \
5
+ && cd miteru \
6
+ && gem build miteru.gemspec -o miteru.gem \
7
+ && gem install miteru.gem \
8
+ && rm -rf /tmp/miteru \
9
+ && apk del --purge git build-base ruby-dev
4
10
 
5
11
  ENTRYPOINT ["miteru"]
6
12
 
@@ -60,20 +60,20 @@ module Miteru
60
60
  end
61
61
  end
62
62
 
63
- # @return [Miteru::Configuration] Miteru's current configuration
64
- def self.configuration
65
- @configuration ||= Configuration.new
66
- end
63
+ class << self
64
+ # @return [Miteru::Configuration] Miteru's current configuration
65
+ def configuration
66
+ @configuration ||= Configuration.new
67
+ end
67
68
 
68
- # Set Miteru's configuration
69
- # @param config [Miteru::Configuration]
70
- def self.configuration=(config)
71
- @configuration = config
72
- end
69
+ # Set Miteru's configuration
70
+ # @param config [Miteru::Configuration]
71
+ attr_writer :configuration
73
72
 
74
- # Modify Miteru's current configuration
75
- # @yieldparam [Miteru::Configuration] config current Miteru config
76
- def self.configure
77
- yield configuration
73
+ # Modify Miteru's current configuration
74
+ # @yieldparam [Miteru::Configuration] config current Miteru config
75
+ def configure
76
+ yield configuration
77
+ end
78
78
  end
79
79
  end
@@ -7,9 +7,11 @@ require "uri"
7
7
  module Miteru
8
8
  class Downloader
9
9
  attr_reader :base_dir
10
+ attr_reader :memo
10
11
 
11
12
  def initialize(base_dir = "/tmp")
12
13
  @base_dir = base_dir
14
+ @memo = {}
13
15
  raise ArgumentError, "#{base_dir} is not exist." unless Dir.exist?(base_dir)
14
16
  end
15
17
 
@@ -24,8 +26,9 @@ module Miteru
24
26
  destination = filepath_to_download(filename)
25
27
  begin
26
28
  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
+ hash = sha256(downloaded_filepath)
30
+ if duplicated?(hash)
31
+ puts "Do not download #{kit.url} because there is a duplicate file in the directory (SHA256: #{hash})."
29
32
  FileUtils.rm downloaded_filepath
30
33
  else
31
34
  puts "Download #{kit.url} as #{downloaded_filepath}"
@@ -46,14 +49,20 @@ module Miteru
46
49
  end
47
50
 
48
51
  def sha256(path)
52
+ return memo[path] if memo.key?(path)
53
+
49
54
  digest = Digest::SHA256.file(path)
50
- digest.hexdigest
55
+ hash = digest.hexdigest
56
+ memo[path] = hash
57
+ hash
58
+ end
59
+
60
+ def sha256s
61
+ Dir.glob("#{base_dir}/*.{zip,rar,7z,tar,gz}").map { |path| sha256(path) }
51
62
  end
52
63
 
53
- def duplicated?(file_path)
54
- base = sha256(file_path)
55
- sha256s = Dir.glob("#{base_dir}/*.{zip,rar,7z,tar,gz}").map { |path| sha256(path) }
56
- sha256s.select { |sha256| sha256 == base }.length > 1
64
+ def duplicated?(hash)
65
+ sha256s.count(hash) > 1
57
66
  end
58
67
  end
59
68
  end
@@ -20,7 +20,7 @@ module Miteru
20
20
  "http://#{domain}"
21
21
  ]
22
22
  end.flatten
23
- rescue HTTPResponseError, JSON::ParserError => e
23
+ rescue HTTPResponseError, HTTP::Error, JSON::ParserError => e
24
24
  puts "Failed to load ayashige feed (#{e})"
25
25
  []
26
26
  end
@@ -25,7 +25,7 @@ module Miteru
25
25
 
26
26
  res = JSON.parse(get(url))
27
27
  res["results"].map { |result| result.dig("task", "url") }
28
- rescue HTTPResponseError, JSON::ParserError => e
28
+ rescue HTTPResponseError, HTTP::Error, JSON::ParserError => e
29
29
  puts "Failed to load urlscan.io feed (#{e})"
30
30
  []
31
31
  end
@@ -11,6 +11,7 @@ module Miteru
11
11
  URLSCAN_UA = "miteru/#{Miteru::VERSION}"
12
12
 
13
13
  attr_reader :ssl_context
14
+
14
15
  def initialize
15
16
  ctx = OpenSSL::SSL::SSLContext.new
16
17
  ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -23,10 +24,6 @@ module Miteru
23
24
  destination
24
25
  end
25
26
 
26
- def self.download(url, base_dir = "/tmp")
27
- new.download(url, base_dir)
28
- end
29
-
30
27
  def get(url, options = {})
31
28
  options = options.merge default_options
32
29
 
@@ -36,16 +33,22 @@ module Miteru
36
33
  .get(url, options)
37
34
  end
38
35
 
39
- def self.get(url, options = {})
40
- new.get url, options
41
- end
42
-
43
36
  def post(url, options = {})
44
37
  HTTP.post url, options
45
38
  end
46
39
 
47
- def self.post(url, options = {})
48
- new.post url, options
40
+ class << self
41
+ def download(url, base_dir = "/tmp")
42
+ new.download(url, base_dir)
43
+ end
44
+
45
+ def get(url, options = {})
46
+ new.get url, options
47
+ end
48
+
49
+ def post(url, options = {})
50
+ new.post url, options
51
+ end
49
52
  end
50
53
 
51
54
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "0.12.10"
4
+ VERSION = "0.12.11"
5
5
  end
@@ -27,16 +27,16 @@ Gem::Specification.new do |spec|
27
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
- spec.add_development_dependency "rake", "~> 12.3"
30
+ spec.add_development_dependency "rake", "~> 13.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.8"
32
32
  spec.add_development_dependency "vcr", "~> 5.0"
33
- spec.add_development_dependency "webmock", "~> 3.6"
33
+ spec.add_development_dependency "webmock", "~> 3.7"
34
34
 
35
35
  spec.add_dependency "colorize", "~> 0.8"
36
- spec.add_dependency "down", "~> 4.8"
36
+ spec.add_dependency "down", "~> 5.0"
37
37
  spec.add_dependency "http", "~> 4.1"
38
38
  spec.add_dependency "oga", "~> 2.15"
39
- spec.add_dependency "parallel", "~> 1.17"
39
+ spec.add_dependency "parallel", "~> 1.18"
40
40
  spec.add_dependency "slack-notifier", "~> 2.3"
41
- spec.add_dependency "thor", "~> 0.19"
41
+ spec.add_dependency "thor", "~> 0.20"
42
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.12.10
4
+ version: 0.12.11
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-08-10 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '12.3'
61
+ version: '13.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '12.3'
68
+ version: '13.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.6'
103
+ version: '3.7'
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.6'
110
+ version: '3.7'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: colorize
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '4.8'
131
+ version: '5.0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '4.8'
138
+ version: '5.0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: http
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '1.17'
173
+ version: '1.18'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.17'
180
+ version: '1.18'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: slack-notifier
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '0.19'
201
+ version: '0.20'
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '0.19'
208
+ version: '0.20'
209
209
  description: An experimental phishing kit detector
210
210
  email:
211
211
  - manabu.niseki@gmail.com
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  - !ruby/object:Gem::Version
263
263
  version: '0'
264
264
  requirements: []
265
- rubygems_version: 3.0.4
265
+ rubygems_version: 3.0.6
266
266
  signing_key:
267
267
  specification_version: 4
268
268
  summary: An experimental phishing kit detector