仅供参考,后果自负-_-
1、安装VS2003,下载putty Release 6.0(http://www.putty.nl/download.html)的源码。
2、在putty.h的struct config_tag中添加变量
在char username[100];这行的下面添加:
char password[100];
3、修改settings.c,将变量写入、读出注册表。
在write_setting_s(sesskey, "UserName", cfg->username);这行下面添加:
write_setting_s(sesskey, "password", cfg->password);
在gpps(sesskey, "UserName", "", cfg->username, sizeof(cfg->username));下面添加:
gpps(sesskey, "password", "", cfg->password, sizeof(cfg->password));
4、在config.c添加用于输入密码的控件
在
/*
* A sub-panel Connection/Data, containing options that
* decide on data to send to the server.
*/
if (!midsession) {
后面添加:
c = ctrl_editbox(s, "Auto-login password", 'w', 50,
HELPCTX(connection_password),
dlg_stdeditbox_handler, I(offsetof(Config,password)),
I(sizeof(((Config *)0)->password)));
c->editbox.password = 1; //设置该ctrl_editbox不为明文。输入的字符以*代替。
5、修改ssh.c,使保存的密码生效
共需要修改两个地方:
(1)用于交互式,使用solaris10测试
大约添加在7500行的
/*
* Send the responses to the server.
*/
前面。
(2)非交互式,使用RedHat AS4测试
大约添加在7573行的
在
/*
* Squirrel away the password. (We may need it later if
* asked to change it.)
*/
与
s->password = dupstr(s->cur_prompt->prompts[0]->result);
free_prompts(s->cur_prompt);
之间。
下面是需要添加的内容:
if (ssh->cfg.password[0] != '/0'&& !strcmp(" 123",s->cur_prompt->prompts[0]->result))
{
strcpy(s->cur_prompt->prompts[0]->result, ssh->cfg.password);
}
6、登录方法
在设置界面的 Connection->Data输入用户名、密码。
登录后,输 123, 即可登录系统。当然改为其它的都可以。
本次实现, 参考http://blog.csdn.net/wwwsq/archive/2007/07/27/1712827.aspx
1、安装VS2003,下载putty Release 6.0(http://www.putty.nl/download.html)的源码。
2、在putty.h的struct config_tag中添加变量
在char username[100];这行的下面添加:
char password[100];
3、修改settings.c,将变量写入、读出注册表。
在write_setting_s(sesskey, "UserName", cfg->username);这行下面添加:
write_setting_s(sesskey, "password", cfg->password);
在gpps(sesskey, "UserName", "", cfg->username, sizeof(cfg->username));下面添加:
gpps(sesskey, "password", "", cfg->password, sizeof(cfg->password));
4、在config.c添加用于输入密码的控件
在
/*
* A sub-panel Connection/Data, containing options that
* decide on data to send to the server.
*/
if (!midsession) {
后面添加:
c = ctrl_editbox(s, "Auto-login password", 'w', 50,
HELPCTX(connection_password),
dlg_stdeditbox_handler, I(offsetof(Config,password)),
I(sizeof(((Config *)0)->password)));
c->editbox.password = 1; //设置该ctrl_editbox不为明文。输入的字符以*代替。
5、修改ssh.c,使保存的密码生效
共需要修改两个地方:
(1)用于交互式,使用solaris10测试
大约添加在7500行的
/*
* Send the responses to the server.
*/
前面。
(2)非交互式,使用RedHat AS4测试
大约添加在7573行的
在
/*
* Squirrel away the password. (We may need it later if
* asked to change it.)
*/
与
s->password = dupstr(s->cur_prompt->prompts[0]->result);
free_prompts(s->cur_prompt);
之间。
下面是需要添加的内容:
if (ssh->cfg.password[0] != '/0'&& !strcmp(" 123",s->cur_prompt->prompts[0]->result))
{
strcpy(s->cur_prompt->prompts[0]->result, ssh->cfg.password);
}
6、登录方法
在设置界面的 Connection->Data输入用户名、密码。
登录后,输 123, 即可登录系统。当然改为其它的都可以。
本次实现, 参考http://blog.csdn.net/wwwsq/archive/2007/07/27/1712827.aspx