@@ -9,23 +9,27 @@ module Msf
99###
1010class DataStore
1111
12- # The global framework datastore doesn't currently import options
13- # For now, store an ad-hoc list of keys that the shell handles
14- #
15- # This list could be removed if framework's bootup sequence registers
16- # these as datastore options
17- GLOBAL_KEYS = %w[
18- ConsoleLogging
19- LogLevel
20- MinimumRank
21- SessionLogging
22- TimestampOutput
23- Prompt
24- PromptChar
25- PromptTimeFormat
26- MeterpreterPrompt
27- SessionTlvLogging
28- ]
12+ # Typed option definitions for globally-scoped datastore keys.
13+ # These are registered on the framework datastore at startup so that
14+ # normalization (e.g. OptBool converting "true" to true) applies even
15+ # when no module is active.
16+ GLOBAL_OPTION_DEFINITIONS = OptionContainer . new ( [
17+ OptBool . new ( 'ConsoleLogging' , [ false , 'Log all console input and output' , false ] ) ,
18+ OptInt . new ( 'LogLevel' , [ false , 'Verbosity of logs (default 0, max 3)' , 0 ] ) ,
19+ OptEnum . new ( 'MinimumRank' , [ false , 'The minimum rank of exploits that will run without explicit confirmation' , 'manual' , RankingName . values ] ) ,
20+ OptBool . new ( 'SessionLogging' , [ false , 'Log all input and output for sessions' , false ] ) ,
21+ OptBool . new ( 'TimestampOutput' , [ false , 'Prefix all console output with a timestamp' , false ] ) ,
22+ OptBool . new ( 'VERBOSE' , [ false , 'Enable detailed status messages - the specific behavior can differ per module' , false ] ) ,
23+ OptString . new ( 'Prompt' , [ false , 'The prompt string' , nil ] ) ,
24+ OptString . new ( 'PromptChar' , [ false , 'The prompt character' , nil ] ) ,
25+ OptString . new ( 'PromptTimeFormat' , [ false , 'Format for timestamp escapes in prompts' , nil ] ) ,
26+ OptString . new ( 'MeterpreterPrompt' , [ false , 'The meterpreter prompt string' , nil ] ) ,
27+ OptSessionTlvLogging . new ( 'SessionTlvLogging' , [ false , 'Log all incoming and outgoing TLV packets' , nil ] ) ,
28+ ] )
29+
30+ # Backward-compatible list of known global key names, derived from the
31+ # typed option definitions above.
32+ GLOBAL_KEYS = GLOBAL_OPTION_DEFINITIONS . keys . freeze
2933
3034 #
3135 # Initializes the data store's internal state.
@@ -136,7 +140,7 @@ def remove_option(name)
136140
137141 #
138142 # This method is a helper method that imports the default value for
139- # all of the supplied options
143+ # all of the supplied options.
140144 #
141145 def import_options ( options , imported_by = nil , overwrite = true )
142146 options . each_option do |name , option |
@@ -350,7 +354,7 @@ def merge!(other)
350354 end
351355 else
352356 other . each do |k , v |
353- self . store ( k , v )
357+ self [ k ] = v
354358 end
355359 end
356360
0 commit comments