miteru 0.2.0 → 0.3.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 +4 -1
- data/lib/miteru.rb +1 -0
- data/lib/miteru/cli.rb +24 -4
- data/lib/miteru/downloader.rb +31 -0
- data/lib/miteru/error.rb +1 -0
- data/lib/miteru/version.rb +1 -1
- data/miteru.gemspec +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 415304dc7c41fb9f40f68e7b8a59f0c03ce74c963020ecd2300b4b3a1ed3c058
|
4
|
+
data.tar.gz: dcef1c8fe00901e5d97f7e4a12c3b63227e63a11e4c1a3498f768fbb7dc7ddd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686844a3d0e5016d66ced3d66a153777d56bc9d5751820b7e41d5a74e1d10ba6fb1d6fc334d69c66545c5e60782fb6df1baaf765bb5ac0ea1d9c48ff2d72b017
|
7
|
+
data.tar.gz: 146cb5832df24866984bf65b4074e1a362db98394aa4fe6150bd941c1f13d28eeb2b1afda088e0d39eb404ad3faa6fd363fdf789fd6d6052736e5ef3f1e1163f
|
data/README.md
CHANGED
@@ -32,9 +32,12 @@ Usage:
|
|
32
32
|
miteru execute
|
33
33
|
|
34
34
|
Options:
|
35
|
+
[--auto-download], [--no-auto-download]
|
36
|
+
[--download-to=DOWNLOAD_TO]
|
37
|
+
# Default: /tmp
|
38
|
+
[--post-to-slack], [--no-post-to-slack]
|
35
39
|
[--verbose], [--no-verbose]
|
36
40
|
# Default: true
|
37
|
-
[--post-to-slack], [--no-post-to-slack]
|
38
41
|
|
39
42
|
Execute the crawler
|
40
43
|
```
|
data/lib/miteru.rb
CHANGED
data/lib/miteru/cli.rb
CHANGED
@@ -6,20 +6,40 @@ require "thor"
|
|
6
6
|
|
7
7
|
module Miteru
|
8
8
|
class CLI < Thor
|
9
|
-
method_option :
|
9
|
+
method_option :auto_download, type: :boolean, default: false
|
10
|
+
method_option :download_to, type: :string, default: "/tmp"
|
10
11
|
method_option :post_to_slack, type: :boolean, default: false
|
12
|
+
method_option :verbose, type: :boolean, default: true
|
11
13
|
desc "execute", "Execute the crawler"
|
12
14
|
def execute
|
13
15
|
websites = Crawler.execute(options[:verbose])
|
14
16
|
websites.each do |website|
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
next unless website.has_kit?
|
18
|
+
|
19
|
+
puts "#{website.url}: it might contain a phishing kit (#{website.zip_files.join(',')}).".colorize(:light_red)
|
20
|
+
post_to_slack(message) if options[:post_to_slack] && valid_slack_setting?
|
21
|
+
begin
|
22
|
+
download_zip_files(website.url, website.zip_files, options[:download_to]) if options[:auto_download]
|
23
|
+
rescue DownloadError => e
|
24
|
+
puts e.to_s
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
22
29
|
no_commands do
|
30
|
+
def download_zip_files(url, zip_files, base_dir)
|
31
|
+
failed_urls = []
|
32
|
+
zip_files.each do |path|
|
33
|
+
target_url = "#{url}/#{path}"
|
34
|
+
begin
|
35
|
+
Downloader.download target_url, base_dir
|
36
|
+
rescue Down::Error => _
|
37
|
+
failed_urls << target_url
|
38
|
+
end
|
39
|
+
end
|
40
|
+
raise DownloadError, "Failed to download: #{failed_urls}.join(',')" unless failed_urls.empty?
|
41
|
+
end
|
42
|
+
|
23
43
|
def valid_slack_setting?
|
24
44
|
ENV["SLACK_WEBHOOK_URL"] != nil
|
25
45
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "down"
|
4
|
+
require "uri"
|
5
|
+
|
6
|
+
module Miteru
|
7
|
+
class Downloader
|
8
|
+
attr_reader :url, :base_dir
|
9
|
+
def initialize(url, base_dir = "/tmp")
|
10
|
+
@url = url
|
11
|
+
@base_dir = base_dir
|
12
|
+
end
|
13
|
+
|
14
|
+
def filename
|
15
|
+
uri = URI.parse(url)
|
16
|
+
File.basename(uri.path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def destination
|
20
|
+
@destination ||= "#{base_dir}/#{filename}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def download
|
24
|
+
Down.download(url, destination: destination)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.download(url, base_dir = "/tmp")
|
28
|
+
new(url, base_dir).download
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/miteru/error.rb
CHANGED
data/lib/miteru/version.rb
CHANGED
data/miteru.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "webmock", "~> 3.4"
|
34
34
|
|
35
35
|
spec.add_dependency "colorize", "~> 0.8"
|
36
|
+
spec.add_dependency "down", "~> 4.5"
|
36
37
|
spec.add_dependency "http", "~> 3.3"
|
37
38
|
spec.add_dependency "oga", "~> 2.15"
|
38
39
|
spec.add_dependency "thor", "~> 0.19"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miteru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.8'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: down
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '4.5'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '4.5'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: http
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,6 +213,7 @@ files:
|
|
199
213
|
- lib/miteru.rb
|
200
214
|
- lib/miteru/cli.rb
|
201
215
|
- lib/miteru/crawler.rb
|
216
|
+
- lib/miteru/downloader.rb
|
202
217
|
- lib/miteru/error.rb
|
203
218
|
- lib/miteru/version.rb
|
204
219
|
- lib/miteru/website.rb
|