diff --git a/lib/rex/ui/text/dispatcher_shell.rb b/lib/rex/ui/text/dispatcher_shell.rb index 88b2e078f22f9..281df7569d924 100644 --- a/lib/rex/ui/text/dispatcher_shell.rb +++ b/lib/rex/ui/text/dispatcher_shell.rb @@ -588,7 +588,15 @@ def run_command(dispatcher, method, arguments) # If the command is unknown... # def unknown_command(method, line) - print_error("Unknown command: #{method}") + # Map each dispatchers commands to valid_commands + valid_commands = dispatcher_stack.flat_map { |dispatcher| dispatcher.commands.keys } + + message = "Unknown command: #{method}." + suggestion = DidYouMean::SpellChecker.new(dictionary: valid_commands).correct(method).first + message << " Did you mean #{suggestion}?" if suggestion + message << ' Run the %grnhelp%clr command for more details.' + + print_error(message) end #