-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to use numerics with info command #14053
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,22 @@ def cmd_info_help | |
print_line | ||
end | ||
|
||
def print_module_info(mod, dump_json: false, show_doc: false) | ||
if dump_json | ||
print(Serializer::Json.dump_module(mod) + "\n") | ||
elsif show_doc | ||
f = Tempfile.new(["#{mod.shortname}_doc", '.html']) | ||
begin | ||
print_status("Generating documentation for #{mod.shortname}, then opening #{f.path} in a browser...") | ||
Msf::Util::DocumentGenerator.spawn_module_document(mod, f) | ||
ensure | ||
f.close if f | ||
end | ||
else | ||
print(Serializer::ReadableText.dump_module(mod)) | ||
end | ||
end | ||
|
||
# | ||
# Displays information about one or more module. | ||
# | ||
|
@@ -128,49 +144,41 @@ def cmd_info(*args) | |
end | ||
|
||
if (args.length == 0) | ||
if (active_module) | ||
if dump_json | ||
print(Serializer::Json.dump_module(active_module) + "\n") | ||
elsif show_doc | ||
f = Tempfile.new(["#{active_module.shortname}_doc", '.html']) | ||
begin | ||
print_status("Generating documentation for #{active_module.shortname}, then opening #{f.path} in a browser...") | ||
Msf::Util::DocumentGenerator.spawn_module_document(active_module, f) | ||
ensure | ||
f.close if f | ||
end | ||
else | ||
print(Serializer::ReadableText.dump_module(active_module)) | ||
end | ||
if active_module | ||
print_module_info(active_module, dump_json: dump_json, show_doc: show_doc) | ||
return true | ||
else | ||
cmd_info_help | ||
return false | ||
end | ||
elsif args.include? "-h" | ||
elsif args.include? '-h' | ||
cmd_info_help | ||
return false | ||
end | ||
|
||
args.each do |arg| | ||
mod_name = arg | ||
|
||
args.each { |name| | ||
# Use a module by search index | ||
index_from_list(@module_search_results, mod_name) do |mod| | ||
next unless mod && mod.respond_to?(:fullname) | ||
|
||
# Module cache object from @module_search_results | ||
mod_name = mod.fullname | ||
end | ||
|
||
# Ensure we have a reference name and not a path | ||
name = trim_path(mod_name, 'modules') | ||
|
||
# Creates an instance of the module | ||
mod = framework.modules.create(name) | ||
|
||
if (mod == nil) | ||
if mod.nil? | ||
print_error("Invalid module: #{name}") | ||
elsif dump_json | ||
print(Serializer::Json.dump_module(mod) + "\n") | ||
elsif show_doc | ||
f = Tempfile.new(["#{mod.shortname}_doc", '.html']) | ||
begin | ||
print_status("Generating documentation for #{mod.shortname}, then opening #{f.path} in a browser...") | ||
Msf::Util::DocumentGenerator.spawn_module_document(mod, f) | ||
ensure | ||
f.close if f | ||
end | ||
else | ||
print(Serializer::ReadableText.dump_module(mod)) | ||
print_module_info(mod, dump_json: dump_json, show_doc: show_doc) | ||
end | ||
} | ||
end | ||
end | ||
|
||
def cmd_options_help | ||
|
@@ -649,7 +657,10 @@ def cmd_use(*args) | |
|
||
# Use a module by search index | ||
index_from_list(@module_search_results, mod_name) do |mod| | ||
return false unless mod && mod.respond_to?(:fullname) | ||
unless mod && mod.respond_to?(:fullname) | ||
print_error("Invalid module index: #{mod_name}") | ||
return false | ||
end | ||
Comment on lines
+660
to
+663
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if you do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dwelch-r7, you beat me on this: #14053 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great usability change! |
||
|
||
# Module cache object from @module_search_results | ||
mod_name = mod.fullname | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if we could have the same error message that has been added to the
use
command when an index is invalid?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I didn't see it happens later, when checking the return value of
framework.modules.create(name)
.