From 9c645a210f587ea98134e297c1436a673ccb254d Mon Sep 17 00:00:00 2001 From: quamrulmina Date: Fri, 6 Nov 2015 17:13:57 -0600 Subject: [PATCH] Block arrow keys in sshd server so that it is not passed to shell/cmd or echoed For now we avoid sending the 4 arrow keys to the shell or echo it to the remote side. as cmd.exe or powershell does not process it correctly in stream output device mode we run win32 sshd server. --- channels.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/channels.c b/channels.c index 03a6c9d..b2556e3 100644 --- a/channels.c +++ b/channels.c @@ -2480,8 +2480,15 @@ channel_input_data(int type, u_int32_t seq, void *ctxt) } } else { + // avoid sending the 4 arrow keys out to remote for now "ESC[A" .. + if ( (c->isatty) && (data_len ==3) && (data[0] == '\033') && (data[1] == '[')) { + if ( ( data[2] == 'A') || (data[2] == 'B') || (data[2] == 'C') || (data[2] == 'D')) + packet_check_eom(); + return 0; + } buffer_append(&c->output, data, data_len); // it is the sshd server, so pass it on - if ( c->isatty ) { // we echo the data if it is sshd server and pty interactive mode + if ( c->isatty ) { // we echo the data if it is sshd server and pty interactive mode + if ( (data_len ==1) && (data[0] == '\b') ) { if (charinline >0) { buffer_append(&c->input, "\b \b", 3); // for backspace, we need to send space and another backspace for visual erase