| 2842 |
pvar->ask4passwd = 0; // disabled(default) (2006.9.18 maya) |
pvar->ask4passwd = 0; // disabled(default) (2006.9.18 maya) |
| 2843 |
pvar->userauth_retry_count = 0; |
pvar->userauth_retry_count = 0; |
| 2844 |
pvar->decomp_buffer = NULL; |
pvar->decomp_buffer = NULL; |
| 2845 |
|
pvar->authbanner_buffer = NULL; |
| 2846 |
pvar->ssh2_authlist = NULL; // (2007.4.27 yutaka) |
pvar->ssh2_authlist = NULL; // (2007.4.27 yutaka) |
| 2847 |
pvar->tryed_ssh2_authlist = FALSE; |
pvar->tryed_ssh2_authlist = FALSE; |
| 2848 |
pvar->agentfwd_enable = FALSE; |
pvar->agentfwd_enable = FALSE; |
| 3379 |
pvar->decomp_buffer = NULL; |
pvar->decomp_buffer = NULL; |
| 3380 |
} |
} |
| 3381 |
|
|
| 3382 |
|
if (pvar->authbanner_buffer != NULL) { |
| 3383 |
|
buffer_free(pvar->authbanner_buffer); |
| 3384 |
|
pvar->authbanner_buffer = NULL; |
| 3385 |
|
} |
| 3386 |
|
|
| 3387 |
if (pvar->ssh2_authlist != NULL) { // (2007.4.27 yutaka) |
if (pvar->ssh2_authlist != NULL) { // (2007.4.27 yutaka) |
| 3388 |
free(pvar->ssh2_authlist); |
free(pvar->ssh2_authlist); |
| 3389 |
pvar->ssh2_authlist = NULL; |
pvar->ssh2_authlist = NULL; |
| 6938 |
return TRUE; |
return TRUE; |
| 6939 |
} |
} |
| 6940 |
|
|
| 6941 |
|
void sanitize_str(buffer_t *buff, unsigned char *src, size_t srclen) |
| 6942 |
|
{ |
| 6943 |
|
unsigned char *start = src; |
| 6944 |
|
int cplen = 0; |
| 6945 |
|
unsigned int i; |
| 6946 |
|
|
| 6947 |
|
if (srclen == 0) |
| 6948 |
|
return; |
| 6949 |
|
|
| 6950 |
|
for (i=0; i<srclen; i++) { |
| 6951 |
|
if (src[i] < 0x20) { |
| 6952 |
|
if (cplen > 0) { |
| 6953 |
|
buffer_append(buff, start, cplen); |
| 6954 |
|
} |
| 6955 |
|
|
| 6956 |
|
if (src[i] == '\r') { |
| 6957 |
|
buffer_append(buff, "\r\n", 2); |
| 6958 |
|
|
| 6959 |
|
if (i < srclen - 1 && src[i+1] == '\n') { |
| 6960 |
|
i++; |
| 6961 |
|
} |
| 6962 |
|
} |
| 6963 |
|
else if (src[i] == '\n') { |
| 6964 |
|
buffer_append(buff, "\r\n", 2); |
| 6965 |
|
} |
| 6966 |
|
|
| 6967 |
|
start = src + i + 1; |
| 6968 |
|
cplen = 0; |
| 6969 |
|
} |
| 6970 |
|
else { |
| 6971 |
|
cplen++; |
| 6972 |
|
} |
| 6973 |
|
} |
| 6974 |
|
|
| 6975 |
|
if (cplen > 0) { |
| 6976 |
|
buffer_append(buff, start, cplen); |
| 6977 |
|
} |
| 6978 |
|
|
| 6979 |
|
buffer_append(buff, "\0", 1); |
| 6980 |
|
} |
| 6981 |
|
|
| 6982 |
/* |
/* |
| 6983 |
* SSH_MSG_USERAUTH_BANNER: |
* SSH_MSG_USERAUTH_BANNER: |
| 6984 |
* byte SSH_MSG_USERAUTH_BANNER |
* byte SSH_MSG_USERAUTH_BANNER |
| 6989 |
{ |
{ |
| 6990 |
int msglen, ltaglen; |
int msglen, ltaglen; |
| 6991 |
char buff[2048]; |
char buff[2048]; |
| 6992 |
|
char *new_payload_buffer = NULL; |
| 6993 |
|
|
| 6994 |
logputs(LOG_LEVEL_INFO, "SSH2_MSG_USERAUTH_BANNER was received."); |
logputs(LOG_LEVEL_INFO, "SSH2_MSG_USERAUTH_BANNER was received."); |
| 6995 |
|
|
| 6999 |
} |
} |
| 7000 |
|
|
| 7001 |
if (msglen > 0) { |
if (msglen > 0) { |
| 7002 |
|
unsigned char *msg; |
| 7003 |
|
|
| 7004 |
|
if (pvar->authbanner_buffer == NULL) { |
| 7005 |
|
pvar->authbanner_buffer = buffer_init(); |
| 7006 |
|
} |
| 7007 |
|
else { |
| 7008 |
|
buffer_clear(pvar->authbanner_buffer); |
| 7009 |
|
} |
| 7010 |
|
|
| 7011 |
|
if (pvar->authbanner_buffer != NULL) { |
| 7012 |
|
sanitize_str(pvar->authbanner_buffer, buff, MIN(msglen, sizeof(buff))); |
| 7013 |
|
msg = buffer_ptr(pvar->authbanner_buffer); |
| 7014 |
|
msglen = buffer_len(pvar->authbanner_buffer) - 1; // NUL Terminate 分は数えない |
| 7015 |
|
} |
| 7016 |
|
else { |
| 7017 |
|
// メモリ確保失敗時は変換前の文字列を表示する。 |
| 7018 |
|
// ただ、C0 制御文字をそのまま表示しようとするので望ましくないかも。 |
| 7019 |
|
msg = buff; |
| 7020 |
|
} |
| 7021 |
|
|
| 7022 |
switch (pvar->settings.AuthBanner) { |
switch (pvar->settings.AuthBanner) { |
| 7023 |
case 0: |
case 0: |
| 7024 |
break; |
break; |
| 7025 |
case 1: |
case 1: |
| 7026 |
pvar->ssh_state.payload_datastart = 4; |
if (pvar->authbanner_buffer != NULL) { |
| 7027 |
pvar->ssh_state.payload_datalen = msglen; |
new_payload_buffer = msg; |
| 7028 |
|
pvar->ssh_state.payload_datastart = 0; |
| 7029 |
|
pvar->ssh_state.payload_datalen = msglen; |
| 7030 |
|
} |
| 7031 |
|
else { |
| 7032 |
|
pvar->ssh_state.payload_datastart = 4; |
| 7033 |
|
pvar->ssh_state.payload_datalen = msglen; |
| 7034 |
|
} |
| 7035 |
break; |
break; |
| 7036 |
case 2: |
case 2: |
| 7037 |
MessageBox(pvar->cv->HWin, buff, "Authentication Banner", MB_OK | MB_ICONINFORMATION); |
MessageBox(pvar->cv->HWin, msg, "Authentication Banner", MB_OK | MB_ICONINFORMATION); |
| 7038 |
break; |
break; |
| 7039 |
case 3: |
case 3: |
| 7040 |
NotifyInfoMessage(pvar->cv, buff, "Authentication Banner"); |
NotifyInfoMessage(pvar->cv, msg, "Authentication Banner"); |
| 7041 |
break; |
break; |
| 7042 |
} |
} |
| 7043 |
logprintf(LOG_LEVEL_NOTICE, "Banner len: %d, Banner message: %s.", msglen, buff); |
logprintf(LOG_LEVEL_NOTICE, "Banner len: %d, Banner message: %s.", msglen, msg); |
| 7044 |
} |
} |
| 7045 |
else { |
else { |
| 7046 |
logprintf(LOG_LEVEL_VERBOSE, "Empty banner"); |
logprintf(LOG_LEVEL_VERBOSE, "Empty banner"); |
| 7058 |
logprintf(LOG_LEVEL_VERBOSE, "Empty Language Tag"); |
logprintf(LOG_LEVEL_VERBOSE, "Empty Language Tag"); |
| 7059 |
} |
} |
| 7060 |
|
|
| 7061 |
|
if (new_payload_buffer) { |
| 7062 |
|
pvar->ssh_state.payload = new_payload_buffer; |
| 7063 |
|
} |
| 7064 |
|
|
| 7065 |
return TRUE; |
return TRUE; |
| 7066 |
} |
} |
| 7067 |
|
|