Path: blob/master/lib/rex/post/hwbridge/ui/console/command_dispatcher.rb
19513 views
# -*- coding: binary -*-12module Rex3module Post4module HWBridge5module Ui67###8#9# Base class for all command dispatchers within the hwbridge console user10# interface.11#12###13module Console::CommandDispatcher1415include Rex::Ui::Text::DispatcherShell::CommandDispatcher1617#18# The hash of file names to class names after a module has already been19# loaded once on the client side.20#21@@file_hash = {}2223#24# Checks the file name to hash association to see if the module being25# requested has already been loaded once.26#27def self.check_hash(name)28@@file_hash[name]29end3031#32# Sets the file path to class name association for future reference.33#34def self.set_hash(name, klass)35@@file_hash[name] = klass36end3738def initialize(shell)39@msf_loaded = nil40super41end4243#44# Returns the hwbridge client context.45#46def client47shell.client48end4950#51# Returns true if the client has a framework object.52#53# Used for firing framework session events54#55def msf_loaded?56return @msf_loaded unless @msf_loaded.nil?57# if we get here we must not have initialized yet5859@msf_loaded = !!(client.framework)60@msf_loaded61end6263#64# Log that an error occurred.65#66def log_error(msg)67print_error(msg)6869elog(msg, 'hwbridge', error: $!)70end7172end7374end75end76end77end787980