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 if !intent
# TODO: Check the shell is interactive or not # TODO: Check the shell is interactive or not
# If the current shell is not interactive, the ASCII Control Character will not work # If the current shell is not interactive, the ASCII Control Character will not work
if !(self.platform=="windows" && self.type =="shell")
print_status("Aborting foreground process in the shell session")
self.rstream.write("\u0003") self.rstream.write("\u0003")
end
return return
end end
rescue Interrupt rescue Interrupt
@ -139,9 +142,17 @@ protected
# #
def _suspend def _suspend
# Ask the user if they would like to background the session # Ask the user if they would like to background the session
if (prompt_yesno("Background session #{name}?") == true) intent = prompt_yesno("Background session #{name}?")
self.interacting = false 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 end
return
end
self.interacting = false
end end
# #
@ -156,7 +167,7 @@ protected
# Checks to see if the user wants to abort. # Checks to see if the user wants to abort.
# #
def user_want_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
end end