Subversion Repositories Kolibri OS

Rev

Rev 9990 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6419 hidnplayr 1
;    ssh.asm - SSH client for KolibriOS
2
;
9987 hidnplayr 3
;    Copyright (C) 2015-2024 Jeffrey Amelynck
6419 hidnplayr 4
;
5
;    This program is free software: you can redistribute it and/or modify
6
;    it under the terms of the GNU General Public License as published by
7
;    the Free Software Foundation, either version 3 of the License, or
8
;    (at your option) any later version.
9
;
10
;    This program is distributed in the hope that it will be useful,
11
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
;    GNU General Public License for more details.
14
;
15
;    You should have received a copy of the GNU General Public License
16
;    along with this program.  If not, see .
17
 
18
format binary as ""
19
 
9106 hidnplayr 20
__DEBUG__               = 1
21
__DEBUG_LEVEL__         = 2             ; 1: Everything, including sensitive information, 2: Debugging, 3: Errors only
6419 hidnplayr 22
 
9106 hidnplayr 23
BUFFERSIZE              = 64*1024       ; Must be at least 32K according rfc4253#section-6.1
24
PACKETSIZE              = 32*1024       ; Must be at least 32K according rfc4253#section-6.1
25
MAX_BITS                = 8192
6419 hidnplayr 26
 
27
DH_PRIVATE_KEY_SIZE     = 256
9132 hidnplayr 28
MAX_INPUT_LENGTH        = 255
9106 hidnplayr 29
MAX_USERNAME_LENGTH     = 256
30
MAX_PASSWORD_LENGTH     = 256
31
MAX_HOSTNAME_LENGTH     = 4096
32
MAX_PUBLIC_KEY_SIZE     = 4096
6419 hidnplayr 33
 
34
use32
35
 
36
        db      'MENUET01'      ; signature
37
        dd      1               ; header version
38
        dd      start           ; entry point
39
        dd      i_end           ; initialized size
6922 hidnplayr 40
        dd      mem+65536       ; required memory
41
        dd      mem+65536       ; stack pointer
6469 hidnplayr 42
        dd      params          ; parameters
6419 hidnplayr 43
        dd      0               ; path
44
 
45
include '../../macros.inc'
6469 hidnplayr 46
;include '../../struct.inc'
6419 hidnplayr 47
purge mov,add,sub
48
include '../../proc32.inc'
49
include '../../dll.inc'
50
include '../../debug-fdo.inc'
51
include '../../network.inc'
9216 dunkaist 52
include '../../develop/libraries/libcrash/libcrash.inc'
6419 hidnplayr 53
 
54
; macros for network byte order
55
macro dd_n op {
56
   dd 0 or (((op) and 0FF000000h) shr 24) or \
57
           (((op) and 000FF0000h) shr  8) or \
58
           (((op) and 00000FF00h) shl  8) or \
59
           (((op) and 0000000FFh) shl 24)
60
}
61
 
62
macro dw_n op {
63
   dw 0 or (((op) and 0FF00h) shr 8) or \
64
           (((op) and 000FFh) shl 8)
65
}
66
 
9106 hidnplayr 67
macro str string {
68
    local .start, .stop
69
 
70
    dd_n (.stop-.start)
71
 
72
    .start db string
73
    .stop:
74
}
75
 
6469 hidnplayr 76
proc dump_hex _ptr, _length
77
if __DEBUG_LEVEL__ <= 1
78
        pushad
79
 
80
        mov     esi, [_ptr]
81
        mov     ecx, [_length]
82
  .next_dword:
83
        lodsd
84
        bswap   eax
9070 hidnplayr 85
        DEBUGF  1,'%x', eax
6469 hidnplayr 86
        loop    .next_dword
87
        DEBUGF  1,'\n'
88
 
89
        popad
9070 hidnplayr 90
end if
6469 hidnplayr 91
        ret
92
endp
93
 
9106 hidnplayr 94
macro DEBUGM l, s, m {
95
if __DEBUG__
96
        DEBUGF  l, s
97
  if l >=__DEBUG_LEVEL__
98
        stdcall mpint_print, m
99
  end if
100
end if
101
}
6469 hidnplayr 102
 
9106 hidnplayr 103
include 'mpint.inc'
104
include 'seed.inc'
105
include 'random.inc'
6469 hidnplayr 106
 
9106 hidnplayr 107
include 'sshlib.inc'
6469 hidnplayr 108
 
9106 hidnplayr 109
include 'sshlib_mcodes.inc'
110
include 'sshlib_transport.inc'
9987 hidnplayr 111
include 'sshlib_transport_hmac.inc'
9990 hidnplayr 112
include 'sshlib_transport_hmac_etm.inc'
9987 hidnplayr 113
include 'sshlib_transport_polychacha.inc'
9106 hidnplayr 114
include 'sshlib_connection.inc'
115
include 'sshlib_dh_gex.inc'
116
include 'sshlib_host.inc'
117
include 'sshlib_channel.inc'
118
include 'sshlib_userauth.inc'
6469 hidnplayr 119
 
9106 hidnplayr 120
include 'encodings.inc'         ; Unfortunately, we dont have UTF-8 capable console yet :(
9070 hidnplayr 121
 
6419 hidnplayr 122
start:
123
        mcall   68, 11          ; Init heap
124
 
6469 hidnplayr 125
        DEBUGF  2, "SSH: Loading libraries\n"
6419 hidnplayr 126
        stdcall dll.Load, @IMPORT
127
        test    eax, eax
9106 hidnplayr 128
        jnz     main.fail
6419 hidnplayr 129
 
6469 hidnplayr 130
        DEBUGF  2, "SSH: Init PRNG\n"
9071 hidnplayr 131
        call    create_seed
6419 hidnplayr 132
        call    init_random
133
 
6469 hidnplayr 134
        DEBUGF  2, "SSH: Init Console\n"
6419 hidnplayr 135
        invoke  con_start, 1
9112 hidnplayr 136
        invoke  con_init, 80, 25, 80, 250, title
6419 hidnplayr 137
 
9106 hidnplayr 138
        cmp     byte[params], 0
139
        jne     main.connect
6419 hidnplayr 140
 
141
main:
142
        invoke  con_cls
143
; Welcome user
9106 hidnplayr 144
        invoke  con_write_asciiz, str1a
145
  .prompt:
146
        invoke  con_write_asciiz, str1b
147
; Reset window title
148
        invoke  con_set_title, title
149
; Write prompt
6419 hidnplayr 150
        invoke  con_write_asciiz, str2
151
; read string
9106 hidnplayr 152
        mov     esi, params
153
        invoke  con_gets, esi, MAX_HOSTNAME_LENGTH
6419 hidnplayr 154
; check for exit
155
        test    eax, eax
9106 hidnplayr 156
        jz      .done
6419 hidnplayr 157
        cmp     byte[esi], 10
9106 hidnplayr 158
        jz      .done
6419 hidnplayr 159
 
9106 hidnplayr 160
  .connect:
161
        stdcall sshlib_connect, ssh_con, params
162
        cmp     eax, 0
163
        jg      .prompt
164
        jl      .error
6419 hidnplayr 165
 
9106 hidnplayr 166
  .login:
167
        mcall   68, 12, (MAX_USERNAME_LENGTH + MAX_PASSWORD_LENGTH)
6419 hidnplayr 168
        test    eax, eax
9106 hidnplayr 169
        jz      .done   ; ERR_NOMEM
170
        mov     esi, eax
171
        lea     edi, [eax + MAX_USERNAME_LENGTH]
6419 hidnplayr 172
 
9106 hidnplayr 173
; Get username
9070 hidnplayr 174
        invoke  con_write_asciiz, str12
9106 hidnplayr 175
        invoke  con_gets, esi, MAX_USERNAME_LENGTH
9070 hidnplayr 176
        test    eax, eax
9106 hidnplayr 177
;;        jz      .con_closed_must_clear
6469 hidnplayr 178
 
9106 hidnplayr 179
; Get password
180
        invoke  con_write_asciiz, str13a
181
        invoke  con_gets, edi, MAX_PASSWORD_LENGTH
9070 hidnplayr 182
        test    eax, eax
9106 hidnplayr 183
;;        jz      .con_closed_must_clear
184
        invoke  con_write_asciiz, str13b
9070 hidnplayr 185
 
9106 hidnplayr 186
; Authenticate
187
        stdcall sshlib_userauth_password, ssh_con, esi, edi
188
; Clear and free username and password
189
  .clear:
9070 hidnplayr 190
        push    eax
9106 hidnplayr 191
        mov     edx, edi
9070 hidnplayr 192
        xor     eax, eax
9106 hidnplayr 193
        mov     ecx, (MAX_USERNAME_LENGTH + MAX_PASSWORD_LENGTH)/4
194
        rep     stosd
9070 hidnplayr 195
        mcall   68, 13, edx
196
        pop     eax
197
 
9106 hidnplayr 198
        cmp     eax, 0
199
        jg      .login          ; Authentication failed
200
        jl      .error          ; An error occured
6469 hidnplayr 201
 
9106 hidnplayr 202
; Open a channel
203
        stdcall sshlib_chan_open, ssh_con
204
        cmp     eax, 0
205
        jg      .prompt         ; Authentication failed
206
        jl      .error          ; An error occured
9070 hidnplayr 207
 
9106 hidnplayr 208
; Start console input handler thread without deactivating the current window
209
; Get active window ID
6419 hidnplayr 210
        mcall   18, 7
211
        push    eax
9106 hidnplayr 212
; Create thread
9987 hidnplayr 213
        mcall   51, 1, con_in_thread, mem + 2048
9106 hidnplayr 214
; Activate window with given ID
6419 hidnplayr 215
        pop     ecx
216
        mcall   18, 3
217
 
9106 hidnplayr 218
  .loop:
219
        invoke  con_get_flags
220
        test    eax, 0x200                      ; console window closed?
221
        jnz     .con_closed
6419 hidnplayr 222
 
9106 hidnplayr 223
        stdcall sshlib_msg_handler, ssh_con, 0
6469 hidnplayr 224
        cmp     eax, 0
9106 hidnplayr 225
        jle     .check_err
6419 hidnplayr 226
 
9106 hidnplayr 227
        cmp     [ssh_con.rx_buffer.message_code], SSH_MSG_CHANNEL_DATA
6469 hidnplayr 228
        jne     .dump
229
 
9106 hidnplayr 230
        mov     eax, dword[ssh_con.rx_buffer.message_code+5]
6469 hidnplayr 231
        bswap   eax
6419 hidnplayr 232
        DEBUGF  1, 'SSH: got %u bytes of data !\n', eax
233
 
9106 hidnplayr 234
        lea     esi, [ssh_con.rx_buffer.message_code+5+4]
235
        lea     edx, [esi+eax]
236
        lea     edi, [ssh_con.rx_buffer]
237
  @@:
238
        call    get_byte_utf8
239
        stosb
240
        cmp     esi, edx
241
        jb      @r
242
        xor     al, al
243
        stosb
244
 
245
        lea     esi, [ssh_con.rx_buffer]
246
        DEBUGF  3, 'SSH msg: %s\n', esi
247
 
6469 hidnplayr 248
        invoke  con_write_asciiz, esi
9106 hidnplayr 249
        jmp     .loop
6469 hidnplayr 250
 
251
  .dump:
9106 hidnplayr 252
        DEBUGF  3, "SSH: Unsupported message: "
253
        lea     esi, [ssh_con.rx_buffer.message_code]
6469 hidnplayr 254
        mov     ecx, eax
6419 hidnplayr 255
        pusha
9106 hidnplayr 256
  @@:
6419 hidnplayr 257
        lodsb
9106 hidnplayr 258
        DEBUGF  3, "%x ", eax:2
6419 hidnplayr 259
        dec     ecx
260
        jnz     @r
261
        popa
9106 hidnplayr 262
        DEBUGF  3, "\n"
263
        jmp     .loop
6419 hidnplayr 264
 
9106 hidnplayr 265
  .check_err:
266
        jz      .err_conn_closed
267
        cmp     ebx, EWOULDBLOCK
268
        je      .loop
269
        jmp     .err_sock
6469 hidnplayr 270
 
9106 hidnplayr 271
  .con_closed:
272
        ; Send close message on the active channel
273
        stdcall sshlib_send_packet, ssh_con, ssh_msg_channel_close, ssh_msg_channel_close.length, 0
274
        jmp     .done
9070 hidnplayr 275
 
9106 hidnplayr 276
  .error:
277
 
278
; TODO: proper cleanup after error
279
 
280
        cmp     eax, SSHLIB_ERR_NOMEM
281
        je      .done
282
        cmp     eax, SSHLIB_ERR_SOCKET
283
        je      .err_sock
284
        cmp     eax, SSHLIB_ERR_PROTOCOL
285
        je      .err_proto
286
        cmp     eax, SSHLIB_ERR_HOSTNAME
287
        je      .err_hostname
288
        cmp     eax, SSHLIB_ERR_HKEY_VERIFY_FAIL
289
        je      .err_hostkey_fail
290
        cmp     eax, SSHLIB_ERR_HKEY_SIGNATURE
291
        je      .err_hostkey_signature
292
        cmp     eax, SSHLIB_ERR_HKEY_PUBLIC_KEY
293
        je      .err_hostkey
294
 
295
        jmp     .done
296
 
297
 
298
  .err_proto:
299
;        lea     eax, [ssh_con.rx_buffer]
300
;        int3
6419 hidnplayr 301
        invoke  con_write_asciiz, str7
9106 hidnplayr 302
        jmp     .prompt
6419 hidnplayr 303
 
9106 hidnplayr 304
  .err_sock:
6419 hidnplayr 305
        invoke  con_write_asciiz, str6
306
 
9106 hidnplayr 307
        mov     eax, str14
308
        cmp     ebx, ETIMEDOUT
309
        je      .err_sock_detail
310
        mov     eax, str15
311
        cmp     ebx, ECONNREFUSED
312
        je      .err_sock_detail
313
        mov     eax, str16
314
        cmp     ebx, ECONNRESET
315
        je      .err_sock_detail
316
        mov     eax, str17
317
  .err_sock_detail:
318
        invoke  con_write_asciiz, eax
319
        jmp     .prompt
6419 hidnplayr 320
 
9106 hidnplayr 321
  .err_hostname:
6419 hidnplayr 322
        invoke  con_write_asciiz, str10
9106 hidnplayr 323
        jmp     .prompt
6419 hidnplayr 324
 
9106 hidnplayr 325
  .err_conn_closed:
6419 hidnplayr 326
        invoke  con_write_asciiz, str11
9106 hidnplayr 327
        jmp     .prompt
6419 hidnplayr 328
 
9106 hidnplayr 329
  .err_hostkey:
330
        invoke  con_write_asciiz, str19
331
        jmp     .prompt
332
 
333
  .err_hostkey_signature:
334
        invoke  con_write_asciiz, str20
335
        jmp     .prompt
336
 
337
  .err_hostkey_fail:
338
        invoke  con_write_asciiz, str21
339
        jmp     .prompt
340
 
341
  .done:
6419 hidnplayr 342
        invoke  con_exit, 1
9106 hidnplayr 343
  .exit:
6469 hidnplayr 344
        DEBUGF  3, "SSH: Exiting\n"
9106 hidnplayr 345
        mcall   close, [ssh_con.socketnum]
346
  .fail:
6419 hidnplayr 347
        mcall   -1
348
 
349
 
9106 hidnplayr 350
proc sshlib_callback_connecting, con_ptr, connstring_sz
6419 hidnplayr 351
 
9106 hidnplayr 352
        invoke  con_write_asciiz, str3
353
        mov     eax, [con_ptr]
354
        lea     eax, [eax+sshlib_connection.hostname_sz]
355
        invoke  con_write_asciiz, eax
356
        invoke  con_write_asciiz, str8
357
        invoke  con_write_asciiz, [connstring_sz]
358
        invoke  con_write_asciiz, str9
6419 hidnplayr 359
 
9106 hidnplayr 360
        ret
361
endp
9070 hidnplayr 362
 
363
 
9106 hidnplayr 364
proc sshlib_callback_hostkey_problem, con_ptr, problem_type, hostkey_sz
9070 hidnplayr 365
 
9106 hidnplayr 366
        cmp     [problem_type], SSHLIB_HOSTKEY_PROBLEM_UNKNOWN
367
        je      .unknown
368
        cmp     [problem_type], SSHLIB_HOSTKEY_PROBLEM_MISMATCH
369
        je      .mismatch
9070 hidnplayr 370
 
371
        mov     eax, -1
372
        ret
373
 
9106 hidnplayr 374
  .unknown:
375
        invoke  con_write_asciiz, str22
376
        jmp     .ask
9070 hidnplayr 377
 
9106 hidnplayr 378
  .mismatch:
379
        invoke  con_write_asciiz, str23
380
;        jmp     .ask
381
  .ask:
9112 hidnplayr 382
        invoke  con_write_asciiz, str24a
383
        invoke  con_write_asciiz, [hostkey_sz]
384
        invoke  con_write_asciiz, str24b
9106 hidnplayr 385
  .getansw:
386
        invoke  con_getch2
387
        or      al, 0x20        ; convert to lowercase
388
        cmp     al, 'a'
389
        je      .accept
390
        cmp     al, 'c'
391
        je      .once
392
        cmp     al, 'x'
393
        je      .refuse
394
        jmp     .getansw
9070 hidnplayr 395
 
9106 hidnplayr 396
  .accept:
397
        mov     eax, SSHLIB_HOSTKEY_ACCEPT
398
        ret
399
  .once:
400
        mov     eax, SSHLIB_HOSTKEY_ONCE
401
        ret
402
  .refuse:
403
        mov     eax, SSHLIB_HOSTKEY_REFUSE
404
        ret
9070 hidnplayr 405
 
406
endp
407
 
9106 hidnplayr 408
 
409
 
410
align 16
411
con_in_thread:
412
 
413
  .loop:
414
; TODO: check if channel is still open somehow
415
 
9132 hidnplayr 416
        invoke  con_get_input, keyb_input, MAX_INPUT_LENGTH
9106 hidnplayr 417
        test    eax, eax
418
        jz      .no_input
419
 
9132 hidnplayr 420
        mov     ecx, eax
421
        mov     esi, keyb_input
422
        mov     edi, ssh_msg_channel_data.data
423
        call    recode_to_utf8
424
 
425
        lea     eax, [edi - ssh_msg_channel_data.data]
426
        lea     ecx, [edi - ssh_msg_channel_data]
9106 hidnplayr 427
        bswap   eax
428
        mov     [ssh_msg_channel_data.len], eax
429
        stdcall sshlib_send_packet, ssh_con, ssh_msg_channel_data, ecx, 0
430
        cmp     eax, 0
431
        jle     .exit
432
 
433
  .no_input:
434
        invoke  con_get_flags
435
        test    eax, 0x200                      ; con window closed?
436
        jz      .loop
437
 
438
  .exit:
439
        mcall   -1
440
 
441
 
6419 hidnplayr 442
; data
9106 hidnplayr 443
title   db 'Secure Shell',0
444
str1a   db 'SSHv2 client for KolibriOS',10,0
445
str1b   db 10,'Please enter URL of SSH server (hostname:port)',10,0
446
str2    db '> ',0
447
str3    db 'Connecting to ',0
448
str4    db 10,0
449
str6    db 10, 27, '[2J',27,'[mA network error has occured.',10,0
450
str7    db 10, 27, '[2J',27,'[mAn SSH protocol error has occured.',10,0
451
str8    db ' (',0
452
str9    db ')',10,0
453
str10   db 'Host does not exist.',10,10,0
454
str11   db 10, 27, '[2J',27,'[mThe remote host closed the connection.',10,0
455
str12   db 'Login as: ',0
456
str13a  db 'Password: ', 27, '[?25l', 27, '[30;40m', 0
457
str13b  db 10, 27, '[?25h', 27, '[0m', 27, '[2J', 0
458
str14   db 'The connection timed out',10,0
459
str15   db 'The connection was refused',10,0
460
str16   db 'The connection was reset',10,0
461
str17   db 'No details available',10,0
462
;str18   db 'User authentication failed',10,0;;;;
463
str19   db "The remote host's public key is invalid.", 10, 0
464
str20   db "The remote host's signature is invalid.", 10, 0
465
str21   db "The remote host failed to verify it's own public key.", 10, 0
466
str22   db "The host key for the server was not found in the cache.", 10
467
        db "There is no guarantee to the servers identity !",10, 0
6419 hidnplayr 468
 
9106 hidnplayr 469
str23   db "The host key provided by the host does not match the cached one.", 10
470
        db "This may indicate that the remote server has been compromised!", 10, 0
471
 
9112 hidnplayr 472
str24a  db 10, "The remote host key is: ", 10, 0
473
str24b  db 10, 10, "If you trust this host, press A to accept and store the (new) key.", 10
9106 hidnplayr 474
        db "Press C to connect to the host but don't store the (new) key.", 10
475
        db "Press X to abort.", 10, 0
476
 
477
 
6419 hidnplayr 478
ssh_ident_ha:
9106 hidnplayr 479
        dd_n (ssh_msg_ident.length-2)
480
ssh_msg_ident:
9991 hidnplayr 481
        db "SSH-2.0-KolibriOS_SSH_0.12",13,10
9106 hidnplayr 482
  .length = $ - ssh_msg_ident
6419 hidnplayr 483
 
9106 hidnplayr 484
 
485
ssh_msg_kex:
6419 hidnplayr 486
        db SSH_MSG_KEXINIT
487
  .cookie:
488
        rd 4
489
  .kex_algorithms:
9990 hidnplayr 490
        str "diffie-hellman-group-exchange-sha256"
6419 hidnplayr 491
  .server_host_key_algorithms:
9990 hidnplayr 492
        str "rsa-sha2-512,rsa-sha2-256"                                 ;ssh-rsa,ssh-dss
6419 hidnplayr 493
  .encryption_algorithms_client_to_server:
9991 hidnplayr 494
        str "chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc"       ;aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc ?
6419 hidnplayr 495
  .encryption_algorithms_server_to_client:
9991 hidnplayr 496
        str "chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc"       ;aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc ?
6419 hidnplayr 497
  .mac_algorithms_client_to_server:
9991 hidnplayr 498
        str "hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512"
6419 hidnplayr 499
  .mac_algorithms_server_to_client:
9991 hidnplayr 500
        str "hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512"
6419 hidnplayr 501
  .compression_algorithms_client_to_server:
9990 hidnplayr 502
        str "none"                                                      ;zlib ?
6419 hidnplayr 503
  .compression_algorithms_server_to_client:
9990 hidnplayr 504
        str "none"                                                      ;zlib ?
6419 hidnplayr 505
  .languages_client_to_server:
9106 hidnplayr 506
        str ""
6419 hidnplayr 507
  .languages_server_to_client:
9106 hidnplayr 508
        str ""
6419 hidnplayr 509
  .first_kex_packet_follows:
510
        db 0
511
  .reserved:
512
        dd_n 0
9106 hidnplayr 513
  .length = $ - ssh_msg_kex
6419 hidnplayr 514
 
515
 
9106 hidnplayr 516
ssh_msg_gex_req:
6419 hidnplayr 517
        db SSH_MSG_KEX_DH_GEX_REQUEST
9070 hidnplayr 518
        dd_n 4096/4                      ; DH GEX min
519
        dd_n 4096/2                      ; DH GEX number of bits
520
        dd_n 4096                        ; DH GEX Max
9106 hidnplayr 521
  .length = $ - ssh_msg_gex_req
6419 hidnplayr 522
 
523
 
9106 hidnplayr 524
ssh_msg_new_keys:
6419 hidnplayr 525
        db SSH_MSG_NEWKEYS
9106 hidnplayr 526
  .length = $ - ssh_msg_new_keys
6419 hidnplayr 527
 
528
 
9106 hidnplayr 529
ssh_msg_request_service:
6469 hidnplayr 530
        db SSH_MSG_SERVICE_REQUEST
9106 hidnplayr 531
        str "ssh-userauth"              ; Service name
532
  .length = $ - ssh_msg_request_service
6469 hidnplayr 533
 
534
 
9106 hidnplayr 535
ssh_msg_channel_open:
536
        db SSH_MSG_CHANNEL_OPEN
537
        str "session"
538
        dd_n 0                          ; Sender channel
539
        dd_n BUFFERSIZE                 ; Initial window size
540
        dd_n PACKETSIZE                 ; maximum packet size
541
  .length = $ - ssh_msg_channel_open
6469 hidnplayr 542
 
543
 
9106 hidnplayr 544
ssh_msg_channel_close:
545
        db SSH_MSG_CHANNEL_CLOSE
6469 hidnplayr 546
        dd_n 0                          ; Sender channel
9106 hidnplayr 547
  .length = $ - ssh_msg_channel_close
6469 hidnplayr 548
 
9106 hidnplayr 549
 
550
ssh_msg_channel_request:
6469 hidnplayr 551
        db SSH_MSG_CHANNEL_REQUEST
552
        dd_n 0                          ; Recipient channel
9106 hidnplayr 553
        str "pty-req"
6469 hidnplayr 554
        db 1                            ; Bool: want reply
9106 hidnplayr 555
        str "xterm"
6469 hidnplayr 556
        dd_n 80                         ; terminal width (rows)
557
        dd_n 25                         ; terminal height (rows)
9106 hidnplayr 558
        dd_n 80*8                       ; terminal width (pixels)
559
        dd_n 25*16                      ; terminal height (pixels)
6469 hidnplayr 560
 
561
        dd_n 0                          ; list of supported opcodes
9106 hidnplayr 562
  .length = $ - ssh_msg_channel_request
6469 hidnplayr 563
 
9106 hidnplayr 564
 
565
ssh_msg_shell_request:
6469 hidnplayr 566
        db SSH_MSG_CHANNEL_REQUEST
567
        dd_n 0                          ; Recipient channel
9106 hidnplayr 568
        str "shell"
6469 hidnplayr 569
        db 1                            ; Bool: want reply
9106 hidnplayr 570
  .length = $ - ssh_msg_shell_request
6469 hidnplayr 571
 
9106 hidnplayr 572
 
573
ssh_msg_channel_data:
6469 hidnplayr 574
        db SSH_MSG_CHANNEL_DATA
575
        dd_n 0                          ; Sender channel
9106 hidnplayr 576
  .len  dd ?
9132 hidnplayr 577
  .data rb 4*MAX_INPUT_LENGTH + 1
6469 hidnplayr 578
 
579
 
9106 hidnplayr 580
ssh_msg_channel_window_adjust:
581
        db SSH_MSG_CHANNEL_WINDOW_ADJUST
582
        dd_n 0                          ; Sender channel
583
  .wnd  dd ?
584
  .length = $ - ssh_msg_channel_window_adjust
585
 
586
 
6419 hidnplayr 587
include_debug_strings
588
 
589
align 4
590
@IMPORT:
591
 
592
library network, 'network.obj', \
6469 hidnplayr 593
        console, 'console.obj', \
9112 hidnplayr 594
        libcrash, 'libcrash.obj', \
595
        libini, 'libini.obj'
6419 hidnplayr 596
 
597
import  network, \
598
        getaddrinfo, 'getaddrinfo', \
599
        freeaddrinfo, 'freeaddrinfo', \
600
        inet_ntoa, 'inet_ntoa'
601
 
602
import  console, \
603
        con_start, 'START', \
604
        con_init, 'con_init', \
605
        con_write_asciiz, 'con_write_asciiz', \
606
        con_exit, 'con_exit', \
607
        con_gets, 'con_gets', \
608
        con_cls, 'con_cls', \
609
        con_getch2, 'con_getch2', \
9106 hidnplayr 610
        con_get_flags, 'con_get_flags', \
611
        con_set_title, 'con_set_title', \
612
        con_get_input, 'con_get_input'
6419 hidnplayr 613
 
6469 hidnplayr 614
import  libcrash, \
9990 hidnplayr 615
        crash.init, "lib_init", \
616
        crash.hash, "crash_hash", \
617
        crash.mac, "crash_mac", \
618
        crash.crypt, "crash_crypt", \
619
        crash.hash_oneshot, "crash_hash_oneshot", \
620
        crash.mac_oneshot, "crash_mac_oneshot", \
621
        crash.crypt_oneshot, "crash_crypt_oneshot", \
622
        \
623
        crc32.init, "crc32_init", \
624
        crc32.update, "crc32_update", \
625
        crc32.finish, "crc32_finish", \
626
        crc32.oneshot, "crc32_oneshot", \
627
        md5.init, "md5_init", \
628
        md5.update, "md5_update", \
629
        md5.finish, "md5_finish", \
630
        md5.oneshot, "md5_oneshot", \
631
        sha1.init, "sha1_init", \
632
        sha1.update, "sha1_update", \
633
        sha1.finish, "sha1_finish", \
634
        sha1.oneshot, "sha1_oneshot", \
635
        sha2_224.init, "sha2_224_init", \
636
        sha2_224.update, "sha2_224_update", \
637
        sha2_224.finish, "sha2_224_finish", \
638
        sha2_224.oneshot, "sha2_224_oneshot", \
639
        sha2_256.init, "sha2_256_init", \
640
        sha2_256.update, "sha2_256_update", \
641
        sha2_256.finish, "sha2_256_finish", \
642
        sha2_256.oneshot, "sha2_256_oneshot", \
643
        sha2_384.init, "sha2_384_init", \
644
        sha2_384.update, "sha2_384_update", \
645
        sha2_384.finish, "sha2_384_finish", \
646
        sha2_384.oneshot, "sha2_384_oneshot", \
647
        sha2_512.init, "sha2_512_init", \
648
        sha2_512.update, "sha2_512_update", \
649
        sha2_512.finish, "sha2_512_finish", \
650
        sha2_512.oneshot, "sha2_512_oneshot", \
651
        sha3_224.init, "sha3_224_init", \
652
        sha3_224.update, "sha3_224_update", \
653
        sha3_224.finish, "sha3_224_finish", \
654
        sha3_224.oneshot, "sha3_224_oneshot", \
655
        sha3_256.init, "sha3_256_init", \
656
        sha3_256.update, "sha3_256_update", \
657
        sha3_256.finish, "sha3_256_finish", \
658
        sha3_256.oneshot, "sha3_256_oneshot", \
659
        sha3_384.init, "sha3_384_init", \
660
        sha3_384.update, "sha3_384_update", \
661
        sha3_384.finish, "sha3_384_finish", \
662
        sha3_384.oneshot, "sha3_384_oneshot", \
663
        sha3_512.init, "sha3_512_init", \
664
        sha3_512.update, "sha3_512_update", \
665
        sha3_512.finish, "sha3_512_finish", \
666
        sha3_512.oneshot, "sha3_512_oneshot", \
667
        \
668
        poly1305.init, "poly1305_init", \
669
        poly1305.update, "poly1305_update", \
670
        poly1305.finish, "poly1305_finish", \
671
        poly1305.oneshot, "poly1305_oneshot", \
672
        hmac_sha2_256.init, "hmac_sha2_256_init", \
673
        hmac_sha2_256.update, "hmac_sha2_256_update", \
674
        hmac_sha2_256.finish, "hmac_sha2_256_finish", \
675
        hmac_sha2_256.oneshot, "hmac_sha2_256_oneshot", \
676
        hmac_sha2_512.init, "hmac_sha2_512_init", \
677
        hmac_sha2_512.update, "hmac_sha2_512_update", \
678
        hmac_sha2_512.finish, "hmac_sha2_512_finish", \
679
        hmac_sha2_512.oneshot, "hmac_sha2_512_oneshot", \
680
        \
681
        chacha20.init, "chacha20_init", \
682
        chacha20.update, "chacha20_update", \
683
        chacha20.finish, "chacha20_finish", \
684
        chacha20.oneshot, "chacha20_oneshot", \
9987 hidnplayr 685
        aes256ctr.init, "aes256ctr_init", \
686
        aes256ctr.update, "aes256ctr_update", \
687
        aes256ctr.finish, "aes256ctr_finish", \
688
        aes256ctr.oneshot, "aes256ctr_oneshot", \
9990 hidnplayr 689
        aes256cbc.init, "aes256cbc_init", \
690
        aes256cbc.update, "aes256cbc_update", \
691
        aes256cbc.finish, "aes256cbc_finish", \
692
        aes256cbc.oneshot, "aes256cbc_oneshot"
6419 hidnplayr 693
 
9112 hidnplayr 694
import  libini, \
695
        ini_get_str, 'ini_get_str', \
696
        ini_set_str, 'ini_set_str'
697
 
6419 hidnplayr 698
IncludeIGlobals
699
 
700
i_end:
701
 
702
IncludeUGlobals
703
 
9987 hidnplayr 704
align 16
9106 hidnplayr 705
params          rb MAX_HOSTNAME_LENGTH
6419 hidnplayr 706
 
9987 hidnplayr 707
align 16
9106 hidnplayr 708
ssh_con         sshlib_connection
9987 hidnplayr 709
 
710
align 16
9106 hidnplayr 711
ssh_chan        sshlib_channel
6419 hidnplayr 712
 
9132 hidnplayr 713
keyb_input      rb MAX_INPUT_LENGTH
714
 
6419 hidnplayr 715
mem: