Class: Msf::Auxiliary

Inherits:
Module
  • Object
show all
Includes:
HasActions
Defined in:
lib/msf/core/auxiliary.rb

Overview

The auxiliary class acts as a base class for all modules that perform reconnaissance, retrieve data, brute force logins, or any other action that doesn't fit our concept of an 'exploit' (involving payloads and targets and whatnot).

Defined Under Namespace

Modules: Arista, AuthBrute, Brocade, CNPILOT, CRand, Cisco, CommandShell, DRDoS, Dos, EPMP, Etcd, Fuzzer, HttpCrawler, IAX2, Juniper, Kademlia, LLMNR, Login, MDNS, MQTT, Mikrotik, MimeTypes, Mms, NATPMP, NTP, Nmap, PII, PasswordCracker, RServices, Redis, Report, Scanner, Sms, Timed, UDPScanner, Ubiquiti, Web, WmapCrawler, WmapModule, WmapScanDir, WmapScanFile, WmapScanGeneric, WmapScanQuery, WmapScanSSL, WmapScanServer, WmapScanUniqueQuery Classes: Complete, Failed

Constant Summary

Constants inherited from Module

Module::REPLICANT_EXTENSION_DS_KEY

Constants included from Module::ModuleInfo

Module::ModuleInfo::UpdateableOptions

Instance Attribute Summary collapse

Attributes inherited from Module

#error, #job_id, #license, #platform, #privileged, #references, #user_data

Attributes included from Framework::Offspring

#framework

Attributes included from Module::UUID

#uuid

Attributes included from Rex::Ui::Subscriber::Input

#user_input

Attributes included from Rex::Ui::Subscriber::Output

#user_output

Attributes included from Module::Privileged

#priveli, #privileged

Attributes included from Module::Options

#options

Attributes included from Module::ModuleStore

#module_store

Attributes included from Module::ModuleInfo

#module_info

Attributes included from Module::FullName

#aliased_as

Attributes included from Module::DataStore

#datastore

Attributes included from Module::Author

#author

Attributes included from Module::Arch

#arch

Attributes included from Module::Alert

#alerts, #you_have_been_warned

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Module

#black_listed_auth_filenames, cached?, #debugging?, #default_cred?, #file_path, #framework, #has_check?, #orig_cls, #owner, #perform_extensions, #platform?, #platform_to_s, #post_auth?, #register_extensions, #register_parent, #replicant, #required_cred_options, #set_defaults, #workspace

Methods included from Module::Reliability

#reliability, #reliability_to_s

Methods included from Module::Stability

#stability, #stability_to_s

Methods included from Module::SideEffects

#side_effects, #side_effects_to_s

Methods included from Module::UUID

#generate_uuid

Methods included from Module::UI

#init_ui

Methods included from Module::UI::Message

#print_error, #print_good, #print_prefix, #print_status, #print_warning

Methods included from Module::UI::Message::Verbose

#vprint_error, #vprint_good, #vprint_status, #vprint_warning

Methods included from Module::UI::Line

#print_line, #print_line_prefix

Methods included from Module::UI::Line::Verbose

#vprint_line

Methods included from Rex::Ui::Subscriber

#copy_ui, #init_ui, #reset_ui

Methods included from Rex::Ui::Subscriber::Input

#gets

Methods included from Rex::Ui::Subscriber::Output

#flush, #print, #print_blank_line, #print_error, #print_good, #print_line, #print_status, #print_warning

Methods included from Module::Type

#auxiliary?, #encoder?, #evasion?, #exploit?, #nop?, #payload?, #post?

Methods included from Module::Ranking

#rank, #rank_to_h, #rank_to_s

Methods included from Module::Privileged

#privileged?

Methods included from Module::Options

#deregister_options, #register_advanced_options, #register_evasion_options, #register_options, #validate

Methods included from Module::Network

#comm, #support_ipv6?, #target_host, #target_port

Methods included from Module::ModuleStore

#[], #[]=

Methods included from Module::ModuleInfo

#alias, #description, #disclosure_date, #info_fixups, #merge_check_key, #merge_info, #merge_info_advanced_options, #merge_info_alias, #merge_info_description, #merge_info_evasion_options, #merge_info_name, #merge_info_options, #merge_info_string, #merge_info_version, #name, #notes, #update_info

Methods included from Module::FullName

#aliases, #fullname, #promptname, #realname, #refname, #shortname

Methods included from Module::DataStore

#import_defaults, #import_target_defaults, #share_datastore

Methods included from Module::Compatibility

#compat, #compatible?, #init_compat

Methods included from Module::Author

#author_to_s, #each_author

Methods included from Module::Auth

#store_valid_credential

Methods included from Module::Arch

#arch?, #arch_to_s, #each_arch

Methods included from Module::Alert

#add_alert, #add_error, #add_warning, #alert_user, #errors, #get_alerts, included, #is_usable?, #warnings

Constructor Details

#initialize(info = {}) ⇒ Auxiliary

Creates an instance of the auxiliary module.


43
44
45
46
47
48
49
50
51
# File 'lib/msf/core/auxiliary.rb', line 43

def initialize(info = {})

  # Call the parent constructor after making any necessary modifications
  # to the information hash.
  super(info)

  self.sockets = Array.new
  self.queue   = Array.new
end

Instance Attribute Details

#passive=(value) ⇒ Object (writeonly, protected)

Sets the attribute passive

Parameters:

  • value

    the value to set the attribute passive to.


172
173
174
# File 'lib/msf/core/auxiliary.rb', line 172

def passive=(value)
  @passive = value
end

#queueObject

Returns the value of attribute queue


167
168
169
# File 'lib/msf/core/auxiliary.rb', line 167

def queue
  @queue
end

#socketsObject (protected)

Returns the value of attribute sockets


171
172
173
# File 'lib/msf/core/auxiliary.rb', line 171

def sockets
  @sockets
end

Class Method Details

.create(info = {}) ⇒ Object

Creates a singleton instance of this auxiliary class


56
57
58
59
# File 'lib/msf/core/auxiliary.rb', line 56

def self.create(info = {})
  return @@aux_singleton if @@aux_singleton
  @@aux_singleton = self.new(info)
end

.typeObject

Returns MODULE_AUX to indicate that this is an auxiliary module.


29
30
31
# File 'lib/msf/core/auxiliary.rb', line 29

def self.type
  Msf::MODULE_AUX
end

Instance Method Details

#abort_socketsObject

This method is called once a new session has been created on behalf of this module instance and all socket connections created by this module should be closed.


151
152
153
154
155
156
157
158
159
160
# File 'lib/msf/core/auxiliary.rb', line 151

def abort_sockets
  sockets.delete_if { |sock|

    begin
      sock.close
    rescue ::Exception
    end
    true
  }
end

#add_socket(sock) ⇒ Object

Adds a socket to the list of sockets opened by this exploit.


135
136
137
# File 'lib/msf/core/auxiliary.rb', line 135

def add_socket(sock)
  self.sockets << sock
end

#autofilterObject

Performs last-minute sanity checking of auxiliary parameters. This method is called during automated exploitation attempts and allows an auxiliary module to filter bad attempts, obtain more information, and choose better parameters based on the available data. Returning anything that evaluates to “false” will cause this specific auxiliary attempt to be skipped. This method can and will change datastore values and may interact with the backend database. The default value for auxiliary modules is false, since not all auxiliary modules actually attempt to exploit a vulnerability.


80
81
82
# File 'lib/msf/core/auxiliary.rb', line 80

def autofilter
  false
end

#autofilter_portsObject

Provides a list of ports that can be used for matching this module against target systems.


88
89
90
# File 'lib/msf/core/auxiliary.rb', line 88

def autofilter_ports
  @autofilter_ports || []
end

#autofilter_servicesObject

Provides a list of services that can be used for matching this module against target systems.


96
97
98
# File 'lib/msf/core/auxiliary.rb', line 96

def autofilter_services
  @autofilter_services || []
end

#auxiliary_commandsObject


65
66
67
# File 'lib/msf/core/auxiliary.rb', line 65

def auxiliary_commands
  return { }
end

#cleanupObject

Called after 'run' returns


128
129
130
# File 'lib/msf/core/auxiliary.rb', line 128

def cleanup
  abort_sockets()
end

#fail_with(reason, msg = nil) ⇒ Object

Override Msf::Module#fail_with for Msf::Simple::Auxiliary::job_run_proc


163
164
165
# File 'lib/msf/core/auxiliary.rb', line 163

def fail_with(reason, msg = nil)
  raise Msf::Auxiliary::Failed, "#{reason.to_s}: #{msg}"
end

#register_autofilter_ports(ports = []) ⇒ Object

Adds a port into the list of ports


103
104
105
106
107
108
# File 'lib/msf/core/auxiliary.rb', line 103

def register_autofilter_ports(ports=[])
  @autofilter_ports ||= []
  @autofilter_ports << ports
  @autofilter_ports.flatten!
  @autofilter_ports.uniq!
end

#register_autofilter_services(services = []) ⇒ Object


110
111
112
113
114
115
# File 'lib/msf/core/auxiliary.rb', line 110

def register_autofilter_services(services=[])
  @autofilter_services ||= []
  @autofilter_services << services
  @autofilter_services.flatten!
  @autofilter_services.uniq!
end

#remove_socket(sock) ⇒ Object

Removes a socket from the list of sockets.


142
143
144
# File 'lib/msf/core/auxiliary.rb', line 142

def remove_socket(sock)
  self.sockets.delete(sock)
end

#runObject


61
62
63
# File 'lib/msf/core/auxiliary.rb', line 61

def run
  print_status("Running the default Auxiliary handler")
end

#setupObject

Called directly before 'run'


121
122
123
# File 'lib/msf/core/auxiliary.rb', line 121

def setup
  alert_user
end

#typeObject

Returns MODULE_AUX to indicate that this is an auxiliary module.


36
37
38
# File 'lib/msf/core/auxiliary.rb', line 36

def type
  Msf::MODULE_AUX
end