1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
//zmg, 03.01.01
//this file needs a better description!
//
//
// File: actions_password.txt
// Description: Router password related functions
// password_processPassword(Keycode)
// IN : Takes one key input from user
// DO : String together input keys as the password, and give the entered
// password to password_parsePassword() when <enter> is depressed
// OUT: None
function password_processPassword(keycode) {
// get the active router object
var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
if (keycode == 8) {
// if the key code is BACKSPACE
// delete 1 character if INPUT has characters to delete
if (rptr.INPUT.length > 0) {
rptr.INPUT = rptr.INPUT.substring(0,rptr.INPUT.length-1);
}
} else if (keycode == 13) {
// if the keycode is ENTER
// parse the password in INPUT
password_parsePassword();
} else {
// else the keycode is part of the password so add it to INPUT
rptr.INPUT += chr(keycode);
}
}
// password_parsePassword()
// IN : active_router.INPUT
// DO : Takes the input and checks against the password.
// for line con 0 and enable, parses password
// OUT: None
function password_parsePassword() {
// get the active router object
var rptr = eval("_root.r" + _root.active_router);
// get the visible router object
var visrptr = eval("_root.r" + _root.VISIBLE_ROUTER);
// space off the output
output_write("\n");
if (rptr.MODE == "startUp") {
// if we are still in startup mode
//if ((visrptr.INPUT == rptr.run.line.con_password)) {
// modified : Sitaram
// checking for the vty_password instead of con_password
// For telnet, Based on the Real Router, validation of password is done
//through vty_passwword
if ((visrptr.INPUT == rptr.run.line.vty_password)) {
// if the entered password matches the saved password
// allow user to have access the router
// end of modification : sitaram
rptr.passcount = 0;
_root.commandline_changeProcess("commandline_processCommandLine");
_root.commandline_setMode("user", _root.active_router);
_root.commandline_commandLine();
} else if ((rptr.passcount == 2)) {
// else if the user has tried to gain access three times
// unsuccessfully, exit the user, return to startup mode
rptr.passcount = 0;
var vr = eval("_root.r" + _root.VISIBLE_ROUTER);
var r = eval("_root.r" + _root.active_router);
if(vr.isTelnetingOut == true) {
output_write("% Bad passwords\n", "\n");
output_write("[Connection to " + TELNET_ADDRESS + " closed by foreign host]\n");
// if we are telneting out
// get the variables to reinstate the router
var tempmode = vr.telnetPath.pop();
var tempname = vr.telnetPath.pop();
var tempptr = eval("_root.r" + tempname);
// resetting the router we came from
if(r.wasntStartUp == true) {
r.router_startup = false;
r.wasntStartUp = false;
r.oldMode = "";
} else {
commandline_setMode(r.oldMode, _root.active_router);
r.oldMode = "";
}
_root.active_router = tempname;
tempptr.MODE = tempmode;
if(_root.VISIBLE_ROUTER == tempname) {
vr.isTelnetingOut = false;
}
_root.active_router.INPUT = "";
_root.commandline_changeProcess("commandline_processCommandLine");
_root.commandline_commandLine();
} else {
_root.commandline_changeProcess("router_startup_processStartUp");
rptr.router_startup = false;
_root.router_startup_checkStartUp();
}
}
} else if (rptr.MODE == "user") {
// modified by sitaram
// checking for the enable password also.
// user entered both enable and secret password's,
// secret password take prescendence over enable
// if we are in user mode trying for enable mode
// if the entered password matches the saved password
// allow user to have access to enable mode
if (rptr.run.secret != "") {
if (visrptr.INPUT == rptr.run.secret) {
rptr.passcount = 0;
_root.commandline_changeProcess("commandline_processCommandLine");
_root.commandline_setMode("enable", _root.active_router);
_root.commandline_commandLine();
//added by suresh on 29 march 2002
stepnum = stepnum + 1;
loadImage(stepnum,stepnum-1);
goToNextStep(stepnum, stepnum-1);
} else if (rptr.passcount == 2) {
// else if the user has tried to gain access three times
// unsuccessfully, exit the user, return to user mode
rptr.passcount = 0;
_root.commandline_changeProcess("commandline_processCommandLine");
_root.commandline_setMode("user", _root.active_router);
_root.output_write("% Bad secrets\n");
_root.commandline_commandLine();
}
}
else if (rptr.run.password != "")
{
if (visrptr.INPUT == rptr.run.password) {
rptr.passcount = 0;
_root.commandline_changeProcess("commandline_processCommandLine");
_root.commandline_setMode("enable", _root.active_router);
_root.commandline_commandLine();
//added by suresh on 29 march 2002
stepnum = stepnum + 1;
loadImage(stepnum,stepnum-1);
goToNextStep(stepnum, stepnum-1);
} else if (rptr.passcount == 2) {
// else if the user has tried to gain access three times
// unsuccessfully, exit the user, return to user mode
rptr.passcount = 0;
_root.commandline_changeProcess("commandline_processCommandLine");
_root.commandline_setMode("user", _root.active_router);
_root.output_write("% Bad secrets\n");
_root.commandline_commandLine();
}
}
}
// print the password prompt again if the user has not entered the
// correct password for the first or second time
if (processName == "password_processPassword") {
rptr.passcount++;
password_passwordLine();
}
}
// password_passwordLine()
// IN : None
// DO : Prompts the user for a password
// OUT: Password prompt
function password_passwordLine() {
// get the active router object
var rptr = eval("_root.r" + _root.VISIBLE_ROUTER);
// clear the input buffer for the router
rptr.INPUT = "";
// print the password prompt
output_write("Password:");
// create the global COMMAND array
COMMAND = new Array();
}
|