CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/parsed_options/console.rb
Views: 1904
1
# Parsed options for {Metasploit::Framework::Command::Console}
2
class Metasploit::Framework::ParsedOptions::Console < Metasploit::Framework::ParsedOptions::Base
3
# Options parsed from msfconsole command-line.
4
#
5
# @return [ActiveSupport::OrderedOptions]
6
def options
7
unless @options
8
super.tap { |options|
9
options.console = ActiveSupport::OrderedOptions.new
10
11
options.console.commands = []
12
options.console.confirm_exit = false
13
options.console.histfile = nil
14
options.console.logger = nil
15
options.console.local_output = nil
16
options.console.plugins = []
17
options.console.quiet = false
18
options.console.readline = true
19
options.console.resources = []
20
options.console.subcommand = :run
21
}
22
end
23
24
@options
25
end
26
27
private
28
29
# Parses msfconsole arguments into {#options}.
30
#
31
# @return [OptionParser]
32
def option_parser
33
unless @option_parser
34
super.tap { |option_parser|
35
option_parser.banner = "Usage: #{option_parser.program_name} [options]"
36
37
option_parser.separator 'Console options:'
38
39
option_parser.on('-a', '--ask', "Ask before exiting Metasploit or accept 'exit -y'") do
40
options.console.confirm_exit = true
41
end
42
43
option_parser.on('-H', '--history-file FILE', 'Save command history to the specified file') do |file|
44
options.console.histfile = file
45
end
46
47
option_parser.on('-l', '--logger STRING', "Specify a logger to use (#{Rex::Logging::LogSinkFactory.available_sinks.join(', ')})") do |logger|
48
options.console.logger = logger
49
end
50
51
option_parser.on('--[no-]readline') do |readline|
52
options.console.readline = readline
53
end
54
55
option_parser.on('-L', '--real-readline', 'Use the system Readline library instead of RbReadline') do
56
message = "The RealReadline option has been marked as deprecated, and is currently a noop.\n"
57
message << "Metasploit Framework now uses Reline exclusively as the input handling library.\n"
58
message << "If you require this functionality, please use the following link to tell us:\n"
59
message << ' https://github.com/rapid7/metasploit-framework/issues/19399'
60
warn message
61
end
62
63
option_parser.on('-o', '--output FILE', 'Output to the specified file') do |file|
64
options.console.local_output = file
65
end
66
67
option_parser.on('-p', '--plugin PLUGIN', 'Load a plugin on startup') do |plugin|
68
options.console.plugins << plugin
69
end
70
71
option_parser.on('-q', '--quiet', 'Do not print the banner on startup') do
72
options.console.quiet = true
73
end
74
75
option_parser.on('-r', '--resource FILE', 'Execute the specified resource file (- for stdin)') do |file|
76
options.console.resources << file
77
end
78
79
option_parser.on(
80
'-x',
81
'--execute-command COMMAND',
82
'Execute the specified console commands (use ; for multiples)'
83
) do |commands|
84
options.console.commands += commands.split(/\s*;\s*/)
85
end
86
}
87
end
88
89
@option_parser
90
end
91
end
92
93