标签归档:开发

修改PuTTY v0.65源码以支持密码保存

PuTTY为安全考虑不支持保存会话中的密码。有时候还是会有密码保存的需求。这里提供的是最新版本0.65的修改方法:

这个保存到注册表的,明文保存,有一定风险,慎用。

winhelp.h
#define WINHELP_CTX_connection_username “connection.username:config-username”
后增加
#define WINHELP_CTX_connection_password “connection.password:config-password”

setting.c
X(STR, NONE, username) \
后增加
X(STR, NONE, password) \


write_setting_s(sesskey, “UserName”, conf_get_str(conf, CONF_username));
后增加
write_setting_s(sesskey, “PassWord” , conf_get_str(conf, CONF_password));

gpps(sesskey, “UserName”, “”, conf, CONF_username);
后面增加:
gpps(sesskey, “PassWord” , “” , conf, CONF_password);

config.c

ctrl_editbox(s, “Auto-login username”, ‘u’, 50,
HELPCTX(connection_username),
conf_editbox_handler, I(CONF_username), I(1));
后增加
c = ctrl_editbox(s, “Auto-login password”, ‘w’, 50,
HELPCTX(connection_password),
conf_editbox_handler, I(CONF_password), I(1));
c->editbox.password = 1;
ssh.c
找到
Plain old password authentication
在其后的变量定义后面增加
char *pwd;
pwd = conf_get_str(ssh->conf, CONF_password);
if (strlen(pwd)==0){

然后在其后的注释段Send the password packet前增加:
}else{
s->password = dupstr(pwd);
}

修改版本号:在version.h里修改TEXTVER的值即可。

官方下载的源代码 修改后的源代码