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/rex/post/sql/ui/console/command_dispatcher.rb
Views: 11791
# -*- coding: binary -*-12require 'rex/post/sql/ui/console/command_dispatcher/client'3require 'rex/post/sql/ui/console/command_dispatcher/core'45module Rex6module Post7module Sql8module Ui9module Console1011###12#13# Base class for all command dispatchers within the Generic SQL console user interface.14#15###16module CommandDispatcher1718include Msf::Ui::Console::CommandDispatcher::Session1920#21# Initializes an instance of the core command set using the supplied session and client22# for interactivity.23#24# @param [Rex::Post::PostgreSQL::Ui::Console] console25def initialize(console)26super27@msf_loaded = nil28@filtered_commands = []29end3031#32# Returns the SQL client context.33# @return [Object]34def client35console = shell36console.client37end3839#40# Returns the PostgreSQL session context.41#42# @return [Msf::Sessions::PostgreSQL]43def session44console = shell45console.session46end4748#49# Returns the commands that meet the requirements50#51def filter_commands(all, reqs)52all.delete_if do |cmd, _desc|53if reqs[cmd]&.any? { |req| !client.commands.include?(req) }54@filtered_commands << cmd55true56end57end58end5960def unknown_command(cmd, line)61if @filtered_commands.include?(cmd)62print_error("The \"#{cmd}\" command is not supported by this session type (#{session.session_type})")63return :handled64end6566super67end6869#70# Returns true if the client has a framework object.71#72# Used for firing framework session events73#74def msf_loaded?75return @msf_loaded unless @msf_loaded.nil?7677# if we get here we must not have initialized yet7879@msf_loaded = !session.framework.nil?80@msf_loaded81end82end83end84end85end86end87end888990