Land #9708, reload_lib command for msfconsole

4.x
William Vu 2018-03-26 17:10:11 -05:00 committed by Jeffrey Martin
parent b870091380
commit 57411b4ef8
No known key found for this signature in database
GPG Key ID: 0CD9BBC2AF15F171
1 changed files with 40 additions and 6 deletions

View File

@ -38,6 +38,7 @@ module Msf
"search" => "Searches module names and descriptions",
"show" => "Displays modules of a given type, or all modules",
"use" => "Selects a module by name",
"reload_lib" => "Load a library file from specified path",
}
end
@ -64,6 +65,44 @@ module Msf
framework.datastore['LocalEditor'] || Rex::Compat.getenv('VISUAL') || Rex::Compat.getenv('EDITOR')
end
def reload_file(path, err_msg = 'Only library files can be loaded.')
if path.end_with?('.rb')
print_status("Reloading #{path}")
load path
else
print_error(err_msg)
end
end
def cmd_reload_lib_help
print_line 'Usage: reload_lib [lib/to/load.rb]'
print_line
print_line 'Load a library from specified path'
end
#
# Load a library file from given path
#
def cmd_reload_lib(*args)
if args.length > 0
path = args[0]
end
if args.include?('-h') || args.include?('--help')
cmd_reload_lib_help
return
end
if path.nil?
print_error('Nothing to load.')
return
end
reload_file(path)
end
def cmd_reload_lib_tabs(str, words)
tab_complete_filenames(str, words)
end
def cmd_edit_help
print_line "Usage: edit [file/to/edit.rb]"
print_line
@ -104,12 +143,7 @@ module Msf
return if editing_module
# XXX: This will try to reload *any* .rb and break on modules
if path.end_with?('.rb')
print_status("Reloading #{path}")
load path
else
print_error('Only library files can be reloaded after editing.')
end
reload_file(path)
end
#