From 177e1321ae114b8b8d6d86ca23ed0222fd559383 Mon Sep 17 00:00:00 2001 From: RageLtMan Date: Thu, 15 Feb 2018 04:20:09 -0500 Subject: [PATCH 1/2] Aux command dispatcher in exploit ctx with action The Auxiliary command dispatcher checks modules for passive actions expecting them to have included Msf::Module::HasActions mixin. The mixin is included in post and aux modules already, but not in exploits. When the aux dispatcher handles an exploit module, it may get upset along the lines of: ``` [-] Error while running command exploit: undefined method 'passive' for # Did you mean? passive? Call stack: /opt/metasploit4/msf4/lib/msf/ui/console/command_dispatcher/ auxiliary.rb:106:in `cmd_run' ``` Avoid this mess by having the conditional which checks the methods included by that mixin depend on the module having included the mixin in the first place. Testing: In local fork (hence the lineno) it seems to fix the problem. The problem condition and fix should be independently tested upstream. --- lib/msf/ui/console/command_dispatcher/auxiliary.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msf/ui/console/command_dispatcher/auxiliary.rb b/lib/msf/ui/console/command_dispatcher/auxiliary.rb index a568d4446e..9bbd52834d 100644 --- a/lib/msf/ui/console/command_dispatcher/auxiliary.rb +++ b/lib/msf/ui/console/command_dispatcher/auxiliary.rb @@ -98,7 +98,7 @@ class Auxiliary # Always run passive modules in the background if (mod.passive || mod.passive_action?(action || mod.default_action)) jobify = true - end + end if mod.is_a?(Msf::Module::HasActions) begin mod.run_simple( From a197997acaab86602c14d81c1c9b1ec767174398 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 15 Feb 2018 17:45:09 -0600 Subject: [PATCH 2/2] avoid chinese finger trap logic, put it all on one side --- lib/msf/ui/console/command_dispatcher/auxiliary.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/auxiliary.rb b/lib/msf/ui/console/command_dispatcher/auxiliary.rb index 9bbd52834d..2baf64261e 100644 --- a/lib/msf/ui/console/command_dispatcher/auxiliary.rb +++ b/lib/msf/ui/console/command_dispatcher/auxiliary.rb @@ -96,9 +96,10 @@ class Auxiliary } # Always run passive modules in the background - if (mod.passive || mod.passive_action?(action || mod.default_action)) + if mod.is_a?(Msf::Module::HasActions) && + (mod.passive || mod.passive_action?(action || mod.default_action)) jobify = true - end if mod.is_a?(Msf::Module::HasActions) + end begin mod.run_simple(