Update stdin processing in resource scripting

Originally in #4674, I wanted to add stdin to msfconsole -r, but I
purposefully left off support for stdin in the console. Now it works.
bug/bundler_fix
William Vu 2017-07-12 13:32:26 -05:00
parent e43adf0223
commit 18c9ac7abb
1 changed files with 14 additions and 12 deletions

View File

@ -37,8 +37,8 @@ module Msf
def cmd_resource_help
print_line "Usage: resource path1 [path2 ...]"
print_line
print_line "Run the commands stored in the supplied files. Resource files may also contain"
print_line "ruby code between <ruby></ruby> tags."
print_line "Run the commands stored in the supplied files (- for stdin)."
print_line "Resource files may also contain ERB or Ruby code between <ruby></ruby> tags."
print_line
print_line "See also: makerc"
print_line
@ -52,21 +52,23 @@ module Msf
args.each do |res|
good_res = nil
if ::File.exist?(res)
if res == '-'
good_res = res
elsif ::File.exist?(res)
good_res = res
elsif
# let's check to see if it's in the scripts/resource dir (like when tab completed)
[
::Msf::Config.script_directory + ::File::SEPARATOR + "resource",
::Msf::Config.user_script_directory + ::File::SEPARATOR + "resource"
].each do |dir|
res_path = dir + ::File::SEPARATOR + res
if ::File.exist?(res_path)
good_res = res_path
break
[
::Msf::Config.script_directory + ::File::SEPARATOR + "resource",
::Msf::Config.user_script_directory + ::File::SEPARATOR + "resource"
].each do |dir|
res_path = dir + ::File::SEPARATOR + res
if ::File.exist?(res_path)
good_res = res_path
break
end
end
end
end
if good_res
driver.load_resource(good_res)
else