Esempio n. 1
0
int console_confirm_weak_crypto_primitive(
    Seat *seat, const char *algtype, const char *algname,
    void (*callback)(void *ctx, int result), void *ctx)
{
    static const char msg[] =
	"The first %s supported by the server is\n"
	"%s, which is below the configured warning threshold.\n"
	"Continue with connection? (y/n) ";

	static const char mbtitle[] = "%s Security Alert";

	int mbret;
	char *message, *title;

	message = dupprintf(msg, algtype, algname);
	title = dupprintf(mbtitle, appname);

	mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING|MB_YESNO);
	sfree(message);
	sfree(title);
	if (mbret == IDYES)
		return 1;
	else
		return 0;
}
Esempio n. 2
0
void console_connection_fatal(Seat *seat, const char *msg)
{
    char morestuff[100];
    sprintf(morestuff, "%.70s Fatal Error", appname);
    MessageBox(GetParentHwnd(), msg, morestuff,
        MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
    cleanup_exit(1);
}
Esempio n. 3
0
BOOL DoLoginDialog(char* password, int maxlen, const char* prompt)
{
   g_hmodThisDll = GetModuleHandle(0);
   g_hwndMain = GetParentHwnd();
   std::string passwordstr;
   BOOL res = LoginDialog::DoLoginDialog(passwordstr, prompt);
   if (res)
      strncpy(password, passwordstr.c_str(), maxlen);
   return res;
}
LRESULT CFuncKeyWnd::OnCommand( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	int		i;
	HWND	hwndCtl;

	hwndCtl = (HWND) lParam;		// handle of control
//	switch( wNotifyCode ){
//	case BN_PUSHED:
		for( i = 0; i < _countof( m_hwndButtonArr ); ++i ){
			if( hwndCtl == m_hwndButtonArr[i] ){
				if( 0 != m_nFuncCodeArr[i] ){
					::SendMessageCmd( GetParentHwnd(), WM_COMMAND, MAKELONG( m_nFuncCodeArr[i], 0 ),  (LPARAM)hwnd );
				}
				break;
			}
		}
		::SetFocus( GetParentHwnd() );
//		break;
//	}
	return 0L;
}
Esempio n. 5
0
void mboxprintf(char *fmt, ...)
{
    va_list ap;
    char *stuff;

    va_start(ap, fmt);
    stuff = dupvprintf(fmt, ap);
    va_end(ap);
    MessageBox(GetParentHwnd(), stuff, "TortoisePlink",
               MB_ICONERROR | MB_OK);
    sfree(stuff);
}
Esempio n. 6
0
void nonfatal(const char *fmt, ...)
{
    va_list ap;
    char *stuff, morestuff[100];
    va_start(ap, fmt);
    stuff = dupvprintf(fmt, ap);
    va_end(ap);
    sprintf(morestuff, "%.70s Error", appname);
    MessageBox(GetParentHwnd(), stuff, morestuff,
        MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
    sfree(stuff);
}
Esempio n. 7
0
void cmdline_error(char *p, ...)
{
	va_list ap;
	char *stuff, morestuff[100];

	va_start(ap, p);
	stuff = dupvprintf(p, ap);
	va_end(ap);
	sprintf(morestuff, "%.70s Command Line Error", appname);
	MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
	sfree(stuff);
    exit(1);
}
Esempio n. 8
0
void fatalbox(char *fmt, ...)
{
    va_list ap;
    char *stuff, morestuff[100];

    va_start(ap, fmt);
    stuff = dupvprintf(fmt, ap);
    va_end(ap);
    sprintf(morestuff, "%.70s Fatal Error", appname);
    MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
    sfree(stuff);
    cleanup_exit(1);
}
Esempio n. 9
0
void connection_fatal(void *frontend, char *p, ...)
{
	va_list ap;
	char *stuff, morestuff[100];

	va_start(ap, p);
	stuff = dupvprintf(p, ap);
	va_end(ap);
	sprintf(morestuff, "%.70s Fatal Error", appname);
	MessageBox(GetParentHwnd(), stuff, morestuff,
		MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
	sfree(stuff);
	cleanup_exit(1);
}
Esempio n. 10
0
void fatalbox(char *p, ...)
{
	va_list ap;
	char *stuff, morestuff[100];

	va_start(ap, p);
	stuff = dupvprintf(p, ap);
	va_end(ap);
	sprintf(morestuff, "%.70s Fatal Error", appname);
	MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
	sfree(stuff);
    if (logctx) {
        log_free(logctx);
        logctx = NULL;
    }
	cleanup_exit(1);
}
Esempio n. 11
0
int console_confirm_weak_cached_hostkey(
    Seat *seat, const char *algname, const char *betteralgs,
    void (*callback)(void *ctx, int result), void *ctx)
{
    HANDLE hin;
    DWORD savemode, i;

    static const char msg[] =
	"The first host key type we have stored for this server\n"
	"is %s, which is below the configured warning threshold.\n"
	"The server also provides the following types of host key\n"
        "above the threshold, which we do not have stored:\n"
        "%s\n"
	"Continue with connection? (y/n) ";
    static const char msg_batch[] =
	"The first host key type we have stored for this server\n"
	"is %s, which is below the configured warning threshold.\n"
	"The server also provides the following types of host key\n"
        "above the threshold, which we do not have stored:\n"
        "%s\n"
	"Connection abandoned.\n";
    static const char abandoned[] = "Connection abandoned.\n";

    char line[32];

    int mbret;
    char *message, *title;
    static const char mbtitle[] = "%s Security Alert";

    message = dupprintf(msg, algname, betteralgs);
    title = dupprintf(mbtitle, appname);

    mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
    sfree(message);
    sfree(title);

    if (mbret == IDYES) {
	return 1;
    } else {
	return 0;
    }
}
Esempio n. 12
0
/*
 * Ask whether to wipe a session log file before writing to it.
 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
 */
static int console_askappend(LogPolicy *lp, Filename *filename,
                             void (*callback)(void *ctx, int result),
                             void *ctx)
{
    HANDLE hin;
    DWORD savemode, i;

    static const char msgtemplate[] =
	"The session log file \"%.*s\" already exists.\n"
	"You can overwrite it with a new session log,\n"
	"append your session log to the end of it,\n"
	"or disable session logging for this session.\n"
	"Enter \"y\" to wipe the file, \"n\" to append to it,\n"
	"or just press Return to disable logging.\n"
	"Wipe the log file? (y/n, Return cancels logging) ";

    static const char msgtemplate_batch[] =
	"The session log file \"%.*s\" already exists.\n"
	"Logging will not be enabled.\n";

    char line[32];
    int mbret;
    char *message, *title;
    static const char mbtitle[] = "%s Session log";

    message = dupprintf(msgtemplate, FILENAME_MAX, filename->path);
    title = dupprintf(mbtitle, appname);

    mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
    sfree(message);
    sfree(title);

    if (mbret == IDYES)
	return 2;
    else if (mbret == IDNO)
	return 1;
    else
	return 0;
}
Esempio n. 13
0
int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
                        char *keystr, char *fingerprint,
                        void (*callback)(void *ctx, int result), void *ctx)
{
    int ret;

    static const char absentmsg_batch[] =
    "The server's host key is not cached in the registry. You\n"
    "have no guarantee that the server is the computer you\n"
    "think it is.\n"
    "The server's %s key fingerprint is:\n"
    "%s\n"
    "Connection abandoned.\n";
    static const char absentmsg[] =
    "The server's host key is not cached in the registry. You\n"
    "have no guarantee that the server is the computer you\n"
    "think it is.\n"
    "The server's %s key fingerprint is:\n"
    "%s\n"
    "If you trust this host, hit Yes to add the key to\n"
    "%s's cache and carry on connecting.\n"
    "If you want to carry on connecting just once, without\n"
    "adding the key to the cache, hit No.\n"
    "If you do not trust this host, hit Cancel to abandon the\n"
    "connection.\n";

    static const char wrongmsg_batch[] =
    "WARNING - POTENTIAL SECURITY BREACH!\n"
    "The server's host key does not match the one PuTTY has\n"
    "cached in the registry. This means that either the\n"
    "server administrator has changed the host key, or you\n"
    "have actually connected to another computer pretending\n"
    "to be the server.\n"
    "The new %s key fingerprint is:\n"
    "%s\n"
    "Connection abandoned.\n";
    static const char wrongmsg[] =
    "WARNING - POTENTIAL SECURITY BREACH!\n"
    "\n"
    "The server's host key does not match the one %s has\n"
    "cached in the registry. This means that either the\n"
    "server administrator has changed the host key, or you\n"
    "have actually connected to another computer pretending\n"
    "to be the server.\n"
    "The new %s key fingerprint is:\n"
    "%s\n"
    "If you were expecting this change and trust the new key,\n"
    "hit Yes to update %s's cache and continue connecting.\n"
    "If you want to carry on connecting but without updating\n"
    "the cache, hit No.\n"
    "If you want to abandon the connection completely, hit\n"
    "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";

    static const char abandoned[] = "Connection abandoned.\n";

    static const char mbtitle[] = "%s Security Alert";

    int mbret;
    char *message, *title;
    

    /*
     * Verify the key against the registry.
     */
    ret = verify_host_key(host, port, keytype, keystr);

    if (ret == 0)              /* success - key matched OK */
    return 1;

    if (ret == 2) {            /* key was different */
        if (console_batch_mode) {
            fprintf(stderr, wrongmsg_batch, keytype, fingerprint);
            return 0;
        }
        message = dupprintf(wrongmsg, appname, keytype, fingerprint, appname);
    }
    else if (ret == 1) {            /* key was absent */
        if (console_batch_mode) {
            fprintf(stderr, absentmsg_batch, keytype, fingerprint);
            return 0;
        }
        message = dupprintf(absentmsg, keytype, fingerprint, appname);
    }
    title = dupprintf(mbtitle, appname);
    mbret = MessageBox(GetParentHwnd(), message, title,
                       MB_ICONWARNING | MB_YESNOCANCEL);
    sfree(message);
    sfree(title);
    if (mbret == IDYES) {
        store_host_key(host, port, keytype, keystr);
        return 1;
    }
    if (mbret == IDCANCEL)
        cleanup_exit(0);
    return 1;
}
// WM_TIMERタイマーの処理
LRESULT CFuncKeyWnd::OnTimer( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
// 	HWND hwnd,	// handle of window for timer messages
//	UINT uMsg,	// WM_TIMER message
//	UINT idEvent,	// timer identifier
//	DWORD dwTime 	// current system time


	//	return;
	if( NULL == GetHwnd() ){
		return 0;
	}

	if( ::GetActiveWindow() != GetParentHwnd() && m_nCurrentKeyState != -1 ) {	//	2002/06/02 MIK	// 2006.12.20 ryoji 初回更新は処理する
		return 0;
	}

	int			nIdx;
//	int			nFuncId;
	int			i;

// novice 2004/10/10
	/* Shift,Ctrl,Altキーが押されていたか */
	nIdx = getCtrlKeyState();
	/* ALT,Shift,Ctrlキーの状態が変化したか */
	if( nIdx != m_nCurrentKeyState ){
		m_nTimerCount = TIMER_CHECKFUNCENABLE + 1;

		/* ファンクションキーの機能名を取得 */
		for( i = 0; i < _countof( m_szFuncNameArr ); ++i ){
			// 2007.02.22 ryoji CKeyBind::GetFuncCode()を使う
			EFunctionCode	nFuncCode = CKeyBind::GetFuncCode(
					(WORD)(((VK_F1 + i) | ((WORD)((BYTE)(nIdx))) << 8)),
					m_pShareData->m_Common.m_sKeyBind.m_nKeyNameArrNum,
					m_pShareData->m_Common.m_sKeyBind.m_pKeyNameArr
			);
			if( nFuncCode != m_nFuncCodeArr[i] ){
				m_nFuncCodeArr[i] = nFuncCode;
				if( 0 == m_nFuncCodeArr[i] ){
					m_szFuncNameArr[i][0] = LTEXT('\0');
				}else{
					//	Oct. 2, 2001 genta
					m_pcEditDoc->m_cFuncLookup.Funccode2Name(
						m_nFuncCodeArr[i],
						m_szFuncNameArr[i],
						_countof(m_szFuncNameArr[i]) - 1
					);
				}
				Wnd_SetText( m_hwndButtonArr[i], m_szFuncNameArr[i] );
			}
		}
	}
	m_nTimerCount += TIMER_TIMEOUT;
	if( m_nTimerCount > TIMER_CHECKFUNCENABLE ||
		nIdx != m_nCurrentKeyState
	){
		m_nTimerCount = 0;
		/* 機能が利用可能か調べる */
		for( i = 0; i < _countof(	m_szFuncNameArr ); ++i ){
			if( IsFuncEnable( (CEditDoc*)m_pcEditDoc, m_pShareData, m_nFuncCodeArr[i]  ) ){
				::EnableWindow( m_hwndButtonArr[i], TRUE );
			}else{
				::EnableWindow( m_hwndButtonArr[i], FALSE );
			}
		}
	}
	m_nCurrentKeyState = nIdx;
	return 0;
}
Esempio n. 15
0
int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
                        char *keystr, char *fingerprint,
                        void (*callback)(void *ctx, int result), void *ctx)
{
    int ret;

    static const char absentmsg_batch[] =
	"The server's host key is not cached in the registry. You\n"
	"have no guarantee that the server is the computer you\n"
	"think it is.\n"
	"The server's %s key fingerprint is:\n"
	"%s\n"
	"Connection abandoned.\n";
    static const char absentmsg[] =
	"The server's host key is not cached in the registry. You\n"
	"have no guarantee that the server is the computer you\n"
	"think it is.\n"
	"The server's %s key fingerprint is:\n"
	"%s\n"
	"If you trust this host, enter \"y\" to add the key to\n"
	"PuTTY's cache and carry on connecting.\n"
	"If you want to carry on connecting just once, without\n"
	"adding the key to the cache, enter \"n\".\n"
	"If you do not trust this host, press Return to abandon the\n"
	"connection.\n"
	"Store key in cache? (y/n) ";

    static const char wrongmsg_batch[] =
	"WARNING - POTENTIAL SECURITY BREACH!\n"
	"The server's host key does not match the one PuTTY has\n"
	"cached in the registry. This means that either the\n"
	"server administrator has changed the host key, or you\n"
	"have actually connected to another computer pretending\n"
	"to be the server.\n"
	"The new %s key fingerprint is:\n"
	"%s\n"
	"Connection abandoned.\n";
    static const char wrongmsg[] =
	"WARNING - POTENTIAL SECURITY BREACH!\n"
	"The server's host key does not match the one PuTTY has\n"
	"cached in the registry. This means that either the\n"
	"server administrator has changed the host key, or you\n"
	"have actually connected to another computer pretending\n"
	"to be the server.\n"
	"The new %s key fingerprint is:\n"
	"%s\n"
	"If you were expecting this change and trust the new key,\n"
	"enter \"y\" to update PuTTY's cache and continue connecting.\n"
	"If you want to carry on connecting but without updating\n"
	"the cache, enter \"n\".\n"
	"If you want to abandon the connection completely, press\n"
	"Return to cancel. Pressing Return is the ONLY guaranteed\n"
	"safe choice.\n"
	"Update cached key? (y/n, Return cancels connection) ";

    static const char abandoned[] = "Connection abandoned.\n";

	static const char mbtitle[] = "%s Security Alert";

    /*
     * Verify the key against the registry.
     */
    ret = verify_host_key(host, port, keytype, keystr);

    if (ret == 0)		       /* success - key matched OK */
	return 1;

    if (ret == 2) {		       /* key was different */
	int mbret;
	char *message, *title;

	message = dupprintf(wrongmsg, appname, keytype, fingerprint, appname);
	title = dupprintf(mbtitle, appname);

	mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
	sfree(message);
	sfree(title);
	if (mbret == IDYES) {
		store_host_key(host, port, keytype, keystr);
		return 1;
	}
	else if (mbret == IDNO) 
	{
		return 1;
	}
	else
		return 0;
	}

    if (ret == 1) {		       /* key was absent */
	int mbret;
	char *message, *title;
	message = dupprintf(absentmsg, keytype, fingerprint, appname);
	title = dupprintf(mbtitle, appname);
	mbret = MessageBox(GetParentHwnd(), message, title,
		MB_ICONWARNING | MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
	sfree(message);
	sfree(title);
	if (mbret == IDYES)
	{
		store_host_key(host, port, keytype, keystr);
		return 1;
	}
	else if (mbret == IDNO)
	{
		return 1;
	}
	else
		return 0;
    }
	return 1;
}