Add and use a callback to report meterpreter commands that are disabled
This commit is contained in:
parent
b983365665
commit
a587c166cb
|
@ -38,6 +38,7 @@ module Console::CommandDispatcher
|
||||||
|
|
||||||
def initialize(shell)
|
def initialize(shell)
|
||||||
@msf_loaded = nil
|
@msf_loaded = nil
|
||||||
|
@filtered_commands = []
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -53,9 +54,21 @@ module Console::CommandDispatcher
|
||||||
#
|
#
|
||||||
def filter_commands(all, reqs)
|
def filter_commands(all, reqs)
|
||||||
all.delete_if do |cmd, _desc|
|
all.delete_if do |cmd, _desc|
|
||||||
reqs[cmd]&.any? { |req| !client.commands.include?(req) }
|
if reqs[cmd]&.any? { |req| !client.commands.include?(req) }
|
||||||
|
@filtered_commands << cmd
|
||||||
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def unknown_command(cmd, line)
|
||||||
|
if @filtered_commands.include?(cmd)
|
||||||
|
print_error("The '#{cmd}' command is not supported by this Meterpreter type (#{client.session_type})")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Return the subdir of the `documentation/` directory that should be used
|
# Return the subdir of the `documentation/` directory that should be used
|
||||||
|
|
|
@ -328,6 +328,15 @@ module DispatcherShell
|
||||||
end
|
end
|
||||||
addresses
|
addresses
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# A callback that can be used to handle unknown commands. This can for example, allow a dispatcher to mark a command
|
||||||
|
# as being disabled.
|
||||||
|
#
|
||||||
|
# @return [Boolean] Returns true when the dispatcher has handled the command.
|
||||||
|
def unknown_command(method, line)
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -474,6 +483,8 @@ module DispatcherShell
|
||||||
self.on_command_proc.call(line.strip) if self.on_command_proc
|
self.on_command_proc.call(line.strip) if self.on_command_proc
|
||||||
run_command(dispatcher, method, arguments)
|
run_command(dispatcher, method, arguments)
|
||||||
found = true
|
found = true
|
||||||
|
elsif dispatcher.unknown_command(method, line)
|
||||||
|
found = true
|
||||||
end
|
end
|
||||||
rescue ::Interrupt
|
rescue ::Interrupt
|
||||||
found = true
|
found = true
|
||||||
|
|
Loading…
Reference in New Issue