miteru 0.14.1 → 0.14.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docker/Dockerfile +1 -1
- data/lib/miteru/configuration.rb +7 -0
- data/lib/miteru/feeds.rb +1 -11
- data/lib/miteru/http_client.rb +14 -1
- data/lib/miteru/kit.rb +47 -15
- data/lib/miteru/version.rb +1 -1
- data/lib/miteru/website.rb +31 -5
- data/miteru.gemspec +4 -4
- data/renovate.json +5 -0
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e33e427231064c47dd4e1358e71e009ebc9418af15350e1f9c7f833ea02205f
|
4
|
+
data.tar.gz: cf3e3f1608a6be63b7b5b93f1e12a8264935da1e059bfbda7437f91a8009bf63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e26651ad45bfc20c22b6584b3ea6f8419f99801f36e6673835034c4a77da3ea5ec2502273265fae8f89590551c4bd3eb42f33bc66a6fb3b873422b57e5136d40
|
7
|
+
data.tar.gz: f582e8422d5d33a97b8f9d3ae7aa58fe1346fc68284b867c0139f7bb908107b3b8eb8081f1bcdc3bbfb678427d318e6eaf269ce1d28647d317ec7dd8ed49a7d8
|
data/docker/Dockerfile
CHANGED
data/lib/miteru/configuration.rb
CHANGED
@@ -28,6 +28,10 @@ module Miteru
|
|
28
28
|
# @return [Boolean]
|
29
29
|
attr_accessor :verbose
|
30
30
|
|
31
|
+
attr_reader :valid_extensions
|
32
|
+
|
33
|
+
attr_reader :valid_mime_types
|
34
|
+
|
31
35
|
def initialize
|
32
36
|
@auto_download = false
|
33
37
|
@ayashige = false
|
@@ -37,6 +41,9 @@ module Miteru
|
|
37
41
|
@size = 100
|
38
42
|
@threads = Parallel.processor_count
|
39
43
|
@verbose = false
|
44
|
+
|
45
|
+
@valid_extensions = [".zip", ".rar", ".7z", ".tar", ".gz"].freeze
|
46
|
+
@valid_mime_types = ["application/zip", "application/vnd.rar", "application/x-7z-compressed", "application/x-tar", "application/gzip"]
|
40
47
|
end
|
41
48
|
|
42
49
|
def auto_download?
|
data/lib/miteru/feeds.rb
CHANGED
@@ -10,7 +10,6 @@ require_relative "./feeds/urlscan_pro"
|
|
10
10
|
module Miteru
|
11
11
|
class Feeds
|
12
12
|
IGNORE_EXTENSIONS = %w(.htm .html .php .asp .aspx .exe .txt).freeze
|
13
|
-
VALID_EXTENSIONS = [".zip", ".rar", ".7z", ".tar", ".gz"].freeze
|
14
13
|
|
15
14
|
def initialize
|
16
15
|
@feeds = [
|
@@ -49,16 +48,7 @@ module Miteru
|
|
49
48
|
segments = uri.path.split("/")
|
50
49
|
return [base] if segments.length.zero?
|
51
50
|
|
52
|
-
urls = (0...segments.length).map
|
53
|
-
breakdowned_url = "#{base}#{segments[0..idx].join('/')}"
|
54
|
-
breakdown = [breakdowned_url]
|
55
|
-
if idx > 0 && idx < segments.length - 1
|
56
|
-
VALID_EXTENSIONS.each do |ext|
|
57
|
-
breakdown << "#{base}#{segments[0..idx - 1].join('/')}/#{segments[idx]}#{ext}"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
breakdown
|
61
|
-
end.flatten
|
51
|
+
urls = (0...segments.length).map { |idx| "#{base}#{segments[0..idx].join('/')}" }
|
62
52
|
|
63
53
|
urls.reject do |breakdowned_url|
|
64
54
|
# Reject a url which ends with specific extension names
|
data/lib/miteru/http_client.rb
CHANGED
@@ -18,11 +18,20 @@ module Miteru
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def download(url, destination)
|
21
|
-
down = Down::Http.new(default_options) { |client| client.headers(default_headers) }
|
21
|
+
down = Down::Http.new(**default_options) { |client| client.headers(**default_headers) }
|
22
22
|
down.download(url, destination: destination)
|
23
23
|
destination
|
24
24
|
end
|
25
25
|
|
26
|
+
def head(url, options = {})
|
27
|
+
options = options.merge default_options
|
28
|
+
|
29
|
+
HTTP.follow
|
30
|
+
.timeout(3)
|
31
|
+
.headers(urlscan_url?(url) ? urlscan_headers : default_headers)
|
32
|
+
.head(url, options)
|
33
|
+
end
|
34
|
+
|
26
35
|
def get(url, options = {})
|
27
36
|
options = options.merge default_options
|
28
37
|
|
@@ -48,6 +57,10 @@ module Miteru
|
|
48
57
|
def post(url, options = {})
|
49
58
|
new.post url, options
|
50
59
|
end
|
60
|
+
|
61
|
+
def head(url, options = {})
|
62
|
+
new.head url, options
|
63
|
+
end
|
51
64
|
end
|
52
65
|
|
53
66
|
private
|
data/lib/miteru/kit.rb
CHANGED
@@ -5,37 +5,44 @@ require "securerandom"
|
|
5
5
|
|
6
6
|
module Miteru
|
7
7
|
class Kit
|
8
|
-
VALID_EXTENSIONS =
|
8
|
+
VALID_EXTENSIONS = Miteru.configuration.valid_extensions
|
9
|
+
VALID_MIME_TYPES = Miteru.configuration.valid_mime_types
|
9
10
|
|
10
|
-
attr_reader :
|
11
|
+
attr_reader :url
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
attr_reader :status
|
14
|
+
attr_reader :content_length
|
15
|
+
attr_reader :mime_type
|
16
|
+
|
17
|
+
def initialize(url)
|
18
|
+
@url = url
|
19
|
+
|
20
|
+
@content_length = nil
|
21
|
+
@mime_type = nil
|
22
|
+
@status = nil
|
15
23
|
end
|
16
24
|
|
17
|
-
def valid
|
18
|
-
|
25
|
+
def valid?;
|
26
|
+
# make a HEAD request for the validation
|
27
|
+
before_validation
|
28
|
+
|
29
|
+
valid_ext? && reachable? && valid_mime_type? && valid_content_length?
|
19
30
|
end
|
20
31
|
|
21
32
|
def extname
|
22
|
-
return ".tar.gz" if
|
33
|
+
return ".tar.gz" if url.end_with?("tar.gz")
|
23
34
|
|
24
|
-
File.extname(
|
35
|
+
File.extname(url)
|
25
36
|
end
|
26
37
|
|
27
38
|
def basename
|
28
|
-
File.basename(
|
39
|
+
File.basename(url)
|
29
40
|
end
|
30
41
|
|
31
42
|
def filename
|
32
43
|
CGI.unescape basename
|
33
44
|
end
|
34
45
|
|
35
|
-
def url
|
36
|
-
"#{base_url}/#{basename}"
|
37
|
-
end
|
38
|
-
|
39
46
|
def download_filepath
|
40
47
|
"#{base_dir}/#{download_filename}"
|
41
48
|
end
|
@@ -59,7 +66,7 @@ module Miteru
|
|
59
66
|
end
|
60
67
|
|
61
68
|
def hostname
|
62
|
-
URI(
|
69
|
+
URI(url).hostname
|
63
70
|
end
|
64
71
|
|
65
72
|
def download_filename
|
@@ -69,5 +76,30 @@ module Miteru
|
|
69
76
|
def base_dir
|
70
77
|
@base_dir ||= Miteru.configuration.download_to
|
71
78
|
end
|
79
|
+
|
80
|
+
def valid_ext?
|
81
|
+
VALID_EXTENSIONS.include? extname
|
82
|
+
end
|
83
|
+
|
84
|
+
def before_validation
|
85
|
+
res = HTTPClient.head(url)
|
86
|
+
@content_length = res.content_length
|
87
|
+
@mime_type = res.content_type.mime_type.to_s
|
88
|
+
@status = res.status
|
89
|
+
rescue StandardError
|
90
|
+
# do nothing
|
91
|
+
end
|
92
|
+
|
93
|
+
def reachable?
|
94
|
+
status&.success?
|
95
|
+
end
|
96
|
+
|
97
|
+
def valid_mime_type?
|
98
|
+
VALID_MIME_TYPES.include? mime_type
|
99
|
+
end
|
100
|
+
|
101
|
+
def valid_content_length?
|
102
|
+
content_length.to_i > 0
|
103
|
+
end
|
72
104
|
end
|
73
105
|
end
|
data/lib/miteru/version.rb
CHANGED
data/lib/miteru/website.rb
CHANGED
@@ -4,7 +4,10 @@ require "oga"
|
|
4
4
|
|
5
5
|
module Miteru
|
6
6
|
class Website
|
7
|
+
VALID_EXTENSIONS = Miteru.configuration.valid_extensions
|
8
|
+
|
7
9
|
attr_reader :url
|
10
|
+
|
8
11
|
def initialize(url)
|
9
12
|
@url = url
|
10
13
|
end
|
@@ -15,7 +18,7 @@ module Miteru
|
|
15
18
|
|
16
19
|
def kits
|
17
20
|
@kits ||= links.map do |link|
|
18
|
-
kit = Kit.new(
|
21
|
+
kit = Kit.new(link)
|
19
22
|
kit.valid? ? kit : nil
|
20
23
|
end.compact
|
21
24
|
end
|
@@ -33,7 +36,7 @@ module Miteru
|
|
33
36
|
end
|
34
37
|
|
35
38
|
def has_kits?
|
36
|
-
|
39
|
+
kits?
|
37
40
|
rescue Addressable::URI::InvalidURIError, ArgumentError, Encoding::CompatibilityError, HTTP::Error, LL::ParserError, OpenSSL::SSL::SSLError => _e
|
38
41
|
false
|
39
42
|
end
|
@@ -46,6 +49,10 @@ module Miteru
|
|
46
49
|
"It might contain #{noun}: #{filename_with_sizes}."
|
47
50
|
end
|
48
51
|
|
52
|
+
def links
|
53
|
+
(href_links + possible_file_links).compact.uniq
|
54
|
+
end
|
55
|
+
|
49
56
|
private
|
50
57
|
|
51
58
|
def response
|
@@ -66,12 +73,31 @@ module Miteru
|
|
66
73
|
nil
|
67
74
|
end
|
68
75
|
|
69
|
-
def
|
70
|
-
if doc
|
71
|
-
doc.css("a").map { |a| a.get("href") }.compact
|
76
|
+
def href_links
|
77
|
+
if doc && ok? && index?
|
78
|
+
doc.css("a").map { |a| a.get("href") }.compact.map do |href|
|
79
|
+
href = href.start_with?("/") ? href : "/#{href}"
|
80
|
+
url + href
|
81
|
+
end
|
72
82
|
else
|
73
83
|
[]
|
74
84
|
end
|
85
|
+
rescue Addressable::URI::InvalidURIError, ArgumentError, Encoding::CompatibilityError, HTTP::Error, LL::ParserError, OpenSSL::SSL::SSLError => _e
|
86
|
+
[]
|
87
|
+
end
|
88
|
+
|
89
|
+
def possible_file_links
|
90
|
+
uri = URI.parse(url)
|
91
|
+
|
92
|
+
segments = uri.path.split("/")
|
93
|
+
return [] if segments.length.zero?
|
94
|
+
|
95
|
+
last = segments.last
|
96
|
+
VALID_EXTENSIONS.map do |ext|
|
97
|
+
new_segments = segments[0..-2] + ["#{last}#{ext}"]
|
98
|
+
uri.path = new_segments.join("/")
|
99
|
+
uri.to_s
|
100
|
+
end
|
75
101
|
end
|
76
102
|
end
|
77
103
|
end
|
data/miteru.gemspec
CHANGED
@@ -30,14 +30,14 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "rake", "~> 13.0"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.9"
|
32
32
|
spec.add_development_dependency "vcr", "~> 6.0"
|
33
|
-
spec.add_development_dependency "webmock", "~> 3.
|
33
|
+
spec.add_development_dependency "webmock", "~> 3.9"
|
34
34
|
|
35
35
|
spec.add_dependency "colorize", "~> 0.8"
|
36
|
-
spec.add_dependency "down", "~> 5.
|
36
|
+
spec.add_dependency "down", "~> 5.2"
|
37
37
|
spec.add_dependency "http", "~> 4.4"
|
38
|
-
spec.add_dependency "oga", "~> 3.
|
38
|
+
spec.add_dependency "oga", "~> 3.3"
|
39
39
|
spec.add_dependency "parallel", "~> 1.19"
|
40
40
|
spec.add_dependency "slack-notifier", "~> 2.3"
|
41
41
|
spec.add_dependency "thor", "~> 1.0"
|
42
|
-
spec.add_dependency "urlscan", "~> 0.
|
42
|
+
spec.add_dependency "urlscan", "~> 0.6"
|
43
43
|
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.14.
|
4
|
+
version: 0.14.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
103
|
+
version: '3.9'
|
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.
|
110
|
+
version: '3.9'
|
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: '5.
|
131
|
+
version: '5.2'
|
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: '5.
|
138
|
+
version: '5.2'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: http
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '3.
|
159
|
+
version: '3.3'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '3.
|
166
|
+
version: '3.3'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: parallel
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,14 +212,14 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: '0.
|
215
|
+
version: '0.6'
|
216
216
|
type: :runtime
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: '0.
|
222
|
+
version: '0.6'
|
223
223
|
description: An experimental phishing kit detector
|
224
224
|
email:
|
225
225
|
- manabu.niseki@gmail.com
|
@@ -259,12 +259,13 @@ files:
|
|
259
259
|
- lib/miteru/version.rb
|
260
260
|
- lib/miteru/website.rb
|
261
261
|
- miteru.gemspec
|
262
|
+
- renovate.json
|
262
263
|
- screenshots/slack.png
|
263
264
|
homepage: https://github.com/ninoseki/miteru
|
264
265
|
licenses:
|
265
266
|
- MIT
|
266
267
|
metadata: {}
|
267
|
-
post_install_message:
|
268
|
+
post_install_message:
|
268
269
|
rdoc_options: []
|
269
270
|
require_paths:
|
270
271
|
- lib
|
@@ -280,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
281
|
version: '0'
|
281
282
|
requirements: []
|
282
283
|
rubygems_version: 3.1.2
|
283
|
-
signing_key:
|
284
|
+
signing_key:
|
284
285
|
specification_version: 4
|
285
286
|
summary: An experimental phishing kit detector
|
286
287
|
test_files: []
|