From 2a0deefddd62e152a11b19ead6d80e5003f2e1de Mon Sep 17 00:00:00 2001 From: asoto-r7 Date: Mon, 22 Oct 2018 15:50:41 -0500 Subject: [PATCH] Land #10450, Implementation of CTRL+Z in reverse shell session Additionally, a check was added to disable this new functionality on Windows command shell payloads. --- lib/msf/core/session/interactive.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/msf/core/session/interactive.rb b/lib/msf/core/session/interactive.rb index e46431a4ee..6885b1fa5f 100644 --- a/lib/msf/core/session/interactive.rb +++ b/lib/msf/core/session/interactive.rb @@ -118,7 +118,10 @@ protected if !intent # TODO: Check the shell is interactive or not # If the current shell is not interactive, the ASCII Control Character will not work - self.rstream.write("\u0003") + if !(self.platform=="windows" && self.type =="shell") + print_status("Aborting foreground process in the shell session") + self.rstream.write("\u0003") + end return end rescue Interrupt @@ -139,9 +142,17 @@ protected # def _suspend # Ask the user if they would like to background the session - if (prompt_yesno("Background session #{name}?") == true) - self.interacting = false + intent = prompt_yesno("Background session #{name}?") + if !intent + # User does not want to background the current session + # Assuming the target is *nix, we'll forward CTRL-Z to the foreground process on the target + if !(self.platform=="windows" && self.type =="shell") + print_status("Backgrounding foreground process in the shell session") + self.rstream.write("\u001A") + end + return end + self.interacting = false end # @@ -156,7 +167,7 @@ protected # Checks to see if the user wants to abort. # def user_want_abort? - prompt_yesno("Abort session #{name}? If not, the foreground process in the session will be killed") + prompt_yesno("Abort session #{name}?") end end