miteru 2.0.3 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4133dc72d0d07c5719999c526b8534a2dd7b5db5fe74172042b747c5cc557d4a
4
- data.tar.gz: d2f59be0a18bdaee1b74633a58b8ed59a396862defd4b80dff4ae8ae9d8199f4
3
+ metadata.gz: 509957b241020f76fcd9c85a6acbb9e80c0f8b3224fe5c1b4af41dcd2faa6ca5
4
+ data.tar.gz: 4e507a9974264a9b98d1ded16c09496a06ed4ca83409f75fc49719c37f934f77
5
5
  SHA512:
6
- metadata.gz: 4a311f7ffa407ed11951f8f3b7ce696510ba31f8888dff459d3a04e4a19ec892f6f7e5651b7616e70a4482cf07d92f657dc4765ef17b6f42e66a3b526c7e1e26
7
- data.tar.gz: 70b43504f29dc3646a343a87029e5c7a785d777099352717a4d2c2f26801879d2541d90ec5568f04d56c6635a35067397c4042e64a3177b6375cb74e51b5eae3
6
+ metadata.gz: 3dc8e2b4569555f5551a1b7fd2407162949cc7a459a5a7f83c5a787206b5cf39b34f16235466b6bcd74f34bac1878e1e4df6797daebe407eda2c03a9e7379e3a
7
+ data.tar.gz: 69d83a4c964ebbcd87b416675ed03bc18e270c0d604a19ef98b8988a0f344388eb49d0fb290edaa2f8637fa5f100608a3e9a76a1571503bda529611aea332bc0
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Miteru
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/miteru.svg)](https://badge.fury.io/rb/miteru)
4
- [![Ruby CI](https://github.com/ninoseki/miteru/actions/workflows/test.yml/badge.svg)](https://github.com/ninoseki/miteru/actions/workflows/test.yml)
4
+ [![Ruby CI](https://github.com/ninoseki/miteru/actions/workflows/ruby.yml/badge.svg)](https://github.com/ninoseki/miteru/actions/workflows/ruby.yml)
5
5
  [![CodeFactor](https://www.codefactor.io/repository/github/ninoseki/miteru/badge)](https://www.codefactor.io/repository/github/ninoseki/miteru)
6
6
  [![Coverage Status](https://coveralls.io/repos/github/ninoseki/miteru/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/miteru?branch=master)
7
7
 
@@ -14,12 +14,12 @@ I take no responsibility and/or liability for how you choose to use this tool.
14
14
 
15
15
  ## How It Works
16
16
 
17
- - It collects phishy URLs from the following feeds:
18
- - urlscan.io's automatic submissions. (`task.method:automatic`)
17
+ - Collect phishy URLs from the following feeds:
18
+ - urlscan.io's automatic submissions. (`task.method:automatic AND NOT task.source:urlscan-observe`)
19
19
  - urlscan.io phish feed. (available for Pro users)
20
20
  - [mitchellkrogza/Phishing.Database](https://github.com/mitchellkrogza/Phishing.Database)'s `phishing-links-ACTIVE-NOW.txt`.
21
21
  - [ninoseki/ayashige](https://github.com/ninoseki/ayashige) feed.
22
- - It checks each phishy URL whether it enables directory listing and contains phishing kits (compressed files) or not.
22
+ - Check each phishy URL whether it enables directory listing and contains phishing kits (compressed files) or not.
23
23
  - Note: Supported compressed files are: `*.zip`, `*.rar`, `*.7z`, `*.tar` and `*.gz`.
24
24
 
25
25
  ## Docs
data/lib/miteru/config.rb CHANGED
@@ -27,7 +27,8 @@ module Miteru
27
27
  threads: Parallel.processor_count,
28
28
  urlscan_api_key: nil,
29
29
  urlscan_submit_visibility: "public",
30
- urlscan_date_condition: ">now-1h",
30
+ urlscan_date_condition: "date:>now-1h",
31
+ urlscan_base_condition: "task.method:automatic AND NOT task.source:urlscan-observe",
31
32
  verbose: false
32
33
  )
33
34
 
@@ -91,6 +92,9 @@ module Miteru
91
92
  # @!attribute [r] urlscan_date_condition
92
93
  # @return [String]
93
94
 
95
+ # @!attribute [r] urlscan_base_condition
96
+ # @return [String]
97
+
94
98
  def database_url=(val)
95
99
  super(URI(val.to_s))
96
100
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "colorize"
4
+
3
5
  module Miteru
4
6
  class Crawler < Service
5
7
  #
@@ -7,7 +9,10 @@ module Miteru
7
9
  #
8
10
  def call(website)
9
11
  Try[OpenSSL::SSL::SSLError, ::HTTP::Error, Addressable::URI::InvalidURIError] do
10
- Miteru.logger.info("Website:#{website.truncated_url} has #{website.kits.length} kit(s).")
12
+ info = "Website:#{website.info}."
13
+ info = info.colorize(:red) if website.kits?
14
+
15
+ Miteru.logger.info(info)
11
16
  return unless website.kits?
12
17
 
13
18
  notify website
@@ -31,7 +31,7 @@ module Miteru
31
31
  end
32
32
 
33
33
  def q
34
- "task.method:automatic AND date:#{Miteru.config.urlscan_date_condition}"
34
+ "#{base_condition} AND #{date_condition}"
35
35
  end
36
36
 
37
37
  #
@@ -59,6 +59,14 @@ module Miteru
59
59
  end
60
60
  end
61
61
  end
62
+
63
+ def base_condition
64
+ Miteru.config.urlscan_base_condition
65
+ end
66
+
67
+ def date_condition
68
+ Miteru.config.urlscan_date_condition
69
+ end
62
70
  end
63
71
  end
64
72
  end
@@ -23,7 +23,7 @@ module Miteru
23
23
  end
24
24
 
25
25
  def q
26
- "date:#{Miteru.config.urlscan_date_condition}"
26
+ Miteru.config.urlscan_date_condition
27
27
  end
28
28
 
29
29
  def format
@@ -5,6 +5,7 @@ require "slack-notifier"
5
5
  module Miteru
6
6
  module Notifiers
7
7
  class SlackAttachment
8
+ # @return [String]
8
9
  attr_reader :url
9
10
 
10
11
  def initialize(url)
@@ -14,7 +15,7 @@ module Miteru
14
15
  def to_a
15
16
  [
16
17
  {
17
- text: defanged_url,
18
+ text:,
18
19
  fallback: "VT & urlscan.io links",
19
20
  actions:
20
21
  }
@@ -47,10 +48,6 @@ module Miteru
47
48
  }
48
49
  end
49
50
 
50
- def defanged_url
51
- @defanged_url ||= url.to_s.gsub(".", "[.]")
52
- end
53
-
54
51
  def domain
55
52
  @domain ||= [].tap do |out|
56
53
  out << URI(url).hostname
@@ -59,6 +56,10 @@ module Miteru
59
56
  end.first
60
57
  end
61
58
 
59
+ def text
60
+ domain.to_s.gsub(".", "[.]")
61
+ end
62
+
62
63
  def _urlscan_link
63
64
  return nil unless domain
64
65
 
@@ -82,12 +83,11 @@ module Miteru
82
83
  return unless callable?
83
84
 
84
85
  attachment = SlackAttachment.new(website.url)
85
- kits = website.kits.select(&:downloaded?)
86
- notifier.post(text: website.message.capitalize, attachments: attachment.to_a) if kits.any?
86
+ notifier.post(text: website.info, attachments: attachment.to_a) if website.kits?
87
87
  end
88
88
 
89
89
  def callable?
90
- !slack_webhook_url.nil?
90
+ !webhook_url.nil?
91
91
  end
92
92
 
93
93
  private
@@ -9,7 +9,7 @@ module Miteru
9
9
  def call(website)
10
10
  return unless callable?
11
11
 
12
- website.kits.each { |kit| submit(kit.url) }
12
+ website.kits.each { |kit| submit(kit.url, source: website.source) }
13
13
  end
14
14
 
15
15
  def callable?
@@ -41,8 +41,12 @@ module Miteru
41
41
  Miteru.config.urlscan_submit_visibility
42
42
  end
43
43
 
44
- def submit(url)
45
- http.post("https://urlscan.io/api/v1/scan/", json: {tags:, visibility:, url:})
44
+ #
45
+ # @param [String] url
46
+ # @param [String] source
47
+ #
48
+ def submit(url, source:)
49
+ http.post("https://urlscan.io/api/v1/scan/", json: {tags: tags + ["source:#{source}"], visibility:, url:})
46
50
  end
47
51
  end
48
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "2.0.3"
4
+ VERSION = "2.1.1"
5
5
  end
@@ -48,6 +48,14 @@ module Miteru
48
48
  url.truncate(64)
49
49
  end
50
50
 
51
+ def defanged_truncated_url
52
+ truncated_url.to_s.gsub(".", "[.]")
53
+ end
54
+
55
+ def info
56
+ "#{defanged_truncated_url} has #{kits.length} kit(s) (Source: #{source})"
57
+ end
58
+
51
59
  private
52
60
 
53
61
  def timeout
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: 2.0.3
4
+ version: 2.1.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: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -554,6 +554,7 @@ files:
554
554
  - ".github/workflows/ruby.yml"
555
555
  - ".gitignore"
556
556
  - ".rspec"
557
+ - ".rubocop.yml"
557
558
  - Gemfile
558
559
  - LICENSE
559
560
  - README.md