@@ -15,12 +15,9 @@ module Msf
15
15
module Ui
16
16
module Console
17
17
18
- ###
19
18
#
20
- # This class implements a user interface driver on a console interface.
19
+ # A user interface driver on a console interface.
21
20
#
22
- ###
23
-
24
21
class Driver < Msf ::Ui ::Driver
25
22
26
23
ConfigCore = "framework/core"
@@ -44,21 +41,18 @@ class Driver < Msf::Ui::Driver
44
41
# prompt character. The optional hash can take extra values that will
45
42
# serve to initialize the console driver.
46
43
#
47
- # The optional hash values can include:
48
- #
49
- # AllowCommandPassthru
50
- #
51
- # Whether or not unknown commands should be passed through and executed by
52
- # the local system.
53
- #
54
- # RealReadline
55
- #
56
- # Whether or to use the system Readline or the RBReadline (default)
57
- #
58
- # HistFile
59
- #
60
- # Name of a file to store command history
61
- #
44
+ # @option opts [Boolean] 'AllowCommandPassthru' (true) Whether to allow
45
+ # unrecognized commands to be executed by the system shell
46
+ # @option opts [Boolean] 'RealReadline' (false) Whether to use the system's
47
+ # readline library instead of RBReadline
48
+ # @option opts [String] 'HistFile' (Msf::Config.history_file) Path to a file
49
+ # where we can store command history
50
+ # @option opts [Array<String>] 'Resources' ([]) A list of resource files to
51
+ # load. If no resources are given, will load the default resource script,
52
+ # 'msfconsole.rc' in the user's {Msf::Config.config_directory config
53
+ # directory}
54
+ # @option opts [Boolean] 'SkipDatabaseInit' (false) Whether to skip
55
+ # connecting to the database and running migrations
62
56
def initialize ( prompt = DefaultPrompt , prompt_char = DefaultPromptChar , opts = { } )
63
57
64
58
# Choose a readline library before calling the parent
@@ -253,14 +247,14 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
253
247
# Process things before we actually display the prompt and get rocking
254
248
on_startup ( opts )
255
249
256
- # Process the resource script
257
- if opts [ 'Resource' ] and opts [ 'Resource' ] . kind_of? Array
250
+ # Process any resource scripts
251
+ if opts [ 'Resource' ] . empty?
252
+ # None given, load the default
253
+ load_resource ( File . join ( Msf ::Config . config_directory , 'msfconsole.rc' ) )
254
+ else
258
255
opts [ 'Resource' ] . each { |r |
259
256
load_resource ( r )
260
257
}
261
- else
262
- # If the opt is nil here, we load ~/.msf3/msfconsole.rc
263
- load_resource ( opts [ 'Resource' ] )
264
258
end
265
259
266
260
# Process any additional startup commands
@@ -433,11 +427,11 @@ def save_config
433
427
end
434
428
end
435
429
430
+ # Processes a resource script file for the console.
436
431
#
437
- # Processes the resource script file for the console.
438
- #
439
- def load_resource ( path = nil )
440
- path ||= File . join ( Msf ::Config . config_directory , 'msfconsole.rc' )
432
+ # @param path [String] Path to a resource file to run
433
+ # @return [void]
434
+ def load_resource ( path )
441
435
return if not ::File . readable? ( path )
442
436
resource_file = ::File . read ( path )
443
437
@@ -605,9 +599,9 @@ def on_variable_unset(glob, var)
605
599
# The framework instance associated with this driver.
606
600
#
607
601
attr_reader :framework
608
- #
602
+ #
609
603
# Whether or not to confirm before exiting
610
- #
604
+ #
611
605
attr_reader :confirm_exit
612
606
#
613
607
# Whether or not commands can be passed through.
0 commit comments