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.
4.x
asoto-r7 2018-10-22 15:50:41 -05:00 committed by Metasploit
parent e6b2ddbc02
commit 2a0deefddd
No known key found for this signature in database
GPG Key ID: CDFB5FA52007B954
1 changed files with 15 additions and 4 deletions

View File

@ -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