Skip to content

Commit a52f491

Browse files
committed
Land rapid7#4615, stopgap fix for module load race
2 parents 2f4ad97 + 9017aa0 commit a52f491

File tree

1 file changed

+12
-3
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class Core
101101
# Constant for disclosure date formatting in search functions
102102
DISCLOSURE_DATE_FORMAT = "%Y-%m-%d"
103103

104+
# Constant for a retry timeout on using modules before they're loaded
105+
CMD_USE_TIMEOUT = 3
106+
104107
# Returns the list of commands supported by this command dispatcher
105108
def commands
106109
{
@@ -2418,9 +2421,15 @@ def cmd_use(*args)
24182421
mod_name = args[0]
24192422

24202423
begin
2421-
if ((mod = framework.modules.create(mod_name)) == nil)
2422-
print_error("Failed to load module: #{mod_name}")
2423-
return false
2424+
mod = framework.modules.create(mod_name)
2425+
unless mod
2426+
# Try one more time; see #4549
2427+
sleep CMD_USE_TIMEOUT
2428+
mod = framework.modules.create(mod_name)
2429+
unless mod
2430+
print_error("Failed to load module: #{mod_name}")
2431+
return false
2432+
end
24242433
end
24252434
rescue Rex::AmbiguousArgumentError => info
24262435
print_error(info.to_s)

0 commit comments

Comments
 (0)