-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.html
505 lines (447 loc) · 19.4 KB
/
index.html
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
<head>
<meta name="viewport" content="user-scalable=no, width=device-width">
<meta charset="utf-8">
<title>inAppBrowser.com</title>
</head>
<h1>InAppBrowser.com</h1>
<p class="subtitle">Check if an in-app browser is injecting JavaScript code</p>
<p id="high-level-summary">
Some iOS and Android apps make use of a custom in-app browser (<a target="_blank" href="https://krausefx.com/blog/announcing-inappbrowsercom-see-what-javascript-commands-get-executed-in-an-in-app-browser">full details</a>). This causes potential security
and privacy risks to the user.
</p>
<div class="summaries" id="clean-summary">
<p>✅ This tool couldn't detect any JavaScript injections. However, this doesn't mean there were no code injections. As of iOS 14.3, Apple introduced a new way of running JavaScript code in an "Isolated World", making it impossible for a website to verify
what code is being executed.</p>
<p>If you opened this website in iOS Safari, or it's being rendered by SFSafariViewController, you are on the safe side when it comes to injecting JavaScript code.</p>
<p>Please read the Disclaimer below, as well as the <a href="https://krausefx.com/blog/announcing-inappbrowsercom-see-what-javascript-commands-get-executed-in-an-in-app-browser" target="_blank">full explanation</a></p>
</div>
<div class="summaries" id="medium-summary">
<p>🕵️♂️ Javascript injection detected. This does not necessarily imply malicious behaviour.</p>
However, this doesn't mean there were no other code injections. As of iOS 14.3, Apple introduced a new way of running JavaScript code in an "Isolated World", making it impossible for a website to verify what code is being executed.</p>
<p>Please read the Disclaimer below, as well as the <a href="https://krausefx.com/blog/announcing-inappbrowsercom-see-what-javascript-commands-get-executed-in-an-in-app-browser" target="_blank">full explanation</a></p>
</div>
<div class="summaries" id="dangerous-summary">
<p>🚨 JavaScript injection detected, with some potentially dangerous commands.</p>
<p>There might be additional JavaScript commands executed using "Isolated World" JavaScript, which can't be detected on this page.</p>
<p>Please read the Disclaimer below, as well as the <a href="https://krausefx.com/blog/announcing-inappbrowsercom-see-what-javascript-commands-get-executed-in-an-in-app-browser" target="_blank">full explanation</a></p>
</div>
<div class="summaries" id="third-party-browser">
<p>✅ It looks like you're opening this page on a third party iOS/Android browser.</p>
<p>It doesn't really make sense to show the JavaScript commands executed, as the browser needs to run JavaScript commands to offer their features, like a password manager, the print dialog, search on page, and media management</p>
<p>This page will still show the commands detected by this page, however some mobile browsers already leverage the "Isolated World" JavaScript, which can't be detected by this page</p>
<p>Please read the Disclaimer below, as well as the <a href="https://krausefx.com/blog/announcing-inappbrowsercom-see-what-javascript-commands-get-executed-in-an-in-app-browser" target="_blank">full explanation</a></p>
<p><b>Please note that there aren't any meaningful conclusions on the output below for browser apps.</b></p>
<br />
</div>
<ul id="all-comments">
</ul>
<hr style="margin-top: 0px; margin-bottom: 15px" />
<div class="summary-note" id="top-summary-1">
The summary above shows a list of things the in-app browser did when you opened this website. However, there might be other things happening as well. The raw output below should be carefully studied to better understand what's happening.
</div>
<ol id="resultsList">
<h5>Detected JavaScript Commands:</h5>
</ol>
<div class="summary-note">
<p><b>Disclaimer</b>: This tool works by overriding the most common JavaScript functions, however the host app may still inject other commands. As of iOS 14.3, Apple introduced <a href="https://developer.apple.com/documentation/webkit/wkcontentworld"
target="_blank">a new way of running JavaScript code</a> in an "Isolated World", making it impossible for a website to verify what code is being executed. Also this tool cannot detect other app tracking that may occur, such as custom gesture recognition,
screenshot detection, or tracking of web request events.</p>
<p><b>Important:</b> Before jumping to any conclusions, please <a href="https://krausefx.com/blog/announcing-inappbrowsercom-see-what-javascript-commands-get-executed-in-an-in-app-browser" target="_blank">read this post</a>.</p>
</div>
<footer>
<hr />
<p>
<a target="_blank" href="https://krausefx.com/blog/announcing-inappbrowsercom-see-what-javascript-commands-get-executed-in-an-in-app-browser">
About this tool
</a> |
<a target="_blank" href="https://github.com/KrauseFx/InAppBrowser.com">
Open on GitHub
</a> | <a target="_blank" href="https://twitter.com/KrauseFx">@KrauseFx</a></p>
</footer>
<script type="text/javascript">
// Fetch the nodes first, before we override the `document` methods
const resultsList = document.getElementById("resultsList")
const cleanSummary = document.getElementById("clean-summary")
const mediumSummary = document.getElementById("medium-summary")
const dangerousSummary = document.getElementById("dangerous-summary")
const elementsToHideOnNonClean = [
cleanSummary,
]
// Check the user agent string if the current browser is a third party browser
// Currently detecting Brave, Chrome, DuckDuckGo, Firefox, Edge and the Google search app
let isThirdPartyBrowser = navigator.userAgent.includes("CriOS") || navigator.userAgent.includes("EdgiOS") || navigator.userAgent.includes("FxiOS") || navigator.userAgent.includes("GSA") || navigator.userAgent.includes("DuckDuckGo") || navigator.brave;
// Additionally check for Android third party user agents
if (navigator.userAgent.includes("Android") && (navigator.userAgent.includes("Chrome") || navigator.userAgent.includes("Firefox") || navigator.userAgent.includes("EdgA"))) {
isThirdPartyBrowser = true
}
if (isThirdPartyBrowser) {
document.getElementById("third-party-browser").style.display = "block"
dangerousSummary.style.display = "none"
mediumSummary.style.display = "none"
cleanSummary.style.display = "none"
} else {
document.getElementById("third-party-browser").style.display = "none"
}
const elementsToShowOnNonClean = [
resultsList,
document.getElementById("top-summary-1"),
]
for (const element of elementsToShowOnNonClean) {
element.style.display = "none"
}
const allComments = document.getElementById("all-comments")
const summary = document.getElementById("summary")
const denyList = [
"globalThis",
"Object",
"log",
"parseInt",
"Array",
"Promise",
"Reflect",
"location",
"onmouseout",
"onmouseover",
"onpointerout",
"onmousemove",
"onmouseleave",
"onpointerrawupdate",
"onpointerover",
"onpointerenter",
"onpointermove",
"onmouseenter",
"onpointerleave",
"onscroll",
"onpointerdown",
"ongotpointercapture",
"onpointercancel",
"onlostpointercapture",
"defaultView",
"toString"
]
const potentiallyDangerous = {
"createElement('script'": "Injects external JavaScript code",
"http://": "Uses an unencrypted URL, making the whole page insecure",
"addEventListener('selectionchange'": "Monitors all text selections on websites",
"addEventListener('click'": "Monitors all taps happening on websites, including taps on all buttons & links",
"addEventListener('keypress'": "Monitors all keyboard inputs on websites",
"addEventListener('keyup'": "Monitors all keyboard inputs on websites",
"addEventListener('keydown'": "Monitors all keyboard inputs on websites",
"createElement('a'": "Creates a new link on website",
"elementFromPoint": "Gets information about an element based on coordinates, which can be used to track which elements the user clicks on",
"querySelector('input[type=password]": "Accesses all password fields: This could either mean the app has a password manager, or the app reads or enters passwords on the page",
"addEventListener('message'": "Monitors all JavaScript messages, this can be used for many things, including communication with iframes",
"addEventListener('focusin'": "Monitors when the user focuses on an element, like a textfield",
}
const neutralNotes = {
"createElement('style')": "Adds CSS code, allows app to customize appearance of website",
"addEventListener('focus'": "Monitors whenever you focus a text field or other element",
"addEventListener('blur'": "Monitors whenever you remove the focus from an element",
"querySelectorAll('img'": "Accesses all images on the page",
}
const goodNotes = {
"querySelector('head > meta[property=\"og:site_name\"]')": "Gets the website's name",
"querySelector('head > meta[name=\"title\"]')": "Gets the website title",
"querySelectorAll('head > link[rel~=\"icon\"]')": "Gets the website's favicon(s)",
"querySelector('head > title')": "Gets the website title",
"getElementsByTagName('meta')": "Gets the page's metadata (like share text), this is unrelated to Meta the company",
}
let lastLevel = -1;
let existingEntries = [];
function appendEvent(str, level) {
let classesToUse = ""
let comments = ""
let allCommentToPush = null;
// Iterate over potentiallyDangerous, and see if any of them are included in the `str`
for (const [key, value] of Object.entries(potentiallyDangerous)) {
if (str.indexOf(key) > -1) {
classesToUse += " danger "
comments += `<p class='bad-comment'>^ ${value}</p>`
allCommentToPush = `<li class='bad-in-comments'>${value}</li>`
cleanSummary.style.display = "none"
mediumSummary.style.display = "none"
if (!isThirdPartyBrowser) {
dangerousSummary.style.display = "block"
}
}
}
// Iterate over neutralNotes, and see if any of them are included in the `str`
for (const [key, value] of Object.entries(neutralNotes)) {
if (str.indexOf(key) > -1) {
comments += `<p class='neutral-comment'>^ ${value}</p>`
allCommentToPush = `<li class='neutral-in-comments'>${value}</li>`
}
}
// Iterate over goodNotes, and see if any of them are included in the `str`
for (const [key, value] of Object.entries(goodNotes)) {
if (str.indexOf(key) > -1) {
comments += `<p class='good-comment'>^ ${value}</p>`
allCommentToPush = `<li class='good-in-comments'>${value}</li>`
}
}
if (allCommentToPush) {
if (!existingEntries.includes(allCommentToPush)) {
allComments.innerHTML += allCommentToPush
}
existingEntries.push(allCommentToPush)
}
if (level < lastLevel) {
classesToUse += " reducedLevel "
}
lastLevel = level;
resultsList.innerHTML += "<li class='" + classesToUse + "'>" + str + comments + "</li>"
for (const element of elementsToShowOnNonClean) {
element.style.display = "block"
}
if (cleanSummary.style.display !== "none") {
for (const element of elementsToHideOnNonClean) {
element.style.display = "none"
}
if (!isThirdPartyBrowser) {
mediumSummary.style.display = "block"
}
}
}
// Function to help surround the value by ' if it's a string
function renderParam(param) {
if (typeof param === "string") {
return "'" + param.replace("'", "\\'") + "'"
} else {
return param
}
}
function overrideFunction(node, prop, level) {
if (typeof node[prop] !== "function") {
return;
}
try {
const original = node[prop]
node[prop] = function() {
let str = prop;
if (arguments) {
str = `${node.constructor.name}.${prop}(`
str += Object.values(arguments).map((arg) => renderParam(arg)).join(", ")
str += ")"
}
// `str` would be something like
// "HTMLDocument.querySelector('head > meta['property="og:site_name"]')"
appendEvent(str, level)
const fakeObj = original.apply(node, arguments)
if (fakeObj) {
investigate(fakeObj, level + 1);
const handler1 = {
get(target, prop, receiver) {
// For some reason, prop is always a string it seems
const spaces = " ".repeat(level * 4)
if (Math.abs(parseInt(prop)) > 0 || prop == "0") {
appendEvent(spaces + fakeObj + "[" + renderParam(prop) + "]", level + 1)
} else {
appendEvent(spaces + fakeObj + "." + prop + "", level + 1)
}
return target[prop]
},
set(target, prop, value, receiver) {
const spaces = " ".repeat(level * 4)
if (Math.abs(parseInt(prop)) > 0 || prop == "0") {
appendEvent(spaces + fakeObj + "[" + renderParam(prop) + "] = '" + value + "'", level + 1)
} else {
appendEvent(spaces + fakeObj + "." + prop + " = " + renderParam(value), level + 1)
}
return target[prop] = value
}
}
return new Proxy(fakeObj, handler1);
}
return fakeObj;
}
console.log("Sucessfully overwrote " + prop + " on " + node)
} catch (e) {
console.error(e);
}
}
function investigate(node, level) {
for (var prop in node) {
if (denyList.includes(prop)) {
continue;
}
value = node[prop]
overrideFunction(node, prop, level)
}
}
investigate(document, 1);
const originalAddEventListener = window.addEventListener;
const originalRemoveEventListener = window.removeEventListener;
window.addEventListener = function(...args) {
const str = `window.addEventListener('${args[0]}', ${args.slice(1).map((arg) => renderParam(arg)).join(", ")}`
appendEvent(str, 1)
return originalAddEventListener.apply(window, args)
}
window.removeEventListener = function() {
appendEvent("window.removeEventListener('" + arguments[0] + "')", 1)
return originalRemoveEventListener.apply(window, arguments)
}
</script>
<style type="text/css">
* {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
color: #353535;
}
.bad-comment {
font-size: 0.8em;
color: rgb(175, 0, 0);
text-align: right;
margin-bottom: 5px;
width: 100%;
margin-top: 0px;
font-family: 'Courier New', Courier, monospace;
padding: 5px;
}
.neutral-comment {
font-size: 0.8em;
color: rgb(0, 0, 175);
text-align: right;
margin-bottom: 5px;
font-weight: bold;
width: 100%;
margin-top: 0px;
font-family: 'Courier New', Courier, monospace;
padding: 5px;
}
.good-comment {
font-size: 0.8em;
color: rgb(0, 187, 0);
text-align: right;
margin-bottom: 5px;
width: 100%;
font-weight: bold;
margin-top: 0px;
font-family: 'Courier New', Courier, monospace;
padding: 5px;
}
.reducedLevel {
margin-top: 30px;
}
body {
background-color: #f0f0f0;
max-width: 600px;
padding-bottom: 20px;
}
/* On larger screens only */
@media only screen and (min-width: 600px) {
body {
margin: 40px;
}
}
h1 {
font-size: 1.5em;
}
a {
color: #0085bd !important;
}
#resultsList h5 {
margin-top: 10px;
padding-top: 0px;
}
#resultsList {
margin-left: -5px;
margin-right: -5px;
overflow-y: auto;
max-width: cacl(100% - 10px);
white-space: nowrap;
background-color: rgba(168, 247, 251, 0.4);
border: 1px solid #ccc;
padding-left: 10px;
padding-right: 35px;
padding-top: 0px;
list-style: none;
}
#resultsList>li {
margin-bottom: 0.5em;
font-size: 0.8em;
font-family: monospace;
}
#author {
margin-top: -10px;
}
footer a {
text-decoration: none;
}
footer p {
text-align: center;
font-size: 0.8em;
margin-top: -15px;
margin-bottom: 5px;
color: #bbb !important;
}
.danger {
color: rgba(255, 0, 0, 1);
font-weight: bold;
}
hr {
border: 0;
height: 1px;
margin-top: 25px;
margin-bottom: 25px;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(40, 40, 40, 0.3), rgba(0, 0, 0, 0));
background-color: transparent !important;
}
.summaries {
padding: 15px;
margin-left: -5px;
margin-right: -5px;
padding-top: 3px;
padding-bottom: 3px;
}
#third-party-browser {
background-color: rgba(72, 255, 0, 0.3);
}
#clean-summary {
background-color: rgba(255, 255, 0, 0.3);
}
#medium-summary {
display: none;
background-color: rgba(255, 255, 0, 0.3);
}
#dangerous-summary {
display: none;
background-color: rgba(255, 0, 0, 0.3);
}
#all-comments {
padding-left: 10px;
margin-top: 10px;
list-style: inside;
line-height: 1.3em;
font-size: 0.8em;
}
#all-comments>li {
text-align: left !important;
padding-left: 0px;
font-family: 'Courier New', Courier, monospace !important;
font-weight: bold;
}
.bad-in-comments {
color: rgb(175, 0, 0);
}
.neutral-in-comments {
color: rgb(0, 0, 175);
}
.good-in-comments {
color: rgb(0, 150, 0);
}
.subtitle {
font-style: italic;
font-size: 0.9em;
color: #666;
margin-top: -10px;
}
.summary-note {
text-align: left;
color: #666;
font-size: 0.9em;
}
#high-level-summary {
color: #555;
margin-left: 20px;
margin-right: 10px;
}
</style>