-
Notifications
You must be signed in to change notification settings - Fork 7
/
micronetlogin.php
executable file
·330 lines (324 loc) · 10.9 KB
/
micronetlogin.php
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<?php
$uamsecret = "easyhotspot";
# Uncomment the following line if you want to use ordinary user-password
# for radius authentication. Must be used together with $uamsecret.
$userpassword=1;
$loginpath = "micronetlogin.php";
$titel = 'Micronet System';
$headline = 'Your network manager.';
$bodytext = '';
$body_onload = '';
$footer_text = '<center>
<a href="#">[HELP]</a>
<a href="#">[terms and conditions]</a>
</center>';
$footer_textz = '';
# attempt to login
if ($_GET['login'] == login) {
$hexchal = pack ("H32", $_GET['chal']);
if (isset ($uamsecret)) {
$newchal = pack ("H*", md5($hexchal . $uamsecret));
} else {
$newchal = $hexchal;
}
$response = md5("\0" . $_GET['Password'] . $newchal);
$newpwd = pack("a32", $_GET['Password']);
$pappassword = implode ("", unpack("H32", ($newpwd ^ $newchal)));
$titel = 'Logging in to HotSpot';
$headline = 'Logging in to HotSpot';
$bodytext = '';
print_header();
if ((isset ($uamsecret)) && isset($userpassword)) {
print '<meta http-equiv="refresh" content="0;url=http://' . $_GET['uamip'] . ':' . $_GET['uamport'] . '/logon?username=' . $_GET['UserName'] . '&password=' . $pappassword . '">';
} else {
print '<meta http-equiv="refresh" content="0;url=http://' . $_GET['uamip'] . ':' . $_GET['uamport'] . '/logon?username=' . $_GET['UserName'] . '&response=' . $response . '&userurl=' . $_GET['userurl'] . '">';
}
print_body();
print_footer();
}
# 1: Login successful
if ($_GET['res'] == success) {
$result = 1;
$titel = 'Logged in to HotSpot';
$headline = 'Logged in to HotSpot';
$bodytext = 'Welcome';
$body_onload = 'onLoad="javascript:popUp(' . $loginpath . '?res=popup&uamip=' . $_GET['uamip'] . '&uamport=' . $_GET['uamport'] . '&timeleft=' . $_GET['timeleft'] . ')"';
print_header();
print_body();
if ($reply) {
print '<center>' . $reply . '</BR></BR></center>';
}
print '<center><a href="http://' . $_GET['uamip'] . ':' . $_GET['uamport'] . '/logoff">Logout</a></center>';
print_footer();
}
# 2: Login failed
if ($_GET['res'] == failed) {
$result = 2;
$titel = 'HotSpot Login Failed';
$headline = 'HotSpot Login Failed';
$bodytext = 'Sorry, try again<br>';
print_header();
print_body();
if ($_GET['reply']) {
print '<center>' . $_GET['reply'] . '</center>';
}
print_login_form();
print_footer();
}
# 3: Logged out
if ($_GET['res'] == logoff) {
$result = 3;
$titel = 'Logged out from HotSpot';
$headline = 'Logged out from HotSpot';
$bodytext = '<a href="http://' . $_GET['uamip'] . ':' . $_GET['uamport'] . '/prelogin">Login</a>';
print_header();
print_body();
print_footer();
}
# 4: Tried to login while already logged in
if ($_GET['res'] == already) {
$result = 4;
$titel = 'Already logged in to HotSpot';
$headline = 'Already logged in to HotSpot';
$bodytext = '<a href="http://' . $_GET['uamip'] . ':' . $_GET['uamport'] . '/logoff">Logout</a>';
print_header();
print_body();
print_footer();
}
# 5: Not logged in yet
if ($_GET['res'] == notyet) {
$result = 5;
$titel = 'Logged out from HotSpot';
$headline = 'Logged out from HotSpot';
$bodytext = 'please log in<br>';
print_header();
print_body();
print_login_form();
print_footer();
}
#11: Popup1
if ($_GET['res'] == popup1) {
$result = 11;
$titel = 'Logging into HotSpot';
$headline = 'Logged in to HotSpot';
$bodytext = 'please wait...';
print_header();
print_body();
print_footer();
}
#12: Popup2
if ($_GET['res'] == popup2) {
$result = 12;
$titel = 'Do not close this Window!';
$headline = 'Logged in to HotSpot';
$bodytext = '<a href="http://' . $_GET['uamip'] . ':' . $_GET['uamport'] . '/logoff">Logout</a>';
print_header();
print_bodyz();
print_footer();
}
#13: Popup3
if ($_GET['res'] == popup3) {
$result = 13;
$titel = 'Logged out from HotSpot';
$headline = 'Logged out from HotSpot';
$bodytext = '<a href="http://' . $_GET['uamip'] . ':' . $_GET['uamport'] . '/prelogin">Login</a>';
print_header();
print_body();
print_footer();
}
# 0: It was not a form request
# Send out an error message
if ($_GET['res'] == "") {
$result = 0;
$titel = 'What do you want here?';
$headline = 'HotSpot Login Failed';
$bodytext = 'Login must be performed through ChilliSpot daemon!';
print_header();
print_body();
print_footer();
}
# functions
function print_header(){
global $titel, $loginpath;
$uamip = $_GET['uamip'];
$uamport = $_GET['uamport'];
print "
<html>
<head>
<title>$titel</title>
<meta http-equiv=\"Cache-control\" content=\"no-cache\">
<meta http-equiv=\"Pragma\" content=\"no-cache\">
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">
<SCRIPT LANGUAGE=\"JavaScript\">
var blur = 0;
var starttime = new Date();
var startclock = starttime.getTime();
var mytimeleft = 0;
function doTime() {
window.setTimeout( \"doTime()\", 1000 );
t = new Date();
time = Math.round((t.getTime() - starttime.getTime())/1000);
if (mytimeleft) {
time = mytimeleft - time;
if (time <= 0) {
window.location = \"$loginpath?res=popup3&uamip=$uamip&uamport=$uamport\";
}
}
if (time < 0) time = 0;
hours = (time - (time % 3600)) / 3600;
time = time - (hours * 3600);
mins = (time - (time % 60)) / 60;
secs = time - (mins * 60);
if (hours < 10) hours = \"0\" + hours;
if (mins < 10) mins = \"0\" + mins;
if (secs < 10) secs = \"0\" + secs;
title = \"Online time: \" + hours + \":\" + mins + \":\" + secs;
if (mytimeleft) {
title = \"Remaining time: \" + hours + \":\" + mins + \":\" + secs;
}
if(document.all || document.getElementById){
document.title = title;
}
else {
self.status = title;
}
}
function popUp(URL) {
if (self.name != \"chillispot_popup\") {
chillispot_popup = window.open(URL, 'chillispot_popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=350,height=300');
}
}
function doOnLoad(result, URL, userurl, redirurl, timeleft) {
if (timeleft) {
mytimeleft = timeleft;
}
if ((result == 1) && (self.name == \"chillispot_popup\")) {
doTime();
}
if ((result == 1) && (self.name != \"chillispot_popup\")) {
chillispot_popup = window.open(URL, 'chillispot_popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=350,height=300');
}
if ((result == 2) || result == 5) {
document.form1.UserName.focus()
}
if ((result == 2) && (self.name != \"chillispot_popup\")) {
chillispot_popup = window.open('', 'chillispot_popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=200');
chillispot_popup.close();
}
if ((result == 12) && (self.name == \"chillispot_popup\")) {
doTime();
if (redirurl) {
opener.location = redirurl;
}
else if (opener.home) {
opener.home();
}
else {
opener.location = \"about:home\";
}
self.focus();
blur = 0;
}
if ((result == 13) && (self.name == \"chillispot_popup\")) {
self.focus();
blur = 1;
}
}
function doOnBlur(result) {
if ((result == 12) && (self.name == \"chillispot_popup\")) {
if (blur == 0) {
blur = 1;
self.focus();
}
}
}
function popup_logoff(url, name)
{
MyNewWindow=window.open(\"http://\"+url,name);
}
</script>";
}
function print_body(){
global $headline, $bodytext, $body_onload,$result, $loginpath;
$uamip = $_GET['uamip'];
$uamport = $_GET['uamport'];
$userurl = $_GET['userurl'];
$redirurl = $_GET['redirurl'];
$userurldecode = $_GET['userurl'];
$redirurldecode = $_GET['redirurl'];
$timeleft = $_GET['timeleft'];
print "
</head>
<body onLoad=\"javascript:doOnLoad($result, '$loginpath?res=popup2&uamip=$uamip&uamport=$uamport&userurl=$userurl&redirurl=$redirurl&timeleft=$timeleft','$userurldecode', '$redirurldecode', '$timeleft')\" onBlur = \"javascript:doOnBlur($result)\" bgColor = '#c0d8f4'>
<h1 style=\"text-align: center;\">$headline</h1>
<center>$bodytext</center><br>";
# begin debugging
# print '<center>THE INPUT (for debugging):<br>';
# foreach ($_GET as $key => $value) {
# print $key . '=' . $value . '<br>';
# }
# print '<br></center>';
# end debugging
}
function print_bodyz(){
global $headline, $bodytext, $body_onload, $result, $loginpath;
$uamip = $_GET['uamip'];
$uamport = $_GET['uamport'];
$userurl = $_GET['userurl'];
$redirurl = $_GET['redirurl'];
$userurldecode = $_GET['userurl'];
$redirurldecode = $_GET['redirurl'];
$timeleft = $_GET['timeleft'];
print "
</head>
<body onLoad=\"javascript:doOnLoad($result, '$loginpath?res=popup2&uamip=$uamip&uamport=$uamport&userurl=$userurl&redirurl=$redirurl&timeleft=$timeleft','$userurldecode', '$redirurldecode', '$timeleft')\" onBlur = \"javascript:doOnBlur($result)\" bgColor = '#c0d8f4' onUnLoad = \"javascript:popup_logoff('192.168.182.1:3990/logoff','Error')\">
<h1 style=\"text-align: center;\">$headline</h1>
<center>$bodytext</center><br><br>
<center>Do not close this window</center>
<center>otherwise you'll be logged out immediately</center>";
# begin debugging
# print '<center>THE INPUT (for debugging):<br>';
# foreach ($_GET as $key => $value) {
# print $key . '=' . $value . '<br>';
# }
# print '<br></center>';
# end debugging
}
function print_login_form(){
global $loginpath;
print '<FORM name="form1" METHOD="get" action="' . $loginpath . '?">
<INPUT TYPE="HIDDEN" NAME="chal" VALUE="' . $_GET['challenge'] . '">
<INPUT TYPE="HIDDEN" NAME="uamip" VALUE="' . $_GET['uamip'] . '">
<INPUT TYPE="HIDDEN" NAME="uamport" VALUE="' . $_GET['uamport'] . '">
<INPUT TYPE="HIDDEN" NAME="userurl" VALUE="' . $_GET['userurl'] . '">
<center>
<table border="0" cellpadding="5" cellspacing="0" style="width: 217px;">
<tbody>
<tr>
<td align="right">Login:</td>
<td><input type="text" name="UserName" size="20" maxlength="255"></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input type="password" name="Password" size="20" maxlength="255"></td>
</tr>
<tr>
<td align="center" colspan="2" height="23"><input type="submit" name="login" value="login"></td>
</tr>
</tbody>
</table>
</center>
</form>';
}
function print_footer(){
global $footer_text;
print $footer_text . '</body></html>';
exit(0);
}
function print_footerz(){
global $footer_textz;
print $footer_textz . '</body></html>';
exit(0);
}
exit(0);
?>