diff --git a/lib/msf/ui/console/command_dispatcher/common.rb b/lib/msf/ui/console/command_dispatcher/common.rb index e764b89b00e62..edbc1b4dc3c6d 100644 --- a/lib/msf/ui/console/command_dispatcher/common.rb +++ b/lib/msf/ui/console/command_dispatcher/common.rb @@ -89,6 +89,10 @@ def set_rhosts_from_addrs(rhosts) # create the output file and assign it to the RHOSTS variable rhosts_file.write(rhosts.join("\n")+"\n") rhosts_file.close + # Keep a reference so Ruby's GC doesn't finalize and unlink the temp file + # before a module has a chance to read it. + @persisted_rhosts_files ||= [] + @persisted_rhosts_files << rhosts_file else # For short lists, just set it directly mydatastore['RHOSTS'] = rhosts.join(" ")