73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
char ch;
ssh_scp_send_eof();
ssh_scp_recv(&ch, 1);
}
exit(1);
}
static void get_password(const char *prompt, char *str, int maxlen)
{
HANDLE hin, hout;
DWORD savemode, i;
if (password) {
strncpy(str, password, maxlen);
str[maxlen-1] = '\0';
password = NULL;
return;
}
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);
}
/*
* Open an SSH connection to user@host and execute cmd.
*/
static void do_cmd(char *host, char *user, char *cmd)
{
|
|
>
>
>
>
>
|
|
|
|
>
>
>
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
char ch;
ssh_scp_send_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';
tried_once = 1;
return 1;
}
}
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.
*/
static void do_cmd(char *host, char *user, char *cmd)
{
|