391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
char ch;
back->special(TS_EOF);
ssh_scp_recv(&ch, 1);
}
exit(1);
}
static int get_password(const char *prompt, char *str, int maxlen)
{
HANDLE hin, hout;
DWORD savemode, i;
if (password) {
static int tried_once = 0;
if (tried_once) {
return 0;
} else {
strncpy(str, password, maxlen);
str[maxlen-1] = '\0';
|
|
|
|
|
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
char ch;
back->special(TS_EOF);
ssh_scp_recv(&ch, 1);
}
exit(1);
}
static int get_line(const char *prompt, char *str, int maxlen, int is_pw)
{
HANDLE hin, hout;
DWORD savemode, newmode, i;
if (is_pw && password) {
static int tried_once = 0;
if (tried_once) {
return 0;
} else {
strncpy(str, password, maxlen);
str[maxlen-1] = '\0';
|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
|
} else {
hin = GetStdHandle(STD_INPUT_HANDLE);
hout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE)
bump("Cannot get standard input/output handles");
GetConsoleMode(hin, &savemode);
SetConsoleMode(hin, (savemode & (~ENABLE_ECHO_INPUT)) |
ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT);
WriteFile(hout, prompt, strlen(prompt), &i, NULL);
ReadFile(hin, str, maxlen-1, &i, NULL);
SetConsoleMode(hin, savemode);
if ((int)i > maxlen) i = maxlen-1; else i = i - 2;
str[i] = '\0';
WriteFile(hout, "\r\n", 2, &i, NULL);
}
return 1;
}
/*
* Open an SSH connection to user@host and execute cmd.
|
<
|
>
>
>
>
>
>
|
|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
|
} else {
hin = GetStdHandle(STD_INPUT_HANDLE);
hout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE)
bump("Cannot get standard input/output handles");
GetConsoleMode(hin, &savemode);
newmode = savemode | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT;
if (is_pw)
newmode &= ~ENABLE_ECHO_INPUT;
else
newmode |= ENABLE_ECHO_INPUT;
SetConsoleMode(hin, newmode);
WriteFile(hout, prompt, strlen(prompt), &i, NULL);
ReadFile(hin, str, maxlen-1, &i, NULL);
SetConsoleMode(hin, savemode);
if ((int)i > maxlen) i = maxlen-1; else i = i - 2;
str[i] = '\0';
if (is_pw)
WriteFile(hout, "\r\n", 2, &i, NULL);
}
return 1;
}
/*
* Open an SSH connection to user@host and execute cmd.
|
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
|
{
int i;
int list = 0;
default_protocol = PROT_TELNET;
flags = FLAG_STDERR;
ssh_get_password = &get_password;
init_winsock();
sk_init();
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-')
break;
if (strcmp(argv[i], "-v") == 0)
|
|
|
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
|
{
int i;
int list = 0;
default_protocol = PROT_TELNET;
flags = FLAG_STDERR;
ssh_get_line = &get_line;
init_winsock();
sk_init();
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-')
break;
if (strcmp(argv[i], "-v") == 0)
|