CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/login_scanner.rb
Views: 1904
1
require 'metasploit/framework/credential'
2
3
module Metasploit
4
module Framework
5
# This module provides the namespace for all LoginScanner classes.
6
# LoginScanners are the classes that provide functionality for testing
7
# authentication against various different protocols and mechanisms.
8
module LoginScanner
9
require 'metasploit/framework/login_scanner/result'
10
require 'metasploit/framework/login_scanner/invalid'
11
12
# Gather a list of LoginScanner classes that can potentially be
13
# used for a given `service`, which should usually be an
14
# `Mdm::Service` object, but can be anything that responds to
15
# #name and #port.
16
#
17
# @param service [Mdm::Service,#port,#name]
18
# @return [Array<LoginScanner::Base>] A collection of LoginScanner
19
# classes that will probably give useful results when run
20
# against `service`.
21
def self.classes_for_service(service)
22
23
unless @required
24
# Make sure we've required all the scanner classes
25
dir = File.expand_path("../login_scanner/", __FILE__)
26
Dir.glob(File.join(dir, "*.rb")).each do |f|
27
require f if File.file?(f)
28
end
29
@required = true
30
end
31
32
self.constants.map{|sym| const_get(sym)}.select do |const|
33
next unless const.kind_of?(Class)
34
35
(
36
const.const_defined?(:LIKELY_PORTS) &&
37
const.const_get(:LIKELY_PORTS).include?(service.port)
38
) || (
39
const.const_defined?(:LIKELY_SERVICE_NAMES) &&
40
const.const_get(:LIKELY_SERVICE_NAMES).include?(service.name)
41
)
42
end
43
end
44
45
end
46
end
47
end
48
49