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 reconnaisance, 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: AuthBrute, Cisco, CommandShell, Dos, Fuzzer, HttpCrawler, IAX2, JohnTheRipper, Login, MimeTypes, Nmap, PII, RServices, Report, Scanner, Timed, UDPScanner, Web, WmapCrawler, WmapModule, WmapScanDir, WmapScanFile, WmapScanGeneric, WmapScanQuery, WmapScanSSL, WmapScanServer, WmapScanUniqueQuery

Instance Attribute Summary collapse

Attributes inherited from Module

#arch, #author, #datastore, #error, #job_id, #license, #module_store, #options, #platform, #privileged, #references, #uuid

Attributes included from Framework::Offspring

#framework

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

#user_input

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

#user_output

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Module

#[], #[]=, #alias, #arch?, #arch_to_s, #author_to_s, #auxiliary?, cached?, #check, #comm, #compat, #compatible?, #debugging?, #description, #disclosure_date, #each_arch, #each_author, #encoder?, #exploit?, #fail_with, #file_path, #framework, #fullname, fullname, #import_defaults, is_usable, #name, #nop?, #orig_cls, #owner, #payload?, #platform?, #platform_to_s, #post?, #print_error, #print_good, #print_line, #print_line_prefix, #print_prefix, #print_status, #print_warning, #privileged?, #rank, rank, #rank_to_h, rank_to_h, #rank_to_s, rank_to_s, #refname, #register_parent, #replicant, #search_filter, #share_datastore, shortname, #shortname, #support_ipv6?, #target_host, #target_port, #validate, #vprint_debug, #vprint_error, #vprint_good, #vprint_line, #vprint_status, #vprint_warning, #workspace

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_debug, #print_error, #print_good, #print_line, #print_status, #print_warning

Constructor Details

#initialize(info = {}) ⇒ Auxiliary

Creates an instance of the auxiliary module.


37
38
39
40
41
42
43
44
45
# File 'lib/msf/core/auxiliary.rb', line 37

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

#queueObject

Returns the value of attribute queue


155
156
157
# File 'lib/msf/core/auxiliary.rb', line 155

def queue
  @queue
end

Class Method Details

.create(info = {}) ⇒ Object

Creates a singleton instance of this auxiliary class


50
51
52
53
# File 'lib/msf/core/auxiliary.rb', line 50

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.


23
24
25
# File 'lib/msf/core/auxiliary.rb', line 23

def self.type
  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.


144
145
146
147
148
149
150
151
152
153
# File 'lib/msf/core/auxiliary.rb', line 144

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.


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

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.


74
75
76
# File 'lib/msf/core/auxiliary.rb', line 74

def autofilter
  false
end

#autofilter_portsObject

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


82
83
84
# File 'lib/msf/core/auxiliary.rb', line 82

def autofilter_ports
  @autofilter_ports || []
end

#autofilter_servicesObject

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


90
91
92
# File 'lib/msf/core/auxiliary.rb', line 90

def autofilter_services
  @autofilter_services || []
end

#auxiliary_commandsObject


59
60
61
# File 'lib/msf/core/auxiliary.rb', line 59

def auxiliary_commands
  return { }
end

#cleanupObject

Called after 'run' returns


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

def cleanup
  abort_sockets()
end

#register_autofilter_ports(ports = []) ⇒ Object

Adds a port into the list of ports


97
98
99
100
101
102
# File 'lib/msf/core/auxiliary.rb', line 97

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

#register_autofilter_services(services = []) ⇒ Object


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

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.


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

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

#runObject


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

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

#setupObject

Called directly before 'run'


115
116
# File 'lib/msf/core/auxiliary.rb', line 115

def setup
end

#typeObject

Returns MODULE_AUX to indicate that this is an auxiliary module.


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

def type
  MODULE_AUX
end