Class: Msf::Auxiliary

Inherits:
Module
  • Object
show all
Includes:
HasActions
Defined in:
lib/msf/core/auxiliary.rb,
lib/msf/core/auxiliary/login_scanner.rb,
lib/msf/core/auxiliary/report_summary.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, F5, Fuzzer, Gladinet, HttpCrawler, IAX2, Juniper, Kademlia, LLMNR, Login, LoginScanner, MDNS, MQTT, ManageEngineXnode, Mikrotik, MimeTypes, Mms, MultipleTargetHosts, NATPMP, NTP, Nfs, Nmap, Osticket, PII, PasswordCracker, Prometheus, RServices, Redis, Report, ReportSummary, Rocketmq, Scanner, Sms, Timed, UDPScanner, Ubiquiti, VYOS, Web, WmapCrawler, WmapModule, WmapScanDir, WmapScanFile, WmapScanGeneric, WmapScanQuery, WmapScanSSL, WmapScanServer, WmapScanUniqueQuery Classes: Complete, Failed

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info = {}) ⇒ Auxiliary

Creates an instance of the auxiliary module.



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

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
  self.fail_reason = Msf::Module::Failure::None
end

Instance Attribute Details

#check_codeObject

The result of the last check invocation (a Msf::Exploit::CheckCode), if any



187
188
189
# File 'lib/msf/core/auxiliary.rb', line 187

def check_code
  @check_code
end

#fail_detailObject

Detailed exception string indicating why the module was not successful



182
183
184
# File 'lib/msf/core/auxiliary.rb', line 182

def fail_detail
  @fail_detail
end

#fail_reasonObject

The reason why the module was not successful (one of the constant defined above)



177
178
179
# File 'lib/msf/core/auxiliary.rb', line 177

def fail_reason
  @fail_reason
end

#last_vuln_attemptObject

The VulnAttempt object created during this run, or nil/false if none was recorded. Used to prevent duplicate attempts when report_failure is called later and to enrich the attempt with check code details.



194
195
196
# File 'lib/msf/core/auxiliary.rb', line 194

def last_vuln_attempt
  @last_vuln_attempt
end

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

Sets the attribute passive

Parameters:

  • value

    the value to set the attribute passive to.



201
202
203
# File 'lib/msf/core/auxiliary.rb', line 201

def passive=(value)
  @passive = value
end

#queueObject

Returns the value of attribute queue.



196
197
198
# File 'lib/msf/core/auxiliary.rb', line 196

def queue
  @queue
end

#socketsObject (protected)

Returns the value of attribute sockets.



200
201
202
# File 'lib/msf/core/auxiliary.rb', line 200

def sockets
  @sockets
end

Class Method Details

.create(info = {}) ⇒ Object

Creates a singleton instance of this auxiliary class



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

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.



27
28
29
# File 'lib/msf/core/auxiliary.rb', line 27

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.



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

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.



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

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.



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

def autofilter
  false
end

#autofilter_portsObject

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



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

def autofilter_ports
  @autofilter_ports || []
end

#autofilter_servicesObject

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



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

def autofilter_services
  @autofilter_services || []
end

#auxiliary_commandsObject



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

def auxiliary_commands
  return { }
end

#cleanupObject

Called after 'run' returns



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

def cleanup
  abort_sockets()
end

#fail_with(reason, msg = nil) ⇒ Object

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



162
163
164
165
166
167
168
169
170
171
172
# File 'lib/msf/core/auxiliary.rb', line 162

def fail_with(reason, msg = nil)
  allowed_values = Msf::Module::Failure.constants.collect {|e| Msf::Module::Failure.const_get(e)}
  if allowed_values.include?(reason)
    self.fail_reason = reason
  else
    self.fail_reason = Msf::Module::Failure::Unknown
  end

  self.fail_detail = msg
  raise Msf::Auxiliary::Failed, "#{reason.to_s}: #{(msg || "No failure message given")}"
end

#register_autofilter_ports(ports = []) ⇒ Object

Adds a port into the list of ports



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

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

#register_autofilter_services(services = []) ⇒ Object



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

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.



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

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

#runObject



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

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

#setupObject

Called directly before 'run'



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

def setup
  alert_user
end

#typeObject

Returns MODULE_AUX to indicate that this is an auxiliary module.



34
35
36
# File 'lib/msf/core/auxiliary.rb', line 34

def type
  Msf::MODULE_AUX
end