Class: Miteru::Website

Inherits:
Object
  • Object
show all
Defined in:
lib/miteru/website.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Website

Returns a new instance of Website.



8
9
10
# File 'lib/miteru/website.rb', line 8

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/miteru/website.rb', line 7

def url
  @url
end

Instance Method Details

#has_kits?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
# File 'lib/miteru/website.rb', line 35

def has_kits?
  ok? && index? && kits?
rescue Addressable::URI::InvalidURIError, ArgumentError, Encoding::CompatibilityError, HTTP::Error, LL::ParserError, OpenSSL::SSL::SSLError => _e
  false
end

#index?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/miteru/website.rb', line 27

def index?
  title.to_s.start_with? "Index of"
end

#kitsObject



16
17
18
19
20
21
# File 'lib/miteru/website.rb', line 16

def kits
  @kits ||= links.map do |link|
    kit = Kit.new(base_url: url, link: link.to_s)
    kit.valid? ? kit : nil
  end.compact
end

#kits?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/miteru/website.rb', line 31

def kits?
  !kits.empty?
end

#messageObject



41
42
43
44
45
46
47
# File 'lib/miteru/website.rb', line 41

def message
  return "It doesn't contain a phishing kit." unless kits?

  filename_with_sizes = kits.map(&:filename_with_size).join(", ")
  noun = kits.length == 1 ? "a phishing kit" : "phishing kits"
  "It might contain #{noun}: #{filename_with_sizes}."
end

#ok?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/miteru/website.rb', line 23

def ok?
  response.code == 200
end

#titleObject



12
13
14
# File 'lib/miteru/website.rb', line 12

def title
  doc&.at_css("title")&.text
end