forked from grengojbo/coova_json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t.php
245 lines (211 loc) · 10.3 KB
/
t.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
<?
/*
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
ini_set('log_errors',TRUE);
ini_set('html_errors',FALSE);
ini_set('error_log','/var/log/chilli.log');
ini_set('display_errors',FALSE);
*/
$challenge = $_REQUEST['challenge'];
$userurl = $_REQUEST['userurl'];
$res = $_REQUEST['res'];
$qs = $_SERVER["QUERY_STRING"];
$uamip = $_REQUEST['uamip'];
$uamport = $_REQUEST['uamport'];
$key = '123456789';
$value = '1-00-00-00';
$profile= 'Free30min';
// $profile= 'Test5min';
$expires= '2010-07-01';
$precede= 'sms';
$realm = 'OceanPLaza';
$hotspot_portal = "http://127.0.0.1";
// $default_site = urlencode('http://oceanplaza.com.ua');
$default_site = 'http://oceanplaza.com.ua';
$uamsecret = 'greatsecret';
$gen_voucher = $hotspot_portal."/c2/yfi_cake/third_parties/json_create_voucher/?".
"key=".$key.'&voucher_value='.$value.'&profile='.urlencode($profile).'&realm='.urlencode($realm);
#"key=".$key.'&voucher_value='.$value.'&profile='.urlencode($profile).'&expires='.$expires.'&precede='.$precede.'&realm='.urlencode($realm);
//error_log(print_r("wget -q -O - '".$gen_voucher."'", TRUE));
print_r("wget -q -O - '".$gen_voucher."'");
$fb = exec("wget -q -O - '".$gen_voucher."'");
//--- Sanitize the feedback a bit ------
$fb = preg_replace("/^\(/","",$fb);
$fb = preg_replace("/\)/","",$fb);
$fb = preg_replace("/;/","",$fb);
$json_array = json_decode($fb,true);
if($json_array['json']['status'] == 'ok'){
// echo "<b>Voucher id </b>".$json_array['voucher']['id']."<br>\n";
// echo "<b>Voucher username </b>".$json_array['voucher']['username']."<br>\n";
// echo "<b>Voucher password </b>".$json_array['voucher']['password']."<br>\n";
}
//--There is a bug that keeps the logout in a loop if userurl is http%3a%2f%2f1.0.0.0 ---/
//--We need to remove this and replace it with something we want
$userurl = $default_site;
if (preg_match("/1\.0\.0\.0/i", $userurl)) {
$pattern = "/1\.0\.0\.0/i";
$userurl = preg_replace($pattern, $default_site, $userurl);
}
// $userurl = $default_site;
//---------------------------------------------------------
if($res == 'success'){
header("Location: $userurl");
print("\n</html>");
}
if($res == 'failed'){
header("Location: fail.php?".$qs);
print("\n</html>");
}
//-- cookie add on -------------------------------
if($res == 'notyet'){
if(isset($_COOKIE['hs'])){
$dir = '/logon';
$userurl = $_REQUEST['userurl'];
$redir = urlencode($userurl);
$username = $_COOKIE['hs']['username'];
$password = $_COOKIE['hs']['password'];
$enc_pwd = return_new_pwd($password,$challenge,$uamsecret);
$target = "http://$uamip".':'.$uamport.$dir."?username=$username&password=$enc_pwd&userurl=$redir";
header("Location: $target");
print("\n</html>");
}
}
//Function to do the encryption thing of the password
function return_new_pwd($pwd,$challenge,$uamsecret){
$hex_chal = pack('H32', $challenge); //Hex the challenge
$newchal = pack('H*', md5($hex_chal.$uamsecret)); //Add it to with $uamsecret (shared between chilli an this script)
$response = md5("\0" . $pwd . $newchal); //md5 the lot
$newpwd = pack('a32', $pwd); //pack again
$password = implode ('', unpack('H32', ($newpwd ^ $newchal))); //unpack again
print_r("pwd: ".$pwd);
print_r("challenge: ".$challenge);
print_r("uamsecret: ".$uamsecret);
print_r("hex_chal: ".$hex_chal);
print_r("newchal: ".$newchal);
print_r("response: ".$response);
print_r("newpwd: ".$newpwd);
print_r("password: ".$password);
print_r("--------------------------------");
return $password;
}
//-- End Cookie add on ------------
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ocean Plaza Wi-Fi</title>
<link rel="stylesheet" href="static/css/pure-min.css" media="screen">
<link rel="stylesheet" href="static/css/main.css" media="screen">
<link href="img/logo.ico" type="image/x-icon" rel="icon"/><link href="img/logo.ico" type="image/x-icon" rel="shortcut icon"/>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1" />
<script>
function submitInternet(){
document.forms['login'].buttonClicked.value = 4;
document.forms['login'].submit();
}
function submitADS(){
//document.forms[0].userurl.value = "<? echo(urlencode($userurl)) ?>";
document.forms['adlogin'].buttonClicked.value = 4;
document.forms['adlogin'].submit();
}
function loadAction(){
var url = window.location.href;
var args = new Object();
var query = location.search.substring(1);
var pairs = query.split("&");
for(var i=0;i<pairs.length;i++){
var pos = pairs[i].indexOf('=');
if(pos == -1) continue;
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
args[argname] = unescape(value);
}
//alert( "AP MAC Address is " + args.ap_mac);
//alert( "The Switch URL is " + args.switch_url);
document.forms['login'].action = args.switch_url;
// This is the status code returned from webauth login action
// Any value of status code from 1 to 5 is error condition and user
// should be shown error as below or modify the message as it suits
// the customer
if(args.statusCode == 1){
alert("You are already logged in. No further action is required on your part.");
}
else if(args.statusCode == 2){
alert("You are not configured to authenticate against web portal. No further action is required on your part.");
}
else if(args.statusCode == 3){
alert("The username specified cannot be used at this time. Perhaps the username is already logged into the system?");
}
else if(args.statusCode == 4){
alert("Wrong username and password. Please try again.");
}
else if(args.statusCode == 5){
alert("The User Name and Password combination you have entered is invalid. Please try again.");
}
}
</script>
</head>
<body topmargin="50" marginheight="50">
<div class="pure-g-r" id="layout">
<?
$tuserurl = 'http://10.1.0.1/coova_json/://bbmedia.com.ua';
if (preg_match("/10\.1\.0\.1\/coova_json\/:\/\//i", $tuserurl)) {
$dsite = '';
$pattern = "/10\.1\.0\.1\/coova_json\/:\/\//i";
$tuserurl = preg_replace($pattern, $dsite, $tuserurl);
}
echo($tuserurl)
?>
<form name="adlogin" action="l.php" method="post">
<input TYPE="hidden" NAME="buttonClicked" SIZE="16" MAXLENGTH="15" value="0">
<input TYPE="hidden" NAME="redirect_url" SIZE="255" MAXLENGTH="255" VALUE="">
<input TYPE="hidden" NAME="err_flag" SIZE="16" MAXLENGTH="15" value="0">
<input TYPE="hidden" NAME="info_flag" SIZE="16" MAXLENGTH="15" value="0">
<input TYPE="hidden" NAME="info_msg" SIZE="32" MAXLENGTH="31" value="0">
<input type="hidden" name="uamip" value="<? echo($uamip) ?>" />
<input type="hidden" name="uamport" value="<? echo($uamport) ?>" />
<input type="hidden" name="challenge" value="<? echo($challenge) ?>" />
<input type="hidden" name="userurl" value="<? echo(urlencode($userurl)) ?>" />
<input type="hidden" name="password" value="<? echo($json_array['voucher']['password']) ?>">
<input type="hidden" name="username" value="<? echo($json_array['voucher']['username']) ?>">
<!-- <input type="checkbox" name="remember" value="remember" /> -->
<div class="pure-u-1" id="wifi-ad">
"http://ads.sky5.com.ua/openx/www/delivery/ck.php?oaparams=2__bannerid=31__zoneid=15__cb=9d338c56a0__oadest=http%3A%2F%2Fbbmedia.com.ua%2Fexclusive%2F2%2F"
<!-- http:%3A%2F%2Fbbmedia.com.ua -->
<script>document.forms['adlogin'].userurl.value = "<? echo(urlencode('http://ads.sky5.com.ua/openx/www/delivery/ck.php')) ?>?oaparams=2__bannerid=31__zoneid=15__cb=9d338c56a0__oadest=http%3A%2F%2Fbbmedia.com.ua%2Fexclusive%2F2%2F";
//if (window.matchMedia('(min-width: 769px)').matches) {
if (window.matchMedia('(max-width: 480px)').matches) {
document.write ('<INPUT TYPE="image" SRC="static/img/bbm320x350.gif" WIDTH="320" HEIGHT="350" BORDER="0" ALT="SUBMIT! phone">');
}
//if (window.matchMedia('(min-width: 769px)').matches) {
if (window.matchMedia('(max-width: 768px)').matches) {
document.write ('<INPUT TYPE="image" SRC="static/img/bbm768x840.jpg" WIDTH="768" HEIGHT="840" BORDER="0" ALT="SUBMIT! table">');
}
if (window.matchMedia('(min-width: 769px)').matches) {
document.write ('<INPUT TYPE="image" SRC="static/img/bbm960x450.jpg" WIDTH="960" HEIGHT="450" BORDER="0" ALT="SUBMIT! desctop">');
}
</script>
</div>
</form>
<form name="login" action="l.php" method="post">
<input TYPE="hidden" NAME="buttonClicked" SIZE="16" MAXLENGTH="15" value="0">
<input TYPE="hidden" NAME="redirect_url" SIZE="255" MAXLENGTH="255" VALUE="">
<input TYPE="hidden" NAME="err_flag" SIZE="16" MAXLENGTH="15" value="0">
<input TYPE="hidden" NAME="info_flag" SIZE="16" MAXLENGTH="15" value="0">
<input TYPE="hidden" NAME="info_msg" SIZE="32" MAXLENGTH="31" value="0">
<input type="hidden" name="uamip" value="<? echo($uamip) ?>" />
<input type="hidden" name="uamport" value="<? echo($uamport) ?>" />
<input type="hidden" name="challenge" value="<? echo($challenge) ?>" />
<input type="hidden" name="userurl" value="<? echo(urlencode($userurl)) ?>" />
<input type="hidden" name="password" value="<? echo($json_array['voucher']['password']) ?>">
<input type="hidden" name="username" value="<? echo($json_array['voucher']['username']) ?>">
<!-- <input type="checkbox" name="remember" value="remember" /> -->
<div class="pure-u-1"><div id="footer"><button class="pure-button pure-input-1-1 pure-button-primary" onclick="submitInternet();">Internet</button></div></div>
</form>
</div>
</body>
</html>