mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
Added a fourth application: plink, a command line connection utility
[originally from svn r575]
This commit is contained in:
parent
263d9e0f09
commit
8394a48620
49
Makefile
49
Makefile
@ -45,17 +45,21 @@ OBJ=obj
|
|||||||
RES=res
|
RES=res
|
||||||
|
|
||||||
##-- objects putty puttytel
|
##-- objects putty puttytel
|
||||||
GOBJS1 = window.$(OBJ) windlg.$(OBJ) terminal.$(OBJ) telnet.$(OBJ) raw.$(OBJ)
|
GOBJS1 = window.$(OBJ) windlg.$(OBJ) terminal.$(OBJ)
|
||||||
GOBJS2 = xlat.$(OBJ) ldisc.$(OBJ) sizetip.$(OBJ)
|
GOBJS2 = xlat.$(OBJ) sizetip.$(OBJ)
|
||||||
##-- objects putty
|
##-- objects putty puttytel plink
|
||||||
|
LOBJS1 = telnet.$(OBJ) raw.$(OBJ) ldisc.$(OBJ)
|
||||||
|
##-- objects putty plink
|
||||||
POBJS = ssh.$(OBJ) be_all.$(OBJ)
|
POBJS = ssh.$(OBJ) be_all.$(OBJ)
|
||||||
##-- objects puttytel
|
##-- objects puttytel
|
||||||
TOBJS = be_nossh.$(OBJ)
|
TOBJS = be_nossh.$(OBJ)
|
||||||
|
##-- objects plink
|
||||||
|
PLOBJS = plink.$(OBJ) windlg.$(OBJ)
|
||||||
##-- objects pscp
|
##-- objects pscp
|
||||||
SOBJS = scp.$(OBJ) windlg.$(OBJ) ssh.$(OBJ) be_none.$(OBJ)
|
SOBJS = scp.$(OBJ) windlg.$(OBJ) ssh.$(OBJ) be_none.$(OBJ)
|
||||||
##-- objects putty puttytel pscp
|
##-- objects putty puttytel pscp plink
|
||||||
MOBJS = misc.$(OBJ) version.$(OBJ)
|
MOBJS = misc.$(OBJ) version.$(OBJ)
|
||||||
##-- objects putty pscp
|
##-- objects putty pscp plink
|
||||||
OBJS1 = sshcrc.$(OBJ) sshdes.$(OBJ) sshmd5.$(OBJ) sshrsa.$(OBJ) sshrand.$(OBJ)
|
OBJS1 = sshcrc.$(OBJ) sshdes.$(OBJ) sshmd5.$(OBJ) sshrsa.$(OBJ) sshrand.$(OBJ)
|
||||||
OBJS2 = sshsha.$(OBJ) sshblowf.$(OBJ) noise.$(OBJ) sshdh.$(OBJ) sshdss.$(OBJ)
|
OBJS2 = sshsha.$(OBJ) sshblowf.$(OBJ) noise.$(OBJ) sshdh.$(OBJ) sshdss.$(OBJ)
|
||||||
OBJS3 = sshbn.$(OBJ) sshpubk.$(OBJ)
|
OBJS3 = sshbn.$(OBJ) sshpubk.$(OBJ)
|
||||||
@ -65,6 +69,8 @@ PRESRC = win_res.$(RES)
|
|||||||
TRESRC = nosshres.$(RES)
|
TRESRC = nosshres.$(RES)
|
||||||
##-- resources pscp
|
##-- resources pscp
|
||||||
SRESRC = scp.$(RES)
|
SRESRC = scp.$(RES)
|
||||||
|
##-- resources plink
|
||||||
|
LRESRC = plink.$(RES)
|
||||||
##--
|
##--
|
||||||
|
|
||||||
##-- gui-apps
|
##-- gui-apps
|
||||||
@ -75,23 +81,29 @@ SRESRC = scp.$(RES)
|
|||||||
##--
|
##--
|
||||||
|
|
||||||
LIBS1 = advapi32.lib user32.lib gdi32.lib
|
LIBS1 = advapi32.lib user32.lib gdi32.lib
|
||||||
LIBS2 = wsock32.lib comctl32.lib comdlg32.lib
|
LIBS2 = comctl32.lib comdlg32.lib
|
||||||
|
SOCK1 = wsock32.lib
|
||||||
|
SOCK2 = ws2_32.lib
|
||||||
|
|
||||||
all: putty.exe puttytel.exe pscp.exe
|
all: putty.exe puttytel.exe pscp.exe plink.exe
|
||||||
|
|
||||||
putty.exe: $(GOBJS1) $(GOBJS2) $(POBJS) $(MOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(PRESRC) putty.rsp
|
putty.exe: $(GOBJS1) $(GOBJS2) $(LOBJS1) $(POBJS) $(MOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(PRESRC) putty.rsp
|
||||||
link $(LFLAGS) -out:putty.exe @putty.rsp
|
link $(LFLAGS) -out:putty.exe @putty.rsp
|
||||||
|
|
||||||
puttytel.exe: $(GOBJS1) $(GOBJS2) $(TOBJS) $(MOBJS) $(TRESRC) puttytel.rsp
|
puttytel.exe: $(GOBJS1) $(GOBJS2) $(LOBJS1) $(TOBJS) $(MOBJS) $(TRESRC) puttytel.rsp
|
||||||
link $(LFLAGS) -out:puttytel.exe @puttytel.rsp
|
link $(LFLAGS) -out:puttytel.exe @puttytel.rsp
|
||||||
|
|
||||||
pscp.exe: $(SOBJS) $(MOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(SRESRC) pscp.rsp
|
pscp.exe: $(SOBJS) $(MOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(SRESRC) pscp.rsp
|
||||||
link $(LFLAGS) -out:pscp.exe @pscp.rsp
|
link $(LFLAGS) -out:pscp.exe @pscp.rsp
|
||||||
|
|
||||||
|
plink.exe: $(LOBJS1) $(POBJS) $(PLOBJS) $(MOBJS) $(OBJS1) $(OBJS2) $(OBJS3) $(LRESRC) plink.rsp
|
||||||
|
link $(LFLAGS) -out:plink.exe @plink.rsp
|
||||||
|
|
||||||
putty.rsp: makefile
|
putty.rsp: makefile
|
||||||
echo /nologo /subsystem:windows > putty.rsp
|
echo /nologo /subsystem:windows > putty.rsp
|
||||||
echo $(GOBJS1) >> putty.rsp
|
echo $(GOBJS1) >> putty.rsp
|
||||||
echo $(GOBJS2) >> putty.rsp
|
echo $(GOBJS2) >> putty.rsp
|
||||||
|
echo $(LOBJS1) >> putty.rsp
|
||||||
echo $(POBJS) >> putty.rsp
|
echo $(POBJS) >> putty.rsp
|
||||||
echo $(MOBJS) >> putty.rsp
|
echo $(MOBJS) >> putty.rsp
|
||||||
echo $(OBJS1) >> putty.rsp
|
echo $(OBJS1) >> putty.rsp
|
||||||
@ -100,16 +112,19 @@ putty.rsp: makefile
|
|||||||
echo $(PRESRC) >> putty.rsp
|
echo $(PRESRC) >> putty.rsp
|
||||||
echo $(LIBS1) >> putty.rsp
|
echo $(LIBS1) >> putty.rsp
|
||||||
echo $(LIBS2) >> putty.rsp
|
echo $(LIBS2) >> putty.rsp
|
||||||
|
echo $(SOCK1) >> putty.rsp
|
||||||
|
|
||||||
puttytel.rsp: makefile
|
puttytel.rsp: makefile
|
||||||
echo /nologo /subsystem:windows > puttytel.rsp
|
echo /nologo /subsystem:windows > puttytel.rsp
|
||||||
echo $(GOBJS1) >> puttytel.rsp
|
echo $(GOBJS1) >> puttytel.rsp
|
||||||
echo $(GOBJS2) >> puttytel.rsp
|
echo $(GOBJS2) >> puttytel.rsp
|
||||||
|
echo $(LOBJS1) >> puttytel.rsp
|
||||||
echo $(TOBJS) >> puttytel.rsp
|
echo $(TOBJS) >> puttytel.rsp
|
||||||
echo $(MOBJS) >> puttytel.rsp
|
echo $(MOBJS) >> puttytel.rsp
|
||||||
echo $(TRESRC) >> puttytel.rsp
|
echo $(TRESRC) >> puttytel.rsp
|
||||||
echo $(LIBS1) >> puttytel.rsp
|
echo $(LIBS1) >> puttytel.rsp
|
||||||
echo $(LIBS2) >> puttytel.rsp
|
echo $(LIBS2) >> puttytel.rsp
|
||||||
|
echo $(SOCK1) >> puttytel.rsp
|
||||||
|
|
||||||
pscp.rsp: makefile
|
pscp.rsp: makefile
|
||||||
echo /nologo /subsystem:console > pscp.rsp
|
echo /nologo /subsystem:console > pscp.rsp
|
||||||
@ -121,6 +136,21 @@ pscp.rsp: makefile
|
|||||||
echo $(SRESRC) >> pscp.rsp
|
echo $(SRESRC) >> pscp.rsp
|
||||||
echo $(LIBS1) >> pscp.rsp
|
echo $(LIBS1) >> pscp.rsp
|
||||||
echo $(LIBS2) >> pscp.rsp
|
echo $(LIBS2) >> pscp.rsp
|
||||||
|
echo $(SOCK1) >> pscp.rsp
|
||||||
|
|
||||||
|
plink.rsp: makefile
|
||||||
|
echo /nologo /subsystem:console > plink.rsp
|
||||||
|
echo $(LOBJS1) >> plink.rsp
|
||||||
|
echo $(POBJS) >> plink.rsp
|
||||||
|
echo $(PLOBJS) >> plink.rsp
|
||||||
|
echo $(MOBJS) >> plink.rsp
|
||||||
|
echo $(OBJS1) >> plink.rsp
|
||||||
|
echo $(OBJS2) >> plink.rsp
|
||||||
|
echo $(OBJS3) >> plink.rsp
|
||||||
|
echo $(LRESRC) >> plink.rsp
|
||||||
|
echo $(LIBS1) >> plink.rsp
|
||||||
|
echo $(LIBS2) >> plink.rsp
|
||||||
|
echo $(SOCK2) >> plink.rsp
|
||||||
|
|
||||||
##-- dependencies
|
##-- dependencies
|
||||||
window.$(OBJ): window.c putty.h win_res.h
|
window.$(OBJ): window.c putty.h win_res.h
|
||||||
@ -150,6 +180,7 @@ version.$(OBJ): version.c
|
|||||||
be_all.$(OBJ): be_all.c
|
be_all.$(OBJ): be_all.c
|
||||||
be_nossh.$(OBJ): be_nossh.c
|
be_nossh.$(OBJ): be_nossh.c
|
||||||
be_none.$(OBJ): be_none.c
|
be_none.$(OBJ): be_none.c
|
||||||
|
plink.$(OBJ): plink.c putty.h
|
||||||
##--
|
##--
|
||||||
|
|
||||||
# Hack to force version.obj to be rebuilt always
|
# Hack to force version.obj to be rebuilt always
|
||||||
|
9
putty.h
9
putty.h
@ -109,6 +109,7 @@ typedef struct {
|
|||||||
void (*send) (char *buf, int len);
|
void (*send) (char *buf, int len);
|
||||||
void (*size) (void);
|
void (*size) (void);
|
||||||
void (*special) (Telnet_Special code);
|
void (*special) (Telnet_Special code);
|
||||||
|
SOCKET (*socket) (void);
|
||||||
} Backend;
|
} Backend;
|
||||||
|
|
||||||
GLOBAL Backend *back;
|
GLOBAL Backend *back;
|
||||||
@ -196,6 +197,14 @@ typedef struct {
|
|||||||
#define DEFAULT_PORT 22
|
#define DEFAULT_PORT 22
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some global flags denoting the type of application.
|
||||||
|
*/
|
||||||
|
#define FLAG_VERBOSE 0x0001
|
||||||
|
#define FLAG_WINDOWED 0x0002
|
||||||
|
#define FLAG_CONNECTION 0x0004
|
||||||
|
GLOBAL int flags;
|
||||||
|
|
||||||
GLOBAL Config cfg;
|
GLOBAL Config cfg;
|
||||||
GLOBAL int default_protocol;
|
GLOBAL int default_protocol;
|
||||||
GLOBAL int default_port;
|
GLOBAL int default_port;
|
||||||
|
7
raw.c
7
raw.c
@ -124,7 +124,7 @@ static char *raw_init (HWND hwnd, char *host, int port, char **realhost) {
|
|||||||
default: return "connect(): unknown error";
|
default: return "connect(): unknown error";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ |
|
if (hwnd && WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ |
|
||||||
FD_WRITE | FD_OOB | FD_CLOSE) == SOCKET_ERROR)
|
FD_WRITE | FD_OOB | FD_CLOSE) == SOCKET_ERROR)
|
||||||
switch (WSAGetLastError()) {
|
switch (WSAGetLastError()) {
|
||||||
case WSAENETDOWN: return "Network is down";
|
case WSAENETDOWN: return "Network is down";
|
||||||
@ -215,10 +215,13 @@ static void raw_special (Telnet_Special code) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SOCKET raw_socket(void) { return s; }
|
||||||
|
|
||||||
Backend raw_backend = {
|
Backend raw_backend = {
|
||||||
raw_init,
|
raw_init,
|
||||||
raw_msg,
|
raw_msg,
|
||||||
raw_send,
|
raw_send,
|
||||||
raw_size,
|
raw_size,
|
||||||
raw_special
|
raw_special,
|
||||||
|
raw_socket
|
||||||
};
|
};
|
||||||
|
4
scp.c
4
scp.c
@ -844,7 +844,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
default_protocol = PROT_TELNET;
|
default_protocol = PROT_TELNET;
|
||||||
|
|
||||||
scp_flags = SCP_FLAG;
|
flags = 0;
|
||||||
ssh_get_password = &get_password;
|
ssh_get_password = &get_password;
|
||||||
init_winsock();
|
init_winsock();
|
||||||
|
|
||||||
@ -852,7 +852,7 @@ int main(int argc, char *argv[])
|
|||||||
if (argv[i][0] != '-')
|
if (argv[i][0] != '-')
|
||||||
break;
|
break;
|
||||||
if (strcmp(argv[i], "-v") == 0)
|
if (strcmp(argv[i], "-v") == 0)
|
||||||
verbose = 1, scp_flags |= SCP_VERBOSE;
|
verbose = 1, flags |= FLAG_VERBOSE;
|
||||||
else if (strcmp(argv[i], "-r") == 0)
|
else if (strcmp(argv[i], "-r") == 0)
|
||||||
recursive = 1;
|
recursive = 1;
|
||||||
else if (strcmp(argv[i], "-p") == 0)
|
else if (strcmp(argv[i], "-p") == 0)
|
||||||
|
4
scp.h
4
scp.h
@ -3,10 +3,6 @@
|
|||||||
* Joris van Rantwijk, Aug 1999, Jun 2000.
|
* Joris van Rantwijk, Aug 1999, Jun 2000.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SCP_FLAG 1
|
|
||||||
#define SCP_VERBOSE 2
|
|
||||||
#define IS_SCP ((scp_flags & SCP_FLAG) != 0)
|
|
||||||
|
|
||||||
/* Exported from ssh.c */
|
/* Exported from ssh.c */
|
||||||
extern int scp_flags;
|
extern int scp_flags;
|
||||||
extern int (*ssh_get_password)(const char *prompt, char *str, int maxlen);
|
extern int (*ssh_get_password)(const char *prompt, char *str, int maxlen);
|
||||||
|
67
ssh.c
67
ssh.c
@ -16,7 +16,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define logevent(s) { logevent(s); \
|
#define logevent(s) { logevent(s); \
|
||||||
if (IS_SCP && (scp_flags & SCP_VERBOSE) != 0) \
|
if (!(flags & FLAG_CONNECTION) && (flags & FLAG_VERBOSE)) \
|
||||||
fprintf(stderr, "%s\n", s); }
|
fprintf(stderr, "%s\n", s); }
|
||||||
|
|
||||||
#define SSH1_MSG_DISCONNECT 1
|
#define SSH1_MSG_DISCONNECT 1
|
||||||
@ -160,7 +160,6 @@ static struct ssh_compress *cscomp = NULL;
|
|||||||
static struct ssh_compress *sccomp = NULL;
|
static struct ssh_compress *sccomp = NULL;
|
||||||
static struct ssh_kex *kex = NULL;
|
static struct ssh_kex *kex = NULL;
|
||||||
static struct ssh_hostkey *hostkey = NULL;
|
static struct ssh_hostkey *hostkey = NULL;
|
||||||
int scp_flags = 0;
|
|
||||||
int (*ssh_get_password)(const char *prompt, char *str, int maxlen) = NULL;
|
int (*ssh_get_password)(const char *prompt, char *str, int maxlen) = NULL;
|
||||||
|
|
||||||
static char *savedhost;
|
static char *savedhost;
|
||||||
@ -177,11 +176,9 @@ static int size_needed = FALSE;
|
|||||||
static void s_write (char *buf, int len) {
|
static void s_write (char *buf, int len) {
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
int i = send (s, buf, len, 0);
|
int i = send (s, buf, len, 0);
|
||||||
if (IS_SCP) {
|
noise_ultralight(i);
|
||||||
noise_ultralight(i);
|
if (i <= 0)
|
||||||
if (i <= 0)
|
fatalbox("Lost connection while sending");
|
||||||
fatalbox("Lost connection while sending");
|
|
||||||
}
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
len -= i, buf += i;
|
len -= i, buf += i;
|
||||||
}
|
}
|
||||||
@ -191,8 +188,7 @@ static int s_read (char *buf, int len) {
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
int i = recv (s, buf, len, 0);
|
int i = recv (s, buf, len, 0);
|
||||||
if (IS_SCP)
|
noise_ultralight(i);
|
||||||
noise_ultralight(i);
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
len -= i, buf += i, ret += i;
|
len -= i, buf += i, ret += i;
|
||||||
else
|
else
|
||||||
@ -202,10 +198,11 @@ static int s_read (char *buf, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void c_write (char *buf, int len) {
|
static void c_write (char *buf, int len) {
|
||||||
if (IS_SCP) {
|
if (!(flags & FLAG_CONNECTION)) {
|
||||||
if (len > 0 && buf[len-1] == '\n') len--;
|
int i;
|
||||||
if (len > 0 && buf[len-1] == '\r') len--;
|
for (i = 0; i < len; i++)
|
||||||
if (len > 0) { fwrite(buf, len, 1, stderr); fputc('\n', stderr); }
|
if (buf[i] != '\r')
|
||||||
|
fputc(buf[i], stderr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (len--)
|
while (len--)
|
||||||
@ -1133,7 +1130,7 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
|
|||||||
static char username[100];
|
static char username[100];
|
||||||
static int pos = 0;
|
static int pos = 0;
|
||||||
static char c;
|
static char c;
|
||||||
if (!IS_SCP && !*cfg.username) {
|
if (!(flags & FLAG_CONNECTION) && !*cfg.username) {
|
||||||
c_write("login as: ", 10);
|
c_write("login as: ", 10);
|
||||||
while (pos >= 0) {
|
while (pos >= 0) {
|
||||||
crWaitUntil(!ispkt);
|
crWaitUntil(!ispkt);
|
||||||
@ -1173,9 +1170,9 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
|
|||||||
char stuff[200];
|
char stuff[200];
|
||||||
strncpy(username, cfg.username, 99);
|
strncpy(username, cfg.username, 99);
|
||||||
username[99] = '\0';
|
username[99] = '\0';
|
||||||
if (!IS_SCP) {
|
if (flags & FLAG_VERBOSE) {
|
||||||
sprintf(stuff, "Sent username \"%s\".\r\n", username);
|
sprintf(stuff, "Sent username \"%s\".\r\n", username);
|
||||||
c_write(stuff, strlen(stuff));
|
c_write(stuff, strlen(stuff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1204,7 +1201,7 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
|
|||||||
if (*cfg.keyfile && !tried_publickey)
|
if (*cfg.keyfile && !tried_publickey)
|
||||||
pwpkt_type = SSH1_CMSG_AUTH_RSA;
|
pwpkt_type = SSH1_CMSG_AUTH_RSA;
|
||||||
|
|
||||||
if (pwpkt_type == SSH1_CMSG_AUTH_PASSWORD && IS_SCP) {
|
if (pwpkt_type == SSH1_CMSG_AUTH_PASSWORD && !FLAG_WINDOWED) {
|
||||||
char prompt[200];
|
char prompt[200];
|
||||||
sprintf(prompt, "%s@%s's password: ", cfg.username, savedhost);
|
sprintf(prompt, "%s@%s's password: ", cfg.username, savedhost);
|
||||||
if (!ssh_get_password(prompt, password, sizeof(password))) {
|
if (!ssh_get_password(prompt, password, sizeof(password))) {
|
||||||
@ -1242,9 +1239,11 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
|
|||||||
if (pwpkt_type == SSH1_CMSG_AUTH_PASSWORD)
|
if (pwpkt_type == SSH1_CMSG_AUTH_PASSWORD)
|
||||||
c_write("password: ", 10);
|
c_write("password: ", 10);
|
||||||
if (pwpkt_type == SSH1_CMSG_AUTH_RSA) {
|
if (pwpkt_type == SSH1_CMSG_AUTH_RSA) {
|
||||||
c_write("Trying public key authentication.\r\n", 35);
|
if (flags & FLAG_VERBOSE)
|
||||||
|
c_write("Trying public key authentication.\r\n", 35);
|
||||||
if (!rsakey_encrypted(cfg.keyfile)) {
|
if (!rsakey_encrypted(cfg.keyfile)) {
|
||||||
c_write("No passphrase required.\r\n", 25);
|
if (flags & FLAG_VERBOSE)
|
||||||
|
c_write("No passphrase required.\r\n", 25);
|
||||||
goto tryauth;
|
goto tryauth;
|
||||||
}
|
}
|
||||||
c_write("passphrase: ", 12);
|
c_write("passphrase: ", 12);
|
||||||
@ -1313,7 +1312,8 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
|
|||||||
|
|
||||||
crWaitUntil(ispkt);
|
crWaitUntil(ispkt);
|
||||||
if (pktin.type == SSH1_SMSG_FAILURE) {
|
if (pktin.type == SSH1_SMSG_FAILURE) {
|
||||||
c_write("Server refused our public key.\r\n", 32);
|
if (flags & FLAG_VERBOSE)
|
||||||
|
c_write("Server refused our public key.\r\n", 32);
|
||||||
continue; /* go and try password */
|
continue; /* go and try password */
|
||||||
}
|
}
|
||||||
if (pktin.type != SSH1_SMSG_AUTH_RSA_CHALLENGE)
|
if (pktin.type != SSH1_SMSG_AUTH_RSA_CHALLENGE)
|
||||||
@ -1337,7 +1337,9 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
|
|||||||
|
|
||||||
crWaitUntil(ispkt);
|
crWaitUntil(ispkt);
|
||||||
if (pktin.type == SSH1_SMSG_FAILURE) {
|
if (pktin.type == SSH1_SMSG_FAILURE) {
|
||||||
c_write("Failed to authenticate with our public key.\r\n", 45);
|
if (flags & FLAG_VERBOSE)
|
||||||
|
c_write("Failed to authenticate with our public key.\r\n",
|
||||||
|
45);
|
||||||
continue; /* go and try password */
|
continue; /* go and try password */
|
||||||
} else if (pktin.type != SSH1_SMSG_SUCCESS) {
|
} else if (pktin.type != SSH1_SMSG_SUCCESS) {
|
||||||
fatalbox("Bizarre response to RSA authentication response");
|
fatalbox("Bizarre response to RSA authentication response");
|
||||||
@ -1351,7 +1353,8 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
|
|||||||
memset(password, 0, strlen(password));
|
memset(password, 0, strlen(password));
|
||||||
crWaitUntil(ispkt);
|
crWaitUntil(ispkt);
|
||||||
if (pktin.type == SSH1_SMSG_FAILURE) {
|
if (pktin.type == SSH1_SMSG_FAILURE) {
|
||||||
c_write("Access denied\r\n", 15);
|
if (flags & FLAG_VERBOSE)
|
||||||
|
c_write("Access denied\r\n", 15);
|
||||||
logevent("Authentication refused");
|
logevent("Authentication refused");
|
||||||
} else if (pktin.type == SSH1_MSG_DISCONNECT) {
|
} else if (pktin.type == SSH1_MSG_DISCONNECT) {
|
||||||
logevent("Received disconnect request");
|
logevent("Received disconnect request");
|
||||||
@ -1775,7 +1778,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
|
|||||||
static int pos = 0;
|
static int pos = 0;
|
||||||
static char c;
|
static char c;
|
||||||
|
|
||||||
if (!IS_SCP && !*cfg.username) {
|
if ((flags & FLAG_CONNECTION) && !*cfg.username) {
|
||||||
c_write("login as: ", 10);
|
c_write("login as: ", 10);
|
||||||
while (pos >= 0) {
|
while (pos >= 0) {
|
||||||
crWaitUntilV(!ispkt);
|
crWaitUntilV(!ispkt);
|
||||||
@ -1815,13 +1818,13 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
|
|||||||
char stuff[200];
|
char stuff[200];
|
||||||
strncpy(username, cfg.username, 99);
|
strncpy(username, cfg.username, 99);
|
||||||
username[99] = '\0';
|
username[99] = '\0';
|
||||||
if (!IS_SCP) {
|
if (flags & FLAG_VERBOSE) {
|
||||||
sprintf(stuff, "Using username \"%s\".\r\n", username);
|
sprintf(stuff, "Using username \"%s\".\r\n", username);
|
||||||
c_write(stuff, strlen(stuff));
|
c_write(stuff, strlen(stuff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_SCP) {
|
if (!(flags & FLAG_WINDOWED)) {
|
||||||
char prompt[200];
|
char prompt[200];
|
||||||
sprintf(prompt, "%s@%s's password: ", cfg.username, savedhost);
|
sprintf(prompt, "%s@%s's password: ", cfg.username, savedhost);
|
||||||
if (!ssh_get_password(prompt, password, sizeof(password))) {
|
if (!ssh_get_password(prompt, password, sizeof(password))) {
|
||||||
@ -2033,7 +2036,7 @@ static char *ssh_init (HWND hwnd, char *host, int port, char **realhost) {
|
|||||||
if (!do_ssh_init())
|
if (!do_ssh_init())
|
||||||
return "Protocol initialisation error";
|
return "Protocol initialisation error";
|
||||||
|
|
||||||
if (WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ | FD_CLOSE) == SOCKET_ERROR)
|
if (hwnd && WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ | FD_CLOSE) == SOCKET_ERROR)
|
||||||
switch (WSAGetLastError()) {
|
switch (WSAGetLastError()) {
|
||||||
case WSAENETDOWN: return "Network is down";
|
case WSAENETDOWN: return "Network is down";
|
||||||
default: return "WSAAsyncSelect(): unknown error";
|
default: return "WSAAsyncSelect(): unknown error";
|
||||||
@ -2134,8 +2137,6 @@ static void get_packet(void)
|
|||||||
long to_read;
|
long to_read;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
assert(IS_SCP);
|
|
||||||
|
|
||||||
p = NULL;
|
p = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
@ -2164,8 +2165,6 @@ int ssh_scp_recv(unsigned char *buf, int len)
|
|||||||
static unsigned char *pending_input_ptr;
|
static unsigned char *pending_input_ptr;
|
||||||
int to_read = len;
|
int to_read = len;
|
||||||
|
|
||||||
assert(IS_SCP);
|
|
||||||
|
|
||||||
if (pending_input_len >= to_read) {
|
if (pending_input_len >= to_read) {
|
||||||
memcpy(buf, pending_input_ptr, to_read);
|
memcpy(buf, pending_input_ptr, to_read);
|
||||||
pending_input_ptr += to_read;
|
pending_input_ptr += to_read;
|
||||||
@ -2229,7 +2228,6 @@ int ssh_scp_recv(unsigned char *buf, int len)
|
|||||||
*/
|
*/
|
||||||
void ssh_scp_send(unsigned char *buf, int len)
|
void ssh_scp_send(unsigned char *buf, int len)
|
||||||
{
|
{
|
||||||
assert(IS_SCP);
|
|
||||||
if (s == INVALID_SOCKET)
|
if (s == INVALID_SOCKET)
|
||||||
return;
|
return;
|
||||||
send_packet(SSH1_CMSG_STDIN_DATA,
|
send_packet(SSH1_CMSG_STDIN_DATA,
|
||||||
@ -2242,7 +2240,6 @@ void ssh_scp_send(unsigned char *buf, int len)
|
|||||||
*/
|
*/
|
||||||
void ssh_scp_send_eof(void)
|
void ssh_scp_send_eof(void)
|
||||||
{
|
{
|
||||||
assert(IS_SCP);
|
|
||||||
if (s == INVALID_SOCKET)
|
if (s == INVALID_SOCKET)
|
||||||
return;
|
return;
|
||||||
send_packet(SSH1_CMSG_EOF, PKT_END);
|
send_packet(SSH1_CMSG_EOF, PKT_END);
|
||||||
@ -2258,8 +2255,6 @@ char *ssh_scp_init(char *host, int port, char *cmd, char **realhost)
|
|||||||
{
|
{
|
||||||
char buf[160], *p;
|
char buf[160], *p;
|
||||||
|
|
||||||
assert(IS_SCP);
|
|
||||||
|
|
||||||
#ifdef MSCRYPTOAPI
|
#ifdef MSCRYPTOAPI
|
||||||
if (crypto_startup() == 0)
|
if (crypto_startup() == 0)
|
||||||
return "Microsoft high encryption pack not installed!";
|
return "Microsoft high encryption pack not installed!";
|
||||||
@ -2295,11 +2290,13 @@ char *ssh_scp_init(char *host, int port, char *cmd, char **realhost)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SOCKET ssh_socket(void) { return s; }
|
||||||
|
|
||||||
Backend ssh_backend = {
|
Backend ssh_backend = {
|
||||||
ssh_init,
|
ssh_init,
|
||||||
ssh_msg,
|
ssh_msg,
|
||||||
ssh_send,
|
ssh_send,
|
||||||
ssh_size,
|
ssh_size,
|
||||||
ssh_special
|
ssh_special,
|
||||||
|
ssh_socket
|
||||||
};
|
};
|
||||||
|
8
telnet.c
8
telnet.c
@ -552,7 +552,7 @@ static char *telnet_init (HWND hwnd, char *host, int port, char **realhost) {
|
|||||||
default: return "connect(): unknown error";
|
default: return "connect(): unknown error";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ |
|
if (hwnd && WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ |
|
||||||
FD_WRITE | FD_OOB | FD_CLOSE) == SOCKET_ERROR)
|
FD_WRITE | FD_OOB | FD_CLOSE) == SOCKET_ERROR)
|
||||||
switch (WSAGetLastError()) {
|
switch (WSAGetLastError()) {
|
||||||
case WSAENETDOWN: return "Network is down";
|
case WSAENETDOWN: return "Network is down";
|
||||||
@ -631,7 +631,6 @@ static int telnet_msg (WPARAM wParam, LPARAM lParam) {
|
|||||||
s = INVALID_SOCKET;
|
s = INVALID_SOCKET;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_telnet_read (buf, ret);
|
do_telnet_read (buf, ret);
|
||||||
} while (in_synch);
|
} while (in_synch);
|
||||||
}
|
}
|
||||||
@ -733,10 +732,13 @@ static void telnet_special (Telnet_Special code) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SOCKET telnet_socket(void) { return s; }
|
||||||
|
|
||||||
Backend telnet_backend = {
|
Backend telnet_backend = {
|
||||||
telnet_init,
|
telnet_init,
|
||||||
telnet_msg,
|
telnet_msg,
|
||||||
telnet_send,
|
telnet_send,
|
||||||
telnet_size,
|
telnet_size,
|
||||||
telnet_special
|
telnet_special,
|
||||||
|
telnet_socket
|
||||||
};
|
};
|
||||||
|
1
window.c
1
window.c
@ -89,6 +89,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
|
|||||||
int guess_width, guess_height;
|
int guess_width, guess_height;
|
||||||
|
|
||||||
putty_inst = inst;
|
putty_inst = inst;
|
||||||
|
flags = FLAG_VERBOSE | FLAG_WINDOWED | FLAG_CONNECTION;
|
||||||
|
|
||||||
winsock_ver = MAKEWORD(1, 1);
|
winsock_ver = MAKEWORD(1, 1);
|
||||||
if (WSAStartup(winsock_ver, &wsadata)) {
|
if (WSAStartup(winsock_ver, &wsadata)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user