Skip to content

Commit

Permalink
Land #10450, Implementation of CTRL+Z in reverse shell session
Browse files Browse the repository at this point in the history
Additionally, a check was added to disable this new functionality on
Windows command shell payloads.
  • Loading branch information
asoto-r7 committed Oct 22, 2018
2 parents e6bbc6d + 03d5754 commit f742d3b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/msf/core/session/interactive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def _interrupt
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
Expand All @@ -139,9 +142,17 @@ def _usr1
#
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

#
Expand All @@ -156,7 +167,7 @@ def _interact_complete
# 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
Expand Down

0 comments on commit f742d3b

Please sign in to comment.