CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/post/hwbridge/ui/console/command_dispatcher.rb
Views: 11789
1
# -*- coding: binary -*-
2
3
module Rex
4
module Post
5
module HWBridge
6
module Ui
7
8
###
9
#
10
# Base class for all command dispatchers within the hwbridge console user
11
# interface.
12
#
13
###
14
module Console::CommandDispatcher
15
16
include Rex::Ui::Text::DispatcherShell::CommandDispatcher
17
18
#
19
# The hash of file names to class names after a module has already been
20
# loaded once on the client side.
21
#
22
@@file_hash = {}
23
24
#
25
# Checks the file name to hash association to see if the module being
26
# requested has already been loaded once.
27
#
28
def self.check_hash(name)
29
@@file_hash[name]
30
end
31
32
#
33
# Sets the file path to class name association for future reference.
34
#
35
def self.set_hash(name, klass)
36
@@file_hash[name] = klass
37
end
38
39
def initialize(shell)
40
@msf_loaded = nil
41
super
42
end
43
44
#
45
# Returns the hwbridge client context.
46
#
47
def client
48
shell.client
49
end
50
51
#
52
# Returns true if the client has a framework object.
53
#
54
# Used for firing framework session events
55
#
56
def msf_loaded?
57
return @msf_loaded unless @msf_loaded.nil?
58
# if we get here we must not have initialized yet
59
60
@msf_loaded = !!(client.framework)
61
@msf_loaded
62
end
63
64
#
65
# Log that an error occurred.
66
#
67
def log_error(msg)
68
print_error(msg)
69
70
elog(msg, 'hwbridge', error: $!)
71
end
72
73
end
74
75
end
76
end
77
end
78
end
79
80