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/ldap/ui/console/command_dispatcher.rb
Views: 11791
# -*- coding: binary -*-12require 'English'3require 'rex/ui/text/dispatcher_shell'45module Rex6module Post7module LDAP8module Ui9###10#11# Base class for all command dispatchers within the LDAP console user12# interface.13#14###15module Console::CommandDispatcher16include Msf::Ui::Console::CommandDispatcher::Session1718#19# Initializes an instance of the core command set using the supplied session and client20# for interactivity.21#22# @param [Rex::Post::LDAP::Ui::Console] console23def initialize(console)24super25@msf_loaded = nil26@filtered_commands = []27end2829#30# Returns the LDAP client context.31#32# @return [Rex::Proto::LDAP::Client]33def client34console = shell35console.client36end3738#39# Returns the LDAP session context.40#41# @return [Msf::Sessions::LDAP]42def session43console = shell44console.session45end4647#48# Returns the commands that meet the requirements49#50def filter_commands(all, reqs)51all.delete_if do |cmd, _desc|52if reqs[cmd]&.any? { |req| !client.commands.include?(req) }53@filtered_commands << cmd54true55end56end57end5859def unknown_command(cmd, line)60if @filtered_commands.include?(cmd)61print_error("The \"#{cmd}\" command is not supported by this session type (#{session.session_type})")62return :handled63end6465super66end6768#69# Return the subdir of the `documentation/` directory that should be used70# to find usage documentation71#72def docs_dir73File.join(super, 'ldap_session')74end7576#77# Returns true if the client has a framework object.78#79# Used for firing framework session events80#81def msf_loaded?82return @msf_loaded unless @msf_loaded.nil?8384# if we get here we must not have initialized yet8586@msf_loaded = !session.framework.nil?87@msf_loaded88end8990#91# Log that an error occurred.92#93def log_error(msg)94print_error(msg)9596elog(msg, 'ldap')9798dlog("Call stack:\n#{$ERROR_POSITION.join("\n")}", 'ldap')99end100end101end102end103end104end105106107