Skip to content

Commit cc293f0

Browse files
committed
Adds some fail safes to cmd_use
2 parents 60d5cef + 11e3e1f commit cc293f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/msf/ui/console/command_dispatcher/modules.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@ def cmd_use(*args)
597597
# Try to create an instance of the supplied module name
598598
mod_name = args[0]
599599

600+
# Ensure we have a reference name and not a path
601+
if mod_name.start_with?('modules/', '/')
602+
mod_name.sub!(/^(?:modules)?\//, '')
603+
end
604+
if mod_name.end_with?('.', '.r', '.rb')
605+
mod_name.sub!(/\.(?:rb?)?$/, '')
606+
end
607+
600608
begin
601609
mod = framework.modules.create(mod_name)
602610
unless mod

0 commit comments

Comments
 (0)