Add validation for resizable interactive shells

This commit is contained in:
dwelch-r7 2021-11-18 13:05:01 +00:00
parent 0edfe45003
commit 3b74021e19
2 changed files with 11 additions and 1 deletions

View File

@ -395,7 +395,16 @@ class Console::CommandDispatcher::Stdapi::Sys
# #
def pty_shell(sh_path, raw: false) def pty_shell(sh_path, raw: false)
args = ['-p'] args = ['-p']
if raw
args << '-r' if raw args << '-r' if raw
if client.commands.include?(Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_SET_TERM_SIZE)
print_line("Terminal size will be synced automatically.")
else
print_line("You may want to set the correct terminal size manually.")
print_line("Example: `stty rows {rows} cols {columns}`")
end
end
sh_path = client.fs.file.exist?(sh_path) ? sh_path : '/bin/sh' sh_path = client.fs.file.exist?(sh_path) ? sh_path : '/bin/sh'
# Python Meterpreter calls pty.openpty() - No need for other methods # Python Meterpreter calls pty.openpty() - No need for other methods

View File

@ -111,6 +111,7 @@ module Console::InteractiveChannel
end end
def update_term_size def update_term_size
return unless self.client.commands.include?(Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_SET_TERM_SIZE)
rows, cols = ::IO.console.winsize rows, cols = ::IO.console.winsize
unless rows == self.rows && cols == self.cols unless rows == self.rows && cols == self.cols
set_term_size(rows, cols) set_term_size(rows, cols)