Skip to content

Commit 0bca3a2

Browse files
committed
POST module duplicate search results
Running a POST module in meterpreter was causing duplicate search results for the executed module. For example, running post/windows/gather/checkvm would produce duplicate results for that module when executing “search checkvm” in msf. Debugging revealed that the cmd_exec function in meterpreter’s ui command_dispatcher core was creating the specified module, and then promptly reloading it. The reload function was causing the duplicate module_detail record to be written to the msg postgres database instance. Further analysis revealed that the “original_mod” could be used for running the post module, so the “reloaded_mod” was removed and the “original_mod” used in it’s place to run the post module. SeeRM rapid7#8754
1 parent c2bb265 commit 0bca3a2

File tree

1 file changed

+2
-3
lines changed
  • lib/rex/post/meterpreter/ui/console/command_dispatcher

1 file changed

+2
-3
lines changed

lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,17 +542,16 @@ def cmd_run(*args)
542542
# fall back to using the scripting interface.
543543
if (msf_loaded? and mod = client.framework.modules.create(script_name))
544544
original_mod = mod
545-
reloaded_mod = client.framework.modules.reload_module(original_mod)
546545

547-
unless reloaded_mod
546+
unless original_mod
548547
error = client.framework.modules.module_load_error_by_path[original_mod.file_path]
549548
print_error("Failed to reload module: #{error}")
550549

551550
return
552551
end
553552

554553
opts = (args + [ "SESSION=#{client.sid}" ]).join(',')
555-
reloaded_mod.run_simple(
554+
original_mod.run_simple(
556555
#'RunAsJob' => true,
557556
'LocalInput' => shell.input,
558557
'LocalOutput' => shell.output,

0 commit comments

Comments
 (0)