diff --git a/.ccls b/.ccls new file mode 100644 index 0000000..57e04ba --- /dev/null +++ b/.ccls @@ -0,0 +1,33 @@ +clang +%c -std=c11 +-D__WINE__ +-DMOD_PERSO +-DMOD_STARTBUTTON +-DMOD_SAVEDUMP +-DMOD_DISABLEALTGR +-DMOD_KEYMAPPING +-DMOD_PUTTYX +-DMOD_PORTKNOCKING +-DMOD_HYPERLINK +-DMOD_PRINTCLIP +-DMOD_LAUNCHER +-DMOD_RECONNECT +-DMOD_WTS +-DMOD_TUTTY +-DMOD_RUTTY +-DMOD_ADB +-DMOD_BACKGROUNDIMAGE +-I0.73_My_PuTTY/ +-I. +-I0.73_My_PuTTY/charset/ +-I0.73_My_PuTTY/windows/ +-I0.73_My_PuTTY/unix/ +-I0.73_My_PuTTY/mac/ +-I0.73_My_PuTTY/macosx/ +-Ibase64/ +-Ibcrypt/ +-Imd5/ +-Iregex/ +-Iurl/ +-Iwincrypt/ +-Irutty/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..057429d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.map +*.exe diff --git a/0.73_My_PuTTY/ssh2connection.c b/0.73_My_PuTTY/ssh2connection.c index f118af5..68ae43b 100644 --- a/0.73_My_PuTTY/ssh2connection.c +++ b/0.73_My_PuTTY/ssh2connection.c @@ -12,6 +12,10 @@ #include "sshcr.h" #include "ssh2connection.h" +#ifdef MOD_RECONNECT +int GetAutoreconnectFlag( void ) ; +#endif + static void ssh2_connection_free(PacketProtocolLayer *); static void ssh2_connection_process_queue(PacketProtocolLayer *); static bool ssh2_connection_get_specials( diff --git a/0.73_My_PuTTY/ssh2userauth.c b/0.73_My_PuTTY/ssh2userauth.c index d216585..3856a42 100644 --- a/0.73_My_PuTTY/ssh2userauth.c +++ b/0.73_My_PuTTY/ssh2userauth.c @@ -865,7 +865,9 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl) continue; /* process this new message */ } ppl_logevent("Offer of public key accepted"); - +#ifdef MOD_RECONNECT + is_backend_first_connected = 0 ; +#endif /* * Actually attempt a serious authentication using * the key. @@ -890,11 +892,13 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl) s->publickey_comment), false); #ifdef MOD_PERSO + //if( GetAutoreconnectFlag() && (strlen(ManagePassPhrase(NULL))>0) ) { if( strlen(ManagePassPhrase(NULL))>0 ) { char *p = ManagePassPhrase(NULL) ; bufchain bc; bufchain_init(&bc); bufchain_add(&bc, p, strlen(p)); + bufchain_add(&bc, "\n", 1); s->userpass_ret = seat_get_userpass_input( s->ppl.seat, s->cur_prompt, &bc ); logevent(NULL,"Test passphrase"); ManagePassPhrase(""); @@ -938,8 +942,12 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl) * Try decrypting the key. */ key = ssh2_load_userkey(s->keyfile, passphrase, &error); + if (passphrase) { /* burn the evidence */ +#ifdef MOD_PERSO + if(strlen(passphrase)>0) { ManagePassPhrase(passphrase); } +#endif smemclr(passphrase, strlen(passphrase)); sfree(passphrase); } @@ -956,6 +964,9 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl) s->suppress_wait_for_response_packet = true; break; /* try something else */ } +#ifdef MOD_PERSO + ManagePassPhrase(""); +#endif } else { /* FIXME: if we ever support variable signature * flags, this is somewhere they'll need to be diff --git a/0.73_My_PuTTY/terminal.c b/0.73_My_PuTTY/terminal.c index f3c2ad1..21ccc32 100644 --- a/0.73_My_PuTTY/terminal.c +++ b/0.73_My_PuTTY/terminal.c @@ -3338,6 +3338,7 @@ unsigned long term_translate( return c; } +extern int cursor_type; /* * Remove everything currently in `inbuf' and stick it up on the * in-memory display. There's a big state machine in here to @@ -3887,6 +3888,18 @@ static void term_out(Terminal *term) if (term->esc_nargs < ARGS_MAX) term->esc_args[term->esc_nargs++] = ARG_DEFAULT; term->termstate = SEEN_CSI; + } else if (c == 'q') { + // cursor shape type (DECSCUSR) + int cursor_shape = def(term->esc_args[0], 1); + // set cursor_type from shape (cursor_type: 0=block, 1=underline, 2=beam) + cursor_type = (cursor_shape - 1) >> 1; + // set term->blink_cur from shape (odd numbers indicate blinking in DECSCUSR) + if (term->blink_cur != cursor_shape & 1) + { + term->blink_cur = cursor_shape & 1; + term_reset_cblink(term); + } + term->termstate = TOPLEVEL; } else if (c < '@') { if (term->esc_query) term->esc_query = -1; @@ -4244,7 +4257,7 @@ static void term_out(Terminal *term) compatibility2(OTHER, VT220); term->curr_attr &= ~(ATTR_BOLD | ATTR_DIM); break; -#ifdef PERSPORT +#ifdef MOD_PERSO case 23: /* disable italics */ compatibility(ANSI); term->curr_attr &= ~ATTR_ITALIC; diff --git a/0.73_My_PuTTY/version.h b/0.73_My_PuTTY/version.h index f43c811..d10da57 100644 --- a/0.73_My_PuTTY/version.h +++ b/0.73_My_PuTTY/version.h @@ -1,5 +1,5 @@ #define RELEASE 0.73 #define TEXTVER "Release 0.73" #define SSHVER "-Release-0.73" -#define BINARY_VERSION 0,73,2,4 +#define BINARY_VERSION 0,73,2,5 #define SOURCE_COMMIT "unavailable" diff --git a/0.73_My_PuTTY/windows/MAKEFILE.MINGW b/0.73_My_PuTTY/windows/MAKEFILE.MINGW index 5ad35bf..80208bd 100644 --- a/0.73_My_PuTTY/windows/MAKEFILE.MINGW +++ b/0.73_My_PuTTY/windows/MAKEFILE.MINGW @@ -848,7 +848,7 @@ putty.res.o: ../windows/putty.rc ../windows/rcstuff.h ../windows/winhelp.rc2 \ ../windows/win_res.h ../windows/putty.ico \ ../windows/puttycfg.ico ../windows/version.rc2 ../version.h \ ../licence.h \ - ../../blocnote/notepad.rc + ../../blocnote/notepad.rc ../windows/kitty.mft $(RC) $(RCFL) $(RCFLAGS) ../windows/putty.rc -o putty.res.o -DMOD_INTEGRATED_AGENT -DMOD_INTEGRATED_KEYGEN puttygen.res.o: ../windows/puttygen.rc ../windows/rcstuff.h \ @@ -2132,7 +2132,7 @@ cross: make -e TOOLPATH=/usr/bin/i686-w64-mingw32- -f MAKEFILE.MINGW putty.exe plink.exe pscp.exe psftp.exe pageant.exe puttygen.exe make -e TOOLPATH=/usr/bin/i686-w64-mingw32- -f MAKEFILE.MINGW portable cp putty.exe putty_nocompress.exe - upx --best --compress-icons=2 --compress-exports=0 putty.exe putty_portable.exe putty_nocompress.exe + upx --best --compress-icons=2 --compress-exports=0 putty.exe putty_portable.exe mv putty.exe /builds/kitty.exe mv putty_portable.exe /builds/kitty_portable.exe mv putty_nocompress.exe /builds/kitty_nocompress.exe diff --git a/0.73_My_PuTTY/windows/kitty.mft b/0.73_My_PuTTY/windows/kitty.mft new file mode 100644 index 0000000..0a19b87 --- /dev/null +++ b/0.73_My_PuTTY/windows/kitty.mft @@ -0,0 +1,45 @@ + + + + + A network client and terminal emulator + + + + + + + + + + + + + + + + + + + + + + + + true + + + diff --git a/0.73_My_PuTTY/windows/putty.rc b/0.73_My_PuTTY/windows/putty.rc index fd58517..d95ab8d 100644 --- a/0.73_My_PuTTY/windows/putty.rc +++ b/0.73_My_PuTTY/windows/putty.rc @@ -6,6 +6,12 @@ #include "winhelp.rc2" #include "win_res.rc2" +#ifdef MOD_PERSO +#ifndef NO_MANIFESTS +1 RT_MANIFEST "kitty.mft" +#endif /* NO_MANIFESTS */ +#else #ifndef NO_MANIFESTS 1 RT_MANIFEST "putty.mft" #endif /* NO_MANIFESTS */ +#endif diff --git a/0.73_My_PuTTY/windows/version_minor.txt b/0.73_My_PuTTY/windows/version_minor.txt index b8626c4..7ed6ff8 100644 --- a/0.73_My_PuTTY/windows/version_minor.txt +++ b/0.73_My_PuTTY/windows/version_minor.txt @@ -1 +1 @@ -4 +5 diff --git a/0.73_My_PuTTY/windows/window.c b/0.73_My_PuTTY/windows/window.c index f5008eb..7c7868f 100644 --- a/0.73_My_PuTTY/windows/window.c +++ b/0.73_My_PuTTY/windows/window.c @@ -539,13 +539,17 @@ static void start_backend(void) conf_get_bool(conf, CONF_tcp_nodelay), conf_get_bool(conf, CONF_tcp_keepalives)); if (error) { +#ifdef MOD_RECONNECT char *str = dupprintf("%s Error", appname); char *msg = dupprintf("Unable to open connection to\n%s\n%s", conf_dest(conf), error); - MessageBox(NULL, msg, str, MB_ICONERROR | MB_OK); + if( GetAutoreconnectFlag() && conf_get_int(conf,CONF_failure_reconnect) && is_backend_first_connected ) { + lp_eventlog(default_logpolicy, msg) ; + } else { + MessageBox(NULL, msg, str, MB_ICONERROR | MB_OK); + } sfree(str); sfree(msg); -#ifdef MOD_RECONNECT if( GetAutoreconnectFlag() && conf_get_int(conf,CONF_failure_reconnect) && is_backend_first_connected ) { SetConnBreakIcon() ; SetSSHConnected(0) ; @@ -556,6 +560,13 @@ static void start_backend(void) return ; } else +#else + char *str = dupprintf("%s Error", appname); + char *msg = dupprintf("Unable to open connection to\n%s\n%s", + conf_dest(conf), error); + MessageBox(NULL, msg, str, MB_ICONERROR | MB_OK); + sfree(str); + sfree(msg); #endif exit(0); } @@ -644,6 +655,7 @@ static void close_session(void *ignored_context) void RestartSession( void ) { win_seat_connection_fatal( win_seat, "User request session restart..." ) ; PostMessage(hwnd,WM_KEYDOWN,VK_RETURN ,0) ; + is_backend_first_connected = 0 ; PostMessage(hwnd,WM_KEYUP,VK_RETURN ,1) ; } #endif @@ -872,6 +884,9 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) debug_flag = 1 ; } else if( !strcmp(p, "-fullscreen") ) { conf_set_int( conf, CONF_fullscreen, 1 ) ; + } else if( !strcmp(p, "-funky") ) { + i++; + conf_set_int( conf, CONF_funky_type, atoi(argv[1]) ) ; } else if( !strcmp(p, "-initdelay") ) { i++ ; init_delay = (int)(1000*atof( argv[i] )) ; @@ -932,7 +947,13 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) } else if( !strcmp(p, "-notrans") ) { SetTransparencyFlag( 0 ) ; conf_set_int(conf,CONF_transparencynumber, -1) ; -#ifdef MOD_SAVEDUMP +#ifdef MOD_RECONNECT + } else if( !strcmp(p, "-autorecnt") ) { + SetAutoreconnectFlag(1) ; + conf_set_int(conf,CONF_wakeup_reconnect, 1) ; + conf_set_int(conf,CONF_failure_reconnect, 1) ; +#endif +#ifdef MOD_SAVEDUMP } else if( !strcmp(p, "-savedump") ) { SaveDump() ; return 0; @@ -6571,7 +6592,6 @@ if( !get_param("PUTTY") && conf_get_int(conf, CONF_disablealtgr) ) { default: break; } - if (!(term->funky_type == FUNKY_XTERM && !term->vt52_mode) || fkey == 0) { *p++ = '\033'; } @@ -6595,7 +6615,6 @@ if( !get_param("PUTTY") && conf_get_int(conf, CONF_disablealtgr) ) { SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, 0); return 0; } - if (wParam == VK_PRIOR && shift_state == 2) { SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0); return 0; @@ -6683,12 +6702,20 @@ if( !get_param("PUTTY") && conf_get_int(conf, CONF_disablealtgr) ) { return 0; } - if (wParam == VK_BACK && shift_state <= 1) { /* Backspace of Shift Backspace */ +#ifdef MOD_KEYMAPPING + if (wParam == VK_BACK && shift_state <= 1) { /* Backspace or Shift Backspace */ +#else + if (wParam == VK_BACK && shift_state == 0) { /* Backspace */ +#endif *p++ = (conf_get_bool(conf, CONF_bksp_is_delete) ? 0x7F : 0x08); *p++ = 0; return -2; } +#ifdef MOD_KEYMAPPING if (wParam == VK_BACK) { /* Ctrl Backspace or Ctrl+Shift Backspace */ +#else + if (wParam == VK_BACK && shift_state == 1) { /* Shift Backspace */ +#endif /* We do the opposite of what is configured */ *p++ = (conf_get_bool(conf, CONF_bksp_is_delete) ? 0x08 : 0x7F); *p++ = 0; @@ -6841,7 +6868,12 @@ if( !get_param("PUTTY") && conf_get_int(conf, CONF_disablealtgr) ) { case VK_PRIOR: sk_key = SKK_PGUP; goto small_keypad_key; case VK_NEXT: sk_key = SKK_PGDN; goto small_keypad_key; small_keypad_key: - p += format_small_keypad_key((char *)p, term, sk_key, shift_state, left_alt); +#ifndef MOD_KEYMAPPING + /* These keys don't generate terminal input with Ctrl */ + if (shift_state & 2) + break; +#endif + p += format_small_keypad_key((char *)p, term, sk_key); return p - output; char xkey; @@ -7108,7 +7140,7 @@ static void wintw_set_title(TermWin *tw, const char *title_in) { if( (title[0]=='_')&&(title[1]=='_') ) { // Mode commande a distance if( ManageLocalCmd( MainHwnd, title+2 ) ) { free(title); return ; } - } + } if( !GetTitleBarFlag() ) { set_title_internal( tw, title ) ; free(title) ; return ; } diff --git a/kitty.c b/kitty.c index df8ba70..52d83fe 100644 --- a/kitty.c +++ b/kitty.c @@ -1306,7 +1306,7 @@ void CreateDefaultIniFile( void ) { #endif #endif writeINI( KittyIniFile, INIT_SECTION, "#uploaddir", "." ) ; - writeINI( KittyIniFile, INIT_SECTION, "#UserPassSSHNoSave", "no" ) ; + writeINI( KittyIniFile, INIT_SECTION, "#userpasssshnosave", "no" ) ; writeINI( KittyIniFile, INIT_SECTION, "#WinSCPPath", "" ) ; writeINI( KittyIniFile, INIT_SECTION, "#WinSCPProtocol", "sftp" ) ; #ifdef MOD_ZMODEM diff --git a/kitty_crypt.c b/kitty_crypt.c index ba06166..833fa7e 100644 --- a/kitty_crypt.c +++ b/kitty_crypt.c @@ -57,7 +57,10 @@ static char PassPhrase[256] = "" ; // Procedure de management de la passphrase char * ManagePassPhrase( const char * st ) { - if( st != NULL ) strcpy( PassPhrase, st ) ; + if( !GetUserPassSSHNoSave() && (st != NULL) ) { + strcpy( PassPhrase, st ) ; + } + if( GetUserPassSSHNoSave() ) { return "" ; } return PassPhrase ; } diff --git a/kitty_crypt.h b/kitty_crypt.h index af04a68..c1f8719 100644 --- a/kitty_crypt.h +++ b/kitty_crypt.h @@ -12,6 +12,7 @@ int decryptstring( char * st, const char * key ) ; int GenerePrivateKey( const char * filename ) ; // Procedure de management de la passphrase +int GetUserPassSSHNoSave(void) ; char * ManagePassPhrase( const char * st ) ; #endif diff --git a/kitty_win.c b/kitty_win.c index 7d27ba4..eca7066 100644 --- a/kitty_win.c +++ b/kitty_win.c @@ -9,18 +9,20 @@ void SetTransparency( HWND hwnd, int value ) { // Numéro de version de l'OS -void GetOSInfo( char * version ) { +void GetOSInfo( char * version ) { // ==> Deprecated with version >= Windows 8.1 OSVERSIONINFO osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); sprintf( version, "%ld.%ld %ld %ld %s %dx%d", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber, osvi.dwPlatformId, osvi.szCSDVersion, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) ) ; - } +} /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832%28v=vs.85%29.aspx Operating system Version number Windows 10 Insider Preview 10.0* Windows Server Technical Preview 10.0* +Windows Server 2019 10.0* +Windows Server 2016 10.0* Windows 8.1 6.3* Windows Server 2012 R2 6.3* Windows 8 6.2