miteru 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/lib/miteru/cli.rb +8 -5
- data/lib/miteru/crawler.rb +10 -17
- data/lib/miteru/version.rb +1 -1
- data/lib/miteru/website.rb +61 -0
- data/lib/miteru.rb +1 -0
- data/miteru.gemspec +3 -0
- metadata +45 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0961934a27b02e1571c875e3a5a1bed37e7069d5333b45ced0f2d20250c9423
|
4
|
+
data.tar.gz: 2172a57faed6cd18e7b00665f481821486606ab1407746bcf683bdea5e0829a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c100e58f709309e9d1dc1ed33cb660bcf7622bf4c8b5ec6186403571968d91a91e50bc22fb2087f662fa5dfb51e46b9c0688ed66d5758da69348a9955da0acec
|
7
|
+
data.tar.gz: 9efad43fa5a0e528d59c6b1c4ee16dd336b5378baf0c3bb21f6a9acafde84d16d806785968d7a5849e229a567c9e1e3f7c057cfd233a4ed40d0aa9ec67499a60
|
data/README.md
CHANGED
@@ -25,3 +25,25 @@ Commands:
|
|
25
25
|
miteru execute # Execute the crawler
|
26
26
|
miteru help [COMMAND] # Describe available commands or one specific command
|
27
27
|
```
|
28
|
+
|
29
|
+
```sh
|
30
|
+
$ miteru help execute
|
31
|
+
Usage:
|
32
|
+
miteru execute
|
33
|
+
|
34
|
+
Options:
|
35
|
+
[--verbose], [--no-verbose]
|
36
|
+
# Default: true
|
37
|
+
[--post-to-slack], [--no-post-to-slack]
|
38
|
+
|
39
|
+
Execute the crawler
|
40
|
+
```
|
41
|
+
|
42
|
+
```sh
|
43
|
+
$ miteru execute
|
44
|
+
...
|
45
|
+
https://dummy1.com: it doesn't contain a phishing kit.
|
46
|
+
https://dummy2.com: it doesn't contain a phishing kit.
|
47
|
+
https://dummy3.com: it doesn't contain a phishing kit.
|
48
|
+
https://dummy4.com: it might contain a phishing kit (dummy.zip).
|
49
|
+
```
|
data/lib/miteru/cli.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "colorize"
|
3
4
|
require "http"
|
4
5
|
require "thor"
|
5
6
|
|
6
7
|
module Miteru
|
7
8
|
class CLI < Thor
|
9
|
+
method_option :verbose, type: :boolean, default: true
|
8
10
|
method_option :post_to_slack, type: :boolean, default: false
|
9
11
|
desc "execute", "Execute the crawler"
|
10
12
|
def execute
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
websites = Crawler.execute(options[:verbose])
|
14
|
+
websites.each do |website|
|
15
|
+
if website.has_kit?
|
16
|
+
puts "#{website.url}: it might contain a phishing kit (#{website.zip_files.join(',')}).".colorize(:light_red)
|
17
|
+
post_to_slack(message) if options[:post_to_slack] && valid_slack_setting?
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
data/lib/miteru/crawler.rb
CHANGED
@@ -16,31 +16,24 @@ module Miteru
|
|
16
16
|
res["results"].map { |result| result.dig("task", "url") }
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
begin
|
21
|
-
res = get(url)
|
22
|
-
rescue HTTPResponseError => _
|
23
|
-
false
|
24
|
-
end
|
25
|
-
|
26
|
-
rules = ["Index of", ".zip"]
|
27
|
-
rules.all? { |rule| res.include? rule }
|
28
|
-
end
|
29
|
-
|
30
|
-
def execute
|
19
|
+
def execute(verbose = false)
|
31
20
|
pool = Thread.pool(threads)
|
32
|
-
|
21
|
+
websites = []
|
33
22
|
|
34
23
|
suspicous_urls.each do |url|
|
35
|
-
pool.process
|
24
|
+
pool.process do
|
25
|
+
website = Website.new(url)
|
26
|
+
puts "#{website.url}: it doesn't contain a phishing kit." if verbose && !website.has_kit?
|
27
|
+
websites << website
|
28
|
+
end
|
36
29
|
end
|
37
30
|
pool.shutdown
|
38
31
|
|
39
|
-
|
32
|
+
websites
|
40
33
|
end
|
41
34
|
|
42
|
-
def self.execute
|
43
|
-
new.execute
|
35
|
+
def self.execute(verbose = false)
|
36
|
+
new.execute(verbose)
|
44
37
|
end
|
45
38
|
|
46
39
|
private
|
data/lib/miteru/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "http"
|
4
|
+
require "oga"
|
5
|
+
|
6
|
+
module Miteru
|
7
|
+
class Website
|
8
|
+
attr_reader :url
|
9
|
+
def initialize(url)
|
10
|
+
@url = url
|
11
|
+
build
|
12
|
+
end
|
13
|
+
|
14
|
+
def title
|
15
|
+
doc.at_css("title")&.text
|
16
|
+
end
|
17
|
+
|
18
|
+
def zip_files
|
19
|
+
@zip_files ||= doc.css("a").map do |a|
|
20
|
+
href = a.get("href")
|
21
|
+
href&.end_with?(".zip") ? href : nil
|
22
|
+
end.compact
|
23
|
+
end
|
24
|
+
|
25
|
+
def ok?
|
26
|
+
response.code == 200
|
27
|
+
end
|
28
|
+
|
29
|
+
def index?
|
30
|
+
title == "Index of /"
|
31
|
+
end
|
32
|
+
|
33
|
+
def zip_files?
|
34
|
+
!zip_files.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def has_kit?
|
38
|
+
ok? && index? && zip_files?
|
39
|
+
end
|
40
|
+
|
41
|
+
def build
|
42
|
+
doc
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def response
|
48
|
+
@response ||= get
|
49
|
+
end
|
50
|
+
|
51
|
+
def get
|
52
|
+
ctx = OpenSSL::SSL::SSLContext.new
|
53
|
+
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
54
|
+
HTTP.get(url, ssl_context: ctx)
|
55
|
+
end
|
56
|
+
|
57
|
+
def doc
|
58
|
+
@doc ||= Oga.parse_html(response.body.to_s)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/miteru.rb
CHANGED
data/miteru.gemspec
CHANGED
@@ -26,12 +26,15 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.16"
|
28
28
|
spec.add_development_dependency "coveralls", "~> 0.8"
|
29
|
+
spec.add_development_dependency "glint", "~> 0.1"
|
29
30
|
spec.add_development_dependency "rake", "~> 12.3"
|
30
31
|
spec.add_development_dependency "rspec", "~> 3.8"
|
31
32
|
spec.add_development_dependency "vcr", "~> 4.0"
|
32
33
|
spec.add_development_dependency "webmock", "~> 3.4"
|
33
34
|
|
35
|
+
spec.add_dependency "colorize", "~> 0.8"
|
34
36
|
spec.add_dependency "http", "~> 3.3"
|
37
|
+
spec.add_dependency "oga", "~> 2.15"
|
35
38
|
spec.add_dependency "thor", "~> 0.19"
|
36
39
|
spec.add_dependency "thread", "~> 0.2.2"
|
37
40
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: glint
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '3.4'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: colorize
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.8'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.8'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: http
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +136,20 @@ dependencies:
|
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '3.3'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: oga
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.15'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '2.15'
|
111
153
|
- !ruby/object:Gem::Dependency
|
112
154
|
name: thor
|
113
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +201,7 @@ files:
|
|
159
201
|
- lib/miteru/crawler.rb
|
160
202
|
- lib/miteru/error.rb
|
161
203
|
- lib/miteru/version.rb
|
204
|
+
- lib/miteru/website.rb
|
162
205
|
- miteru.gemspec
|
163
206
|
homepage: https://github.com/ninoseki/miteru
|
164
207
|
licenses:
|