kolibrios-fun/programs/network/ssh/sshlib_channel.inc
hidnplayr c60d5b31c6 -Added Poly1305-Chacha20 cipher (new hardcoded default)
-Use HMAC and CTR/CBC from libcrash instead of our own implementations
-Fixed stack allocation for keystroke handler thread

git-svn-id: svn://kolibrios.org@9987 a494cfbc-eb01-0410-851d-a64ba20cac60
2024-03-06 20:22:01 +00:00

94 lines
2.8 KiB
PHP

; sshlib_channel.inc - SSH channel
;
; Copyright (C) 2016-2024 Jeffrey Amelynck
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
proc sshlib_chan_open con_ptr; Channel struct ptr?!
; >> Open channel
DEBUGF 2, "SSH: Opening channel\n"
mov [ssh_chan.rcv_wnd], BUFFERSIZE
mov [ssh_chan.snd_wnd], 0
stdcall sshlib_send_packet, [con_ptr], ssh_msg_channel_open, ssh_msg_channel_open.length, 0
cmp eax, 0
jl .err
; << Check for channel open confirmation
stdcall sshlib_msg_handler, [con_ptr], 0
cmp eax, 0
jl .err
mov esi, [con_ptr]
cmp [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_OPEN_CONFIRMATION
jne .err_proto
DEBUGF 2, "SSH: Channel opened successfully\n"
; >> Channel request: pty
DEBUGF 2, "SSH: Requesting PTY\n"
stdcall sshlib_send_packet, [con_ptr], ssh_msg_channel_request, ssh_msg_channel_request.length, 0
cmp eax, 0
jl .err
; << Check for channel request confirmation
stdcall sshlib_msg_handler, [con_ptr], 0
cmp eax, 0
jl .err
mov esi, [con_ptr]
cmp [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_SUCCESS
jne .err_proto
DEBUGF 2, "SSH: PTY opened successfully\n"
; >> Channel request: shell
DEBUGF 2, "SSH: Requesting shell\n"
stdcall sshlib_send_packet, [con_ptr], ssh_msg_shell_request, ssh_msg_shell_request.length, 0
cmp eax, 0
jl .err
; << Check for channel request confirmation
; TODO: timeout
.wait_success:
stdcall sshlib_msg_handler, [con_ptr], 0
cmp eax, 0
jl .err
mov esi, [con_ptr]
cmp [esi + sshlib_connection.rx_buffer.message_code], SSH_MSG_CHANNEL_SUCCESS
jne .wait_success
DEBUGF 2, "SSH: Shell opened successfully\n"
xor eax, eax
.err:
ret
.err_proto:
mov eax, SSHLIB_ERR_PROTOCOL
ret
endp