Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/core/auxiliary.rb
Views: 11780
# -*- coding: binary -*-12module Msf34###5#6# The auxiliary class acts as a base class for all modules that perform7# reconnaissance, retrieve data, brute force logins, or any other action8# that doesn't fit our concept of an 'exploit' (involving payloads and9# targets and whatnot).10#11###12class Auxiliary < Msf::Module1314class Complete < RuntimeError15end1617class Failed < RuntimeError18end192021include HasActions2223#24# Returns MODULE_AUX to indicate that this is an auxiliary module.25#26def self.type27Msf::MODULE_AUX28end2930#31# Returns MODULE_AUX to indicate that this is an auxiliary module.32#33def type34Msf::MODULE_AUX35end3637#38# Creates an instance of the auxiliary module.39#40def initialize(info = {})4142# Call the parent constructor after making any necessary modifications43# to the information hash.44super(info)4546self.sockets = Array.new47self.queue = Array.new48end4950#51# Creates a singleton instance of this auxiliary class52#53def self.create(info = {})54return @@aux_singleton if @@aux_singleton55@@aux_singleton = self.new(info)56end5758def run59print_status("Running the default Auxiliary handler")60end6162def auxiliary_commands63return { }64end6566#67# Performs last-minute sanity checking of auxiliary parameters. This method68# is called during automated exploitation attempts and allows an69# auxiliary module to filter bad attempts, obtain more information, and choose70# better parameters based on the available data. Returning anything that71# evaluates to "false" will cause this specific auxiliary attempt to72# be skipped. This method can and will change datastore values and73# may interact with the backend database. The default value for auxiliary74# modules is false, since not all auxiliary modules actually attempt75# to exploit a vulnerability.76#77def autofilter78false79end8081#82# Provides a list of ports that can be used for matching this module83# against target systems.84#85def autofilter_ports86@autofilter_ports || []87end8889#90# Provides a list of services that can be used for matching this module91# against target systems.92#93def autofilter_services94@autofilter_services || []95end9697#98# Adds a port into the list of ports99#100def register_autofilter_ports(ports=[])101@autofilter_ports ||= []102@autofilter_ports << ports103@autofilter_ports.flatten!104@autofilter_ports.uniq!105end106107def register_autofilter_services(services=[])108@autofilter_services ||= []109@autofilter_services << services110@autofilter_services.flatten!111@autofilter_services.uniq!112end113114115#116# Called directly before 'run'117#118def setup119alert_user120end121122#123# Called after 'run' returns124#125def cleanup126abort_sockets()127end128129#130# Adds a socket to the list of sockets opened by this exploit.131#132def add_socket(sock)133self.sockets << sock134end135136#137# Removes a socket from the list of sockets.138#139def remove_socket(sock)140self.sockets.delete(sock)141end142143#144# This method is called once a new session has been created on behalf of145# this module instance and all socket connections created by this146# module should be closed.147#148def abort_sockets149sockets.delete_if { |sock|150151begin152sock.close153rescue ::Exception154end155true156}157end158159# Override Msf::Module#fail_with for Msf::Simple::Auxiliary::job_run_proc160def fail_with(reason, msg = nil)161raise Msf::Auxiliary::Failed, "#{reason.to_s}: #{msg}"162end163164attr_accessor :queue165166protected167168attr_accessor :sockets169attr_writer :passive170171end172173end174175176177