forked from troyhunt/PineappleSurprise
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
301 lines (271 loc) · 7.8 KB
/
index.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
<?php
// Include 'settings' form defines.php - copy one form provided .sample-file
include_once 'defines.php';
// Grab the host and full path of the requested URI
$requestedHost = $_SERVER["HTTP_HOST"];
$requestedUri = $requestedHost.$_SERVER["REQUEST_URI"];
// Make a nice friendly URL with no www prefix (only for display purposes)
$shortHost = str_replace("www.", "", $requestedHost);
// Also grab the user agent for logging and checking if it's a captive portal request
$userAgent = $_SERVER["HTTP_USER_AGENT"];
// Don't log favicon requests which the browser will issue when loading the log file
if($_SERVER["REQUEST_URI"] != "/favicon.ico")
{
logRequest($requestedUri, $userAgent);
}
// For these URIs and hosts "Success" page will be returned - not the educating one
$blackListedUris = array(
"www.apple.com/library/test/success.html",
);
$blackListedHosts = array(
"www.appleiphonecell.com",
"captive.apple.com",
"www.ibook.info",
"www.itools.info",
);
// This is iOS' Wi-Fi connectivity test request: https://erratasec.blogspot.com.au/2010/09/apples-secret-wispr-request.html
// iOS 7 added some new domains to the wispr request: https://supportforums.cisco.com/docs/DOC-36523
// Seems the iOS 7 may have a heap of domains so also check for the "CaptiveNetworkSupport" header https://forum.daviddarts.com/read.php?9,8879
if( in_array($requestedUri, $blackListedUris)
or in_array($requestedHost, $blackListedHosts)
or strpos($userAgent, "CaptiveNetworkSupport") !== false)
{
print_r("<HTML><HEAD><TITLE>Success</TITLE></HEAD><BODY>Success</BODY></HTML>");
exit();
}
// This is Windows' Wi-Fi connectivity test request: https://technet.microsoft.com/en-us/library/cc766017(v=WS.10).aspx
if($requestedUri == "www.msftncsi.com/ncsi.txt")
{
print_r("Microsoft NCSI");
exit();
}
?>
<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>This is not <?php print_r($shortHost); ?>!</title>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0" name="viewport" />
<style type="text/css">
body
{
font-family: league-gothic,sans-serif;
background-color: #333333;
color: #fdfdfd;
margin: 0;
padding: 0;
}
p
{
font-size: 0.9em;
line-height: 1.285em;
}
header, content
{
padding: 0 20%;
display: block;
}
header
{
padding-bottom: 20px;
}
content
{
background-color: #222222;
padding-top: 40px;
}
h1, h2
{
display: block;
font-weight: bold;
letter-spacing: 0.04em;
padding: 10px 0;
text-align: center;
text-transform: uppercase;
width: 100%;
padding: 0;
}
h1
{
font-size: 6.8em;
margin: 5px 0 0 0;
}
h2
{
font-size: 1.6em;
margin: 0 0 22px 0;
}
h3
{
font-size: 1em;
background-color: #b21563;
display: inline;
padding: 7px;
margin-bottom: 10px;
line-height: 2.2em;
}
hr
{
border: 0;
height: 6px;
background-color: #fdfdfd;
width: 30%;
}
p
{
padding: 0 0 23px 0;
margin: 10px 0 0 0;
}
p, li
{
word-wrap: break-word;
}
em
{
font-style: normal;
color: #a7d019;
font-size: 1.1em;
}
ol
{
color: #222222;
font-weight: bold;
}
ol span
{
color: #666666;
}
div
{
background-color: #a7d019;
padding: 10px;
margin-bottom: 40px;
}
@media only screen and (max-width: 630px)
{
header, content
{
padding-left: 4%;
padding-right: 4%;
}
h1
{
font-size: 5em;
}
h2
{
font-size: 1.4em;
}
}
</style>
</head>
<body>
<header>
<h1>
UH OH
</h1>
<h2>
THIS ISN'T WHAT YOU<br />
WERE EXPECTING!
</h2>
<hr />
</header>
<content>
<h3>
Where's <?php print_r($shortHost); ?>?
</h3>
<p>
Double check the URL in your address bar, I'll wait...
</p>
<h3>
This is a rogue wireless access point
</h3>
<p>
You might have done it consciously thinking you were picking up some free Wi-Fi or your device might have done it
accidentally. Most devices remember networks they've previously connected to and continue to look for them well
after they're gone. But how did that get
you here?
</p>
<h3>
WILSON!!!
</h3>
<p>
Let's imagine you once connected to an unprotected access point called "WILSON". <em>Your phone or tablet
or laptop is now wandering around screaming "WILSON", "WILSON", where are you
"WILSON"?!</em> The access point you're now connected to heard that and responded with "I'm WILSON" and
now here you are.
</p>
<h3>
Cookies
</h3>
<p>
Now that you're connected, <em>the device could monitor all your unencrypted traffic</em>; read any passwords you
send, store the responses from websites you visit and grab any cookies along the way.
<?php
if(empty($_COOKIE))
{
echo 'As it turns out, your browser didn\'t send any cookies with this request but it could all so easily have
been a different situation. ';
}
else
{
echo 'In fact here are your cookie names and values for ', $shortHost;
// ToDo: Ignore the GA cookies, there's not much of interest there
echo ":</p><div><ol>";
foreach ($_COOKIE as $name => $value)
{
echo sprintf(
'<li>%s: <span>%s</span></li>',
htmlspecialchars($name),
htmlspecialchars($value)
);
}
echo "</ol></div><p>";
}
?>
Often these cookies will contain enough information for an attacker to hijack your session and impersonate you;
it's the equivalent of just handing over your phone or PC whilst you're already logged in.
</p>
<h3>
Insecure websites put you at risk
</h3>
<p>
It's <em>websites that do not implement proper transport
layer protection that put you at risk.</em> You requested this site over HTTP and it sent the cookies you see
above in an insecure fashion which, depending on their purpose, can be rather bad. That is the website's fault.
</p>
<h3>
Don't trust Wi-Fi hotspots
</h3>
<p>
You could just as easily have been served the actual
page you requested and if not loaded securely it could have been monitored or manipulated by the access point you
are presently connected to. <em>An attacker could be harvesting your info and you would be none the wiser.</em>
</p>
<h3>
But don't worry...
</h3>
<p>
Fortunately this is a friendly rogue access point. No personal data has been collected and you've learnt
something new about Wi-Fi and website security. Have a nice day!
</p>
<content>
</body>
</html>
<?php
function logRequest($requestedUri, $userAgent)
{
$handle = fopen(LOG_LOCATION, 'a');
// Skip logging if unable to write to log
if (!$handle)
return;
$logRow = array(
date('Y-m-d H:i:s'),
$requestedUri,
$_SERVER["REMOTE_HOST"],
$_SERVER["HTTP_ACCEPT"],
$userAgent
);
fwrite($handle, implode('|', $logRow) . "\n");
fclose($handle);
}
?>