mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-30 22:19:17 +02:00
Land #499, Add support for updating terminal size dynamically
This commit is contained in:
commit
dc14eada5d
python/meterpreter
@ -39,6 +39,12 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
has_termios = False
|
has_termios = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
import fcntl
|
||||||
|
has_fcntl = True
|
||||||
|
except ImportError:
|
||||||
|
has_fcntl = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import _winreg as winreg
|
import _winreg as winreg
|
||||||
has_winreg = True
|
has_winreg = True
|
||||||
@ -610,6 +616,9 @@ TLV_TYPE_REGISTER_SIZE = TLV_META_TYPE_UINT | 2541
|
|||||||
TLV_TYPE_REGISTER_VALUE_32 = TLV_META_TYPE_UINT | 2542
|
TLV_TYPE_REGISTER_VALUE_32 = TLV_META_TYPE_UINT | 2542
|
||||||
TLV_TYPE_REGISTER = TLV_META_TYPE_GROUP | 2550
|
TLV_TYPE_REGISTER = TLV_META_TYPE_GROUP | 2550
|
||||||
|
|
||||||
|
TLV_TYPE_TERMINAL_ROWS = TLV_META_TYPE_UINT | 2600
|
||||||
|
TLV_TYPE_TERMINAL_COLUMNS = TLV_META_TYPE_UINT | 2601
|
||||||
|
|
||||||
##
|
##
|
||||||
# Ui
|
# Ui
|
||||||
##
|
##
|
||||||
@ -1159,7 +1168,6 @@ def stdapi_sys_process_execute(request, response):
|
|||||||
if has_termios:
|
if has_termios:
|
||||||
try:
|
try:
|
||||||
settings = termios.tcgetattr(master)
|
settings = termios.tcgetattr(master)
|
||||||
settings[3] = settings[3] & ~termios.ECHO
|
|
||||||
termios.tcsetattr(master, termios.TCSADRAIN, settings)
|
termios.tcsetattr(master, termios.TCSADRAIN, settings)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -2549,3 +2557,16 @@ def stdapi_ui_get_idle_time(request, response):
|
|||||||
idle_time = (GetTickCount() - info.dwTime) / 1000
|
idle_time = (GetTickCount() - info.dwTime) / 1000
|
||||||
response += tlv_pack(TLV_TYPE_IDLE_TIME, idle_time)
|
response += tlv_pack(TLV_TYPE_IDLE_TIME, idle_time)
|
||||||
return ERROR_SUCCESS, response
|
return ERROR_SUCCESS, response
|
||||||
|
|
||||||
|
@register_function_if(has_termios and has_fcntl)
|
||||||
|
def stdapi_sys_process_set_term_size(request, response):
|
||||||
|
channel_id = packet_get_tlv(request, TLV_TYPE_CHANNEL_ID)['value']
|
||||||
|
rows = packet_get_tlv(request, TLV_TYPE_TERMINAL_ROWS)['value']
|
||||||
|
columns = packet_get_tlv(request, TLV_TYPE_TERMINAL_COLUMNS)['value']
|
||||||
|
if channel_id in meterpreter.interact_channels:
|
||||||
|
proc_h = meterpreter.channels[channel_id].proc_h
|
||||||
|
winsize = struct.pack("HHHH", rows, columns, 0, 0)
|
||||||
|
fcntl.ioctl(proc_h.stdin, termios.TIOCSWINSZ, winsize)
|
||||||
|
else:
|
||||||
|
return ERROR_FAILURE, response
|
||||||
|
return ERROR_SUCCESS, response
|
||||||
|
@ -347,6 +347,8 @@ COMMAND_IDS = (
|
|||||||
(1115, 'stdapi_audio_mic_start'),
|
(1115, 'stdapi_audio_mic_start'),
|
||||||
(1116, 'stdapi_audio_mic_stop'),
|
(1116, 'stdapi_audio_mic_stop'),
|
||||||
(1117, 'stdapi_audio_mic_list'),
|
(1117, 'stdapi_audio_mic_list'),
|
||||||
|
(1118, 'stdapi_sys_process_set_term_size'),
|
||||||
|
|
||||||
)
|
)
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user