miteru 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/miteru/cli.rb +8 -13
- data/lib/miteru/downloader.rb +5 -5
- data/lib/miteru/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08e49cafafb4f0ca46b1aad40e1de0ce09e1098dd49395aa38ac98fd0d08e09f'
|
4
|
+
data.tar.gz: ace78f1898e2ef84573abb7ef8b624819d6819eb7924a21e6fb6189c918cfe98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0cd62ad104dda985f0de5d023295079f43638553c08ba11a4c3c67e4271423d50860f6eb0349c10c2a25cc91ed57c231e452434ae657c848ba890499b0dcb76
|
7
|
+
data.tar.gz: 69f50f7a12ab6433f6ec1cb517779aaa92ab2f714f261f9ac8786e859a7d9b1c955ef503d7e355166f5481010ce7666ffe14f87c906f8011fbf2a80ca81cf487
|
data/README.md
CHANGED
@@ -32,10 +32,10 @@ Usage:
|
|
32
32
|
miteru execute
|
33
33
|
|
34
34
|
Options:
|
35
|
-
[--auto-download], [--no-auto-download]
|
36
|
-
[--download-to=DOWNLOAD_TO]
|
35
|
+
[--auto-download], [--no-auto-download] # Enable or disable auto-download of *.zip file(s)
|
36
|
+
[--download-to=DOWNLOAD_TO] # Directory to download file(s)
|
37
37
|
# Default: /tmp
|
38
|
-
[--post-to-slack], [--no-post-to-slack]
|
38
|
+
[--post-to-slack], [--no-post-to-slack] # Post a message to Slack if it detects a phishing kit
|
39
39
|
[--verbose], [--no-verbose]
|
40
40
|
# Default: true
|
41
41
|
|
data/lib/miteru/cli.rb
CHANGED
@@ -6,9 +6,9 @@ require "thor"
|
|
6
6
|
|
7
7
|
module Miteru
|
8
8
|
class CLI < Thor
|
9
|
-
method_option :auto_download, type: :boolean, default: false
|
10
|
-
method_option :download_to, type: :string, default: "/tmp"
|
11
|
-
method_option :post_to_slack, type: :boolean, default: false
|
9
|
+
method_option :auto_download, type: :boolean, default: false, desc: "Enable or disable auto-download of *.zip file(s)"
|
10
|
+
method_option :download_to, type: :string, default: "/tmp", desc: "Directory to download file(s)"
|
11
|
+
method_option :post_to_slack, type: :boolean, default: false, desc: "Post a message to Slack if it detects a phishing kit"
|
12
12
|
method_option :verbose, type: :boolean, default: true
|
13
13
|
desc "execute", "Execute the crawler"
|
14
14
|
def execute
|
@@ -18,26 +18,21 @@ module Miteru
|
|
18
18
|
|
19
19
|
puts "#{website.url}: it might contain a phishing kit (#{website.zip_files.join(',')}).".colorize(:light_red)
|
20
20
|
post_to_slack(message) if options[:post_to_slack] && valid_slack_setting?
|
21
|
-
|
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
|
25
|
-
end
|
21
|
+
download_zip_files(website.url, website.zip_files, options[:download_to]) if options[:auto_download]
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
29
25
|
no_commands do
|
30
26
|
def download_zip_files(url, zip_files, base_dir)
|
31
|
-
failed_urls = []
|
32
27
|
zip_files.each do |path|
|
33
28
|
target_url = "#{url}/#{path}"
|
34
29
|
begin
|
35
|
-
Downloader.download
|
36
|
-
|
37
|
-
|
30
|
+
destination = Downloader.download(target_url, base_dir)
|
31
|
+
puts "Download #{target_url} as #{destination}"
|
32
|
+
rescue Down::Error => e
|
33
|
+
puts "Failed to download: #{target_url} (#{e})"
|
38
34
|
end
|
39
35
|
end
|
40
|
-
raise DownloadError, "Failed to download: #{failed_urls}.join(',')" unless failed_urls.empty?
|
41
36
|
end
|
42
37
|
|
43
38
|
def valid_slack_setting?
|
data/lib/miteru/downloader.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "down"
|
4
|
-
require "
|
4
|
+
require "securerandom"
|
5
5
|
|
6
6
|
module Miteru
|
7
7
|
class Downloader
|
@@ -11,17 +11,17 @@ module Miteru
|
|
11
11
|
@base_dir = base_dir
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
File.basename(uri.path)
|
14
|
+
def save_filename
|
15
|
+
"#{SecureRandom.alphanumeric}.zip"
|
17
16
|
end
|
18
17
|
|
19
18
|
def destination
|
20
|
-
@destination ||= "#{base_dir}/#{
|
19
|
+
@destination ||= "#{base_dir}/#{save_filename}"
|
21
20
|
end
|
22
21
|
|
23
22
|
def download
|
24
23
|
Down.download(url, destination: destination)
|
24
|
+
destination
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.download(url, base_dir = "/tmp")
|
data/lib/miteru/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.1
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|