miteru 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 415304dc7c41fb9f40f68e7b8a59f0c03ce74c963020ecd2300b4b3a1ed3c058
4
- data.tar.gz: dcef1c8fe00901e5d97f7e4a12c3b63227e63a11e4c1a3498f768fbb7dc7ddd3
3
+ metadata.gz: '08e49cafafb4f0ca46b1aad40e1de0ce09e1098dd49395aa38ac98fd0d08e09f'
4
+ data.tar.gz: ace78f1898e2ef84573abb7ef8b624819d6819eb7924a21e6fb6189c918cfe98
5
5
  SHA512:
6
- metadata.gz: 686844a3d0e5016d66ced3d66a153777d56bc9d5751820b7e41d5a74e1d10ba6fb1d6fc334d69c66545c5e60782fb6df1baaf765bb5ac0ea1d9c48ff2d72b017
7
- data.tar.gz: 146cb5832df24866984bf65b4074e1a362db98394aa4fe6150bd941c1f13d28eeb2b1afda088e0d39eb404ad3faa6fd363fdf789fd6d6052736e5ef3f1e1163f
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
 
@@ -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
- 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
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 target_url, base_dir
36
- rescue Down::Error => _
37
- failed_urls << target_url
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?
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "down"
4
- require "uri"
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 filename
15
- uri = URI.parse(url)
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}/#{filename}"
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")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  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.3.0
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-18 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler