Skip to content

Commit

Permalink
Land rapid7#4615, stopgap fix for module load race
Browse files Browse the repository at this point in the history
  • Loading branch information
wvu committed Jan 21, 2015
2 parents 2f4ad97 + 9017aa0 commit a52f491
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/msf/ui/console/command_dispatcher/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class Core
# Constant for disclosure date formatting in search functions
DISCLOSURE_DATE_FORMAT = "%Y-%m-%d"

# Constant for a retry timeout on using modules before they're loaded
CMD_USE_TIMEOUT = 3

# Returns the list of commands supported by this command dispatcher
def commands
{
Expand Down Expand Up @@ -2418,9 +2421,15 @@ def cmd_use(*args)
mod_name = args[0]

begin
if ((mod = framework.modules.create(mod_name)) == nil)
print_error("Failed to load module: #{mod_name}")
return false
mod = framework.modules.create(mod_name)
unless mod
# Try one more time; see #4549
sleep CMD_USE_TIMEOUT
mod = framework.modules.create(mod_name)
unless mod
print_error("Failed to load module: #{mod_name}")
return false
end
end
rescue Rex::AmbiguousArgumentError => info
print_error(info.to_s)
Expand Down

0 comments on commit a52f491

Please sign in to comment.