-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
783 lines (753 loc) · 34.9 KB
/
index.php
File metadata and controls
783 lines (753 loc) · 34.9 KB
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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
<?php
//Copyright (c) 2015-2021 Divested Computing Group
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Lesser General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License
//along with this program. If not, see <https://www.gnu.org/licenses/>.
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
error_reporting(E_ERROR | E_PARSE);
putenv('GDFONTPATH=' . realpath('.') . '/captcha_fonts/');
include 'settings.php';
include 'utils.php';
//START OF VARIABLES
$page = str_replace(":", ":", str_replace(" ", " ", noHTML($_GET["p"])));
if ($page == '') {
$page = $defaultPage;
}
$eid = noHTML($_GET["eid"]);
$theme = $defaultTheme;
if(strlen($_COOKIE["theme"]) >= 1) {
$theme = str_replace(".", ".", noHTML($_COOKIE["theme"]));
}
session_start();
$_SESSION['csrfToken'] = bin2hex(random_bytes(32));
//END OF VARIABLES
//START OF PAGE
print(cTop());
if($loggedIn) {
print(cNavBar());
$landscape = explode("L: ", $page)[1];
if($page == 'Dashboard') {
print(cHeader("Dashboard", "Brief Overview of Shadow") . cDashboard());
} else if($page == 'About') {
print(cHeader("About", "About this project") . cAbout());
} else if($page == 'LM: New Landscape') {
print(cHeader("Landscape", "Creating new landscape") . cNewLandScape());
} else if(startsWith($page, "L: ") && in_array($landscape, getLandscapes())) {
print(cHeader("Landscape", "Viewing " . $landscape) . cAnalytics($landscape));
} else if ($page == 'AM: My Account') {
print(cHeader("Accounts", "Managing your account") . cMyAccount());
} else if ($page == 'AM: New Account') {
print(cHeader("Accounts", "Creating new account") . cNewAccount());
} else if ($page == 'AM: Manage Accounts') {
print(cHeader("Accounts", "Managing accounts"));
} else {
print(cHeader("You've taken a wrong turn mate", "Error " + $eid));
}
} else {
print(cHeader("Login", "You'll need to login first") . cLogin());
}
print(cBottom());
//END OF PAGE
//START OF SITE FUNCTIONS
function cTop() {
return "
<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"utf-8\">
<meta name=\"robots\" content=\"noindex\">
<meta name=\"theme-color\" content=\"#3D4348\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
<meta name=\"robots\" content=\"noindex, nofollow, noarchive, nosnippet, noodp, notranslate, noimageindex\">
<meta name=\"author\" content=\"Divested Computing Group\">
<title>" . $GLOBALS['page'] . " || Shadow Administration</title>
<link href=\"assets/img/favicon-round.png\" rel=\"shortcut icon\">
<link href=\"assets/css/themes/" . $GLOBALS['theme'] . "\" rel=\"stylesheet\" type=\"text/css\" id=\"theme\">
</head>
<body>
";
}
function cNavbar() {
$landscapesDropDown = '';
foreach(getLandscapes() as $landscape) {
$landscapesDropDown = $landscapesDropDown . "<li><a href=\"index.php?p=L:%20" . $landscape . "\">" . $landscape . "</a></li>";
}
$themesDropDown = '';
foreach(getThemes() as $themeS) {
$suffix = "";
if($themeS == $GLOBALS['theme']) {
$suffix = " - Current";
}
$themesDropDown = $themesDropDown . "<li><a href=\"javascript:changeTheme('" . $themeS . "')\">" . $themeS . $suffix . "</a></li>";
}
return "
<script type=\"text/javascript\">
function changeTheme(theme) {
document.cookie = \"theme=\" + theme;
document.getElementById('theme').href = \"assets/css/themes/\" + theme;
}
function logout() {
var req = new XMLHttpRequest();
req.open(\"POST\", \"manage.php\", true);
req.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
req.send(\"a=logout\" + \"&ct=" . $_SESSION['csrfToken'] . "\");
setTimeout(function() {window.location.href = \"index.php\"}, 500);
}
</script>
<nav class=\"navbar navbar-default\">
<div class=\"container-fluid\">
<div class=\"navbar-header\">
<button type=\"button\" class=\"navbar-toggle collapsed\" data-toggle=\"collapse\" data-target=\"#main-navbar-collapse-1\" aria-expanded=\"false\">
<span class=\"sr-only\">Toggle navigation</span>
<span class=\"icon-bar\"></span>
<span class=\"icon-bar\"></span>
<span class=\"icon-bar\"></span>
</button>
<a class=\"navbar-brand\" href=\"index.php?p=Dashboard\">Shadow Administration Panel</a>
</div>
<div class=\"collapse navbar-collapse\" id=\"main-navbar-collapse-1\">
<ul class=\"nav navbar-nav navbar-right\">
<li><a href=\"index.php?p=Dashboard\">Dashboard</a></li>
<li class=\"dropdown\">
<a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Landscapes <b class=\"caret\"></b></a>
<ul class=\"dropdown-menu\">
<li><a href=\"index.php?p=LM:%20New%20Landscape\">New Landscape</a></li>
<li role=\"separator\" class=\"divider\"></li>
" . $landscapesDropDown . "
</ul>
</li>
<li class=\"dropdown\">
<a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Accounts <b class=\"caret\"></b></a>
<ul class=\"dropdown-menu\">
<li><a href=\"index.php?p=AM:%20My%20Account\">My Account</a></li>
<li role=\"separator\" class=\"divider\"></li>
<li><a href=\"index.php?p=AM:%20New%20Account\">New Account</a></li>
<li><a href=\"index.php?p=AM:%20Manage%20Accounts\">Manage Accounts</a></li>
</ul>
</li>
<li class=\"dropdown\">
<a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Themes <b class=\"caret\"></b></a>
<ul class=\"dropdown-menu\">
" . $themesDropDown . "
</ul>
</li>
<li><a href=\"index.php?p=About\">About</a></li>
<li><a href=\"javascript:logout()\">Logout</a></li>
</ul>
</div>
</div>
</nav>
";
}
function cHeader($title, $subtitle) {
return "
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"page-header\">
<h1>" . $title . " <small>" . $subtitle . "</small></h1>
</div>
</div>
</div>
</div>
";
}
function cLogin() {
include 'captcha.php';
$captchaField = "<input type=\"hidden\" class=\"form-control\" id=\"txtCaptcha\" placeholder=\"Captcha\" autocomplete=\"off\">";
if($GLOBALS['captchaEnabled']) {
$_SESSION['authSaltOne'] = bin2hex(random_bytes(32));
$_SESSION['authSaltTwo'] = bin2hex(random_bytes(32));
$captchaField = "
<div class=\"form-group\">
<label for=\"txtCaptcha\">Captcha</label>
<br><img for=\"txtCaptcha\" src=\"" . getImageBase64(getCaptchaText()) . "\"/><br><br>
<input type=\"text\" class=\"form-control\" id=\"txtCaptcha\" placeholder=\"Captcha\" autocomplete=\"off\">
</div>";
}
$fake = "|";
for($counter = 0; $counter < rand(6, 12); $counter ++) {
$fake = $fake . bin2hex(random_bytes(32)) . "|";
}
$localJS = " function rot(s, i) {
return s.replace(/[a-zA-Z]/g, function (c) {
return String.fromCharCode((c <= \"Z\" ? 90 : 122) >= (c = c.charCodeAt(0) + i) ? c : c - 26);
});
}
function login() {
var username = document.getElementById('txtUsername').value;
var usernameHash = forge.md.sha512.create();
usernameHash.update(username + \"" . $GLOBALS['accountSalt'] . "\");
var usernameOut = forge.util.encode64(usernameHash.digest().toHex());
usernameOut = usernameOut.substring(0, usernameOut.length-1);
usernameHash = forge.md.sha512.create();
usernameHash.update(usernameOut + \"" . $_SESSION['authSaltOne'] . "\");
usernameOut = forge.util.encode64(usernameHash.digest().toHex());
usernameOut = usernameOut.substring(0, usernameOut.length-1);
usernameOut = rot(usernameOut, 13);
var password = document.getElementById('txtPassword').value;
var passwordHash = forge.md.sha512.create();
passwordHash.update(password + \"" . $GLOBALS['accountSalt'] . "\");
var passwordOut = forge.util.encode64(passwordHash.digest().toHex());
passwordOut = passwordOut.substring(0, passwordOut.length-1);
passwordHash = forge.md.sha512.create();
passwordHash.update(passwordOut + \"" . $_SESSION['authSaltTwo'] . "\");
passwordOut = forge.util.encode64(passwordHash.digest().toHex());
passwordOut = passwordOut.substring(0, passwordOut.length-1);
passwordOut = rot(passwordOut, 13);
var tfa = document.getElementById('txtTfa').value;
var tfaOut = tfa;
if(tfaOut.length == 0) {
tfaOut = \"DISABLED\";
}
var captcha = document.getElementById('txtCaptcha').value;
var captchaOut = captcha;
if(captchaOut.length == 0) {
captchaOut = \"DISABLED\";
}
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
setTimeout(function() {window.location.href = \"index.php\"}, 500);
}
};
req.open(\"POST\", \"manage.php\", true);
req.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
req.send(\"a=login&username=\" + usernameOut + \"&password=\" + passwordOut + \"&captcha=\" + captchaOut + \"&tfa=\" + tfaOut + \"&ct=" . $_SESSION['csrfToken'] . "\");
}";
return "
<script type=\"text/javascript\">
" . $localJS . "
</script>
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-md-4 col-md-offset-4\">
<form role=\"form\" name=\"frmLogin\" method=\"post\" action=\"javascript:login()\">
<div class=\"form-group\">
<label for=\"txtUsername\">Username</label>
<input type=\"username\" class=\"form-control\" id=\"txtUsername\" placeholder=\"Username\" autocomplete=\"off\" autofocus>
</div>
<div class=\"form-group\">
<label for=\"txtPassword\">Password</label>
<input type=\"password\" class=\"form-control\" id=\"txtPassword\" placeholder=\"Password\" autocomplete=\"off\">
</div>
<div class=\"form-group\">
<label for=\"txtTfa\">Two-Factor Authentication</label>
<input type=\"password\" class=\"form-control\" id=\"txtTfa\" placeholder=\"Two-Factor Authentication\" autocomplete=\"off\">
</div>
" . $captchaField . "
<button type=\"submit\" class=\"btn btn-default\">Submit</button>
</form>
</div>
</div>
</div>
</div>
";
}
function cDashboard() {
return "
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"panel panel-info\">
<div class=\"panel-heading\">
<h3 class=\"panel-title\">Project Status</h3>
</div>
<div class=\"panel-body\">
<div class=\"progress progress-striped active\">
<div class=\"progress-bar progress-bar-warning\" style=\"width: " . (35.5/53)*100 . "%\"></div>
</div>
<p>
 [COMPLETE - 2015-10-06] - Create a basic interface<br>
 [COMPLETE - 2015-10-06] - Create a login/logout mechanism<br>
 [COMPLETE - 2015-10-06] - Track the current page<br>
 [COMPLETE - 2015-10-06] - Track the time stamp of the request<br>
 [COMPLETE - 2015-10-06] - Track the user's IP address<br>
 [COMPLETE - 2015-10-06] - Track the user's user agent<br>
 [COMPLETE - 2016-01-15] - Generate identicons for tracking IDs<br>
 [COMPLETE - 2016-01-15] - Make landscapes dynamic<br>
 [COMPLETE - 2016-01-15] - Retrieve country from IP<br>
 [COMPLETE - 2016-01-15] - Retrieve OS and browser from user agent<br>
 [COMPLETE - 2016-01-15] - Use passive and active fingerprinting over cookies<br>
 [COMPLETE - 2016-01-16] - Implement ability to add and delete landsacpes<br>
 [COMPLETE - 2016-01-16] - Implement ability to clear landscape data<br>
 [COMPLETE - 2016-01-16] - Implement ability to rename landscapes<br>
 [COMPLETE - 2016-01-16] - Implement dynamic theme changing<br>
 [COMPLETE - 2016-01-16] - Implement theme support<br>
 [COMPLETE - 2016-01-17] - Create a test page<br>
 [COMPLETE - 2016-01-17] - Display code snippets<br>
 [COMPLETE - 2016-01-17] - Implement account creation<br>
 [COMPLETE - 2016-01-17] - Implement multiple user support<br>
 [COMPLETE - 2016-01-17] - Make accounts dynamic<br>
 [COMPLETE - 2016-01-18] - XSS prevention<br>
 [COMPLETE - 2016-01-23] - Authentication token renewal on request<br>
 [COMPLETE - 2016-01-23] - Create an Android web wrapper app<br>
 [COMPLETE - 2016-01-23] - Frequently clear valid auth tokens<br>
 [COMPLETE - 2016-01-26] - Implement captchas on login page<br>
 [COMPLETE - 2016-01-27] - Implement basic 2FA<br>
 [COMPLETE - 2016-01-27] - Implement global settings<br>
 [COMPLETE - 2016-01-28] - Track the true referrer<br>
 [COMPLETE - 2016-03-24] - Change from GET to POST requests<br>
 [COMPLETE - 2016-03-24] - Create an about page<br>
 [COMPLETE - 2016-03-24] - Retrieve city/state/lat/lon from IP<br>
 [COMPLETE - 2016-03-24] - Implement landscape auto refresh<br>
 [COMPLETE - 2016-03-25] - Improve security of login page<br>
 [COMPLETE - 2016-03-26] - Implement basic CSRF protection<br>
 [PARTIAL] - Implement account management<br>
 [NOT STARTED] - Allow account creation when no accounts exist without login<br>
 [NOT STARTED] - Calculate landscape statistics<br>
 [NOT STARTED] - Create an actual Android app<br>
 [NOT STARTED] - Implement account permissions<br>
 [NOT STARTED] - Implement advanced 2FA<br>
 [NOT STARTED] - Implement global settings page<br>
 [NOT STARTED] - Implement rate limiting<br>
 [NOT STARTED] - Implement user map<br>
 [NOT STARTED] - Implement user searching<br>
 [NOT STARTED] - Intelligently clear valid auth tokens<br>
 [NOT STARTED] - Offload more actions to client<br>
 [NOT STARTED] - Perform code cleanup<br>
 [NOT STARTED] - Perform code optimization<br>
 [NOT STARTED] - Track if an adblocker is in use<br>
 [NOT STARTED] - Track interaction level<br>
 [NOT STARTED] - Track time spent<br>
 [NOT STARTED] - Use a real database backend<br>
</p>
</div>
</div>
</div>
</div>
</div>
";
}
function cNewAccount() {
$status = noHTML($_GET["s"]);
if(strlen($status) >= 1) {
$errorMessage = "
<div class=\"alert alert-dismissible alert-info\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>
<h4>Result</h4>
<p>" . $status . "</p>
</div>
";
}
return "
<script type=\"text/javascript\">
function createAccount() {
var username = document.getElementById('txtUsername').value;
var password = document.getElementById('txtPassword').value;
var passwordConfirm = document.getElementById('txtPasswordConfirm').value;
if(password != passwordConfirm) {
alert(\"Passwords are not the same!\");
} else {
var usernameHash = forge.md.sha512.create();
usernameHash.update(username + \"" . $GLOBALS['accountSalt'] . "\");
var usernameOut = forge.util.encode64(usernameHash.digest().toHex());
usernameOut = usernameOut.substring(0, usernameOut.length-1);
var passwordHash = forge.md.sha512.create();
passwordHash.update(password + \"" . $GLOBALS['accountSalt'] . "\");
var passwordOut = forge.util.encode64(passwordHash.digest().toHex());
passwordOut = passwordOut.substring(0, passwordOut.length-1);
var req = new XMLHttpRequest();
req.open(\"POST\", \"manage.php\", true);
req.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
req.send(\"a=createAccount&usernameRaw=\" + username + \"&username=\" + usernameOut + \"&password=\" + passwordOut + \"&ct=" . $_SESSION['csrfToken'] . "\");
setTimeout(function() {window.location.href = \"index.php?p=AM:%20New%20Account&s=\" + req.responseText}, 500);
}
}
</script>
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-md-4 col-md-offset-4\">
" . $errorMessage . "
<form role=\"form\" name=\"frmLogin\" method=\"post\" action=\"javascript:createAccount();\">
<div class=\"form-group\">
<label for=\"txtUsername\">Username</label>
<input type=\"username\" class=\"form-control\" id=\"txtUsername\" placeholder=\"Username\" autocomplete=\"off\" autofocus>
</div>
<div class=\"form-group\">
<label for=\"txtPassword\">Password</label>
<input type=\"password\" class=\"form-control\" id=\"txtPassword\" placeholder=\"Password\" autocomplete=\"off\">
</div>
<div class=\"form-group\">
<label for=\"txtPassword\">Confirm Password</label>
<input type=\"password\" class=\"form-control\" id=\"txtPasswordConfirm\" placeholder=\"Password\" autocomplete=\"off\">
</div>
<button type=\"submit\" class=\"btn btn-default\">Submit</button>
</form>
</div>
</div>
</div>
</div>
";
}
function cMyAccount() {
$status = noHTML($_POST["s"]);
if(strlen($status) >= 1) {
$statusMessage = "
<div class=\"alert alert-dismissible alert-info\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>
<h4>Result</h4>
<p>" . $status . "</p>
</div>
";
}
return "
<script type=\"text/javascript\">
</script>
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-md-4 col-md-offset-4\">
" . $statusMessage . "
<h3>Current Password</h3>
<input type=\"password\" class=\"form-control\" id=\"txtPassword\" placeholder=\"Current Password\" autocomplete=\"off\" autofocus>
</div>
</div>
<div class=\"row\">
<div class=\"col-sm-6 col-md-4\">
<h3>Change Password</h3>
<form role=\"form\" name=\"frmChangePassword\" method=\"post\" action=\"javascript:changePassword()\">
<div class=\"form-group\">
<label for=\"txtChangePasswordNewPassword\">New Password</label>
<input type=\"password\" class=\"form-control\" id=\"txtChangePasswordNewPassword\" placeholder=\"New Password\" autocomplete=\"off\">
</div>
<div class=\"form-group\">
<label for=\"txtChangePasswordNewPasswordConfirm\">Confirm New Password</label>
<input type=\"password\" class=\"form-control\" id=\"txtChangePasswordNewPasswordConfirm\" placeholder=\"Confirm New Password\" autocomplete=\"off\">
</div>
<button type=\"submit\" class=\"btn btn-default\">Change Password</button>
</form>
</div>
<div class=\"col-sm-6 col-md-4\">
<h3>Enable 2FA</h3>
<form role=\"form\" name=\"frmEnabledTfa\" method=\"post\" action=\"javascript:enableTfa()\">
<div class=\"form-group\">
<label for=\"txtEnableTfaToken\">2FA Token</label>
<input type=\"text\" class=\"form-control\" id=\"txtEnableTfaToken\" placeholder=\"2FA Token\" autocomplete=\"off\">
</div>
<button type=\"submit\" class=\"btn btn-default\">Enable 2FA</button>
</form>
</div>
<div class=\"col-sm-6 col-md-4\">
<h3>Disable 2FA</h3>
<form role=\"form\" name=\"frmDisableTfa\" method=\"post\" action=\"javascript:disableTfa()\">
<div class=\"form-group\">
<label for=\"txtDisableTfaToken\">Current 2FA Token</label>
<input type=\"text\" class=\"form-control\" id=\"txtDisableTfaToken\" placeholder=\"Current 2FA Token\" autocomplete=\"off\">
</div>
<button type=\"submit\" class=\"btn btn-default\">Disable 2FA</button>
</form>
</div>
</div>
</div>
</div>
";
}
function cNewLandscape() {
return "
<script type=\"text/javascript\">
function newLandscape() {
var landscape = document.getElementById('txtLandscape').value
if(landscape != null && landscape.length >= 1) {
var req = new XMLHttpRequest();
req.open(\"POST\", \"manage.php\", true);
req.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
req.send(\"a=createLandscape&l=\" + landscape + \"&ct=" . $_SESSION['csrfToken'] . "\");
setTimeout(function() {window.location.href = \"index.php?p=L:%20\" + landscape}, 500);
}
}
</script>
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-md-4 col-md-offset-4\">
<form role=\"form\" name=\"frmNewLandscape\" method=\"post\" action=\"javascript:newLandscape();\">
<div class=\"form-group\">
<label for=\"txtLandscape\">Landscape Name</label>
<input type=\"text\" class=\"form-control\" id=\"txtLandscape\" placeholder=\"Landscape Name\" autocomplete=\"off\" autofocus>
</div>
<div class=\"form-group\">
<label for=\"txtUniqueViewerGoal\">Unique Viewer Goal</label>
<input type=\"number\"class=\"form-control\" id=\"txtUniqueViewerGoal\" placeholder=\"Unique Viewer Goal\" autocomplete=\"off\" disabled>
</div>
<div class=\"form-group\">
<label for=\"txtTotalViewsGoal\">Total Views Goal</label>
<input type=\"number\"class=\"form-control\" id=\"txtTotalViewsGoal\" placeholder=\"Total Views Goal\" autocomplete=\"off\" disabled>
</div>
<div class=\"form-group\">
<label for=\"txtCustomFieldsCount\">Custom Fields Count</label>
<input type=\"number\"class=\"form-control\" id=\"txtCustomFieldsCount\" placeholder=\"0\" autocomplete=\"off\" disabled>
</div>
<button type=\"submit\" class=\"btn btn-default\">Create</button>
</form>
</div>
</div>
</div>
</div>
";
}
function cAnalytics($landscape) {
$views = countLines($GLOBALS['landscapePath'] . $landscape . "/Analytics-Raw.csv");
$users = countLines($GLOBALS['landscapePath'] . $landscape . "/Analytics-Users.log");
$clientsDB = file($GLOBALS['landscapePath'] . $landscape . "/Analytics-Raw.csv", FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
$clientsDB = array_reverse($clientsDB);
date_default_timezone_set($GLOBALS['defaultTimeZone']);
$counter = 0;
$crawlers = 0;
$personal = 0;
foreach($clientsDB as $client) {
if($counter > 250) {
break;
}
$clientInfo = explode("|", $client);
if($clientInfo[9] == 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' || $clientInfo[9] == 'Mozilla/5.0 (compatible; CloudFlare-AlwaysOnline/1.0; +http://www.cloudflare.com/always-online) AppleWebKit/534.34' || startsWith($clientInfo['5'], '204.79.180') || startsWith($clientInfo['5'], '66.102.6')) {
$crawlers++;
} else if(startsWith($clientInfo['5'], $_SERVER['REMOTE_ADDR'])) {
$personal++;
} else {
$ipLookupTitle = $clientInfo[5];
if($GLOBALS['trimIPvSix'] && strlen($clientInfo[5]) > 16) {
$ipLookupTitle = "Lookup";
}
$clients = $clients . "
<tr>
<td><canvas width=\"34\" height=\"34\" data-jdenticon-hash=\"" . $clientInfo[0] . "\" title=\"" . $clientInfo[0] . "\"></canvas></td>
<td><canvas width=\"34\" height=\"34\" data-jdenticon-hash=\"" . $clientInfo[1] . "\" title=\"" . $clientInfo[1] . "\"></canvas></td>
<td><a href=\"" . $clientInfo[2] . "\" target=\"_blank\">View</a></td>
<td>" . $clientInfo[3] . "</td>
<td>" . date('Y/m/d h:i:s A', $clientInfo[4]) . "</td>
<td><a href=\"" . $GLOBALS['ipLookupURL'] . $clientInfo[5] . "\" target=\"_blank\" >" . $ipLookupTitle . "</a></td>
<td>" . $clientInfo[6] . "</td>
<script>var parser = new UAParser();parser.setUA(\"" . $clientInfo[9] . "\");var result = parser.getResult();var os = result.os.name + \" \" + result.os.version;if(os == \"undefined undefined\"){os = \"Unknown\";}var device = result.device.vendor + \" \" + result.device.model; if(device == \"undefined undefined\"){device = \"Unknown\";}var browser = result.browser.name + \" \" + result.browser.version;if(browser == \"undefined undefined\"){browser = \"Unknown\";}document.write(\"<td title='\" + parser.getUA() + \"'>\" + browser + \"</td><td title='\" + parser.getUA() + \"'>\" + device + \"</td><td title='\" + parser.getUA() + \"'>\" + os + \"</td>\");</script>
</tr>
";
$counter++;
}
}
$autoRefresh = "false";
$autoRefreshStatus = "btn-danger";
if(strlen($_COOKIE["autoRefresh"]) >= 1) {
$autoRefresh = noHTML($_COOKIE["autoRefresh"]);
}
if($autoRefresh == "true") {
$autoRefreshStatus = "btn-success";
}
return "
<script type=\"text/javascript\">
var landscape = \"" . $landscape . "\";
if(" . $autoRefresh . ") {
autoRefresh();
}
function autoRefresh() {
setTimeout(function() {
if(document.visibilityState == \"visible\" && document.scrollingElement.scrollTop == 0) {
window.location.href = \"index.php?p=L:%20\" + landscape
}
}, 30000);
autoRefresh();
}
function toggleAutoRefresh() {
if(" . $autoRefresh . " == true)
document.cookie = \"autoRefresh=false\";
if(" . $autoRefresh . " == false)
document.cookie = \"autoRefresh=true\";
setTimeout(function() {window.location.href = \"index.php?p=L:%20\" + landscape}, 500);
}
function clearLandscape() {
if(window.confirm(\"Are you sure you want to clear this landscape?\")) {
var req = new XMLHttpRequest();
req.open(\"POST\", \"manage.php\", true);
req.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
req.send(\"a=clear&l=\" + landscape + \"&ct=" . $_SESSION['csrfToken'] . "\");
setTimeout(function() {window.location.href = \"index.php?p=L:%20\" + landscape}, 500);
}
}
function renameLandscape(){
var landscapeNew = prompt(\"What would you like to rename this landscape to?\", landscape);
if(landscapeNew != null && landscapeNew != landscape) {
var req = new XMLHttpRequest();
req.open(\"POST\", \"manage.php\", true);
req.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
req.send(\"a=rename&l=\" + landscape + \"&ln=\" + landscapeNew + \"&ct=" . $_SESSION['csrfToken'] . "\");
setTimeout(function() {window.location.href = \"index.php?p=L:%20\" + landscapeNew}, 500);
}
}
function deleteLandscape() {
if(window.confirm(\"Are you sure you want to delete this landscape?\")) {
var req = new XMLHttpRequest();
req.open(\"POST\", \"manage.php\", true);
req.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
req.send(\"a=delete&l=\" + landscape + \"&ct=" . $_SESSION['csrfToken'] . "\");
setTimeout(function() {window.location.href = \"index.php?p=Dashboard\"}, 500);
}
}
</script>
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-sm-6 col-md-4\">
<div class=\"panel panel-info\">
<div class=\"panel-heading\">
<h3 class=\"panel-title\">Popularity Contest</h3>
</div>
<div class=\"panel-body\">
Crawler Views: " . $crawlers . "<br>
Personal Views: " . $personal . "<br>
Most Popular Browser: [TODO]<br>
Most Popular Country: [TODO]<br>
Most Popular ISP: [TODO]<br>
Most Popular OS: [TODO]<br>
Most Popular Page: [TODO]
</div>
</div>
</div>
<div class=\"col-sm-6 col-md-4\">
<div class=\"panel panel-info\">
<div class=\"panel-heading\">
<h3 class=\"panel-title\">Goals</h3>
</div>
<div class=\"panel-body\">
<h4>Unique Users: " . $users . "/250</h4>
<div class=\"progress progress-striped active\">
<div class=\"progress-bar progress-bar-info\" style=\"width: " . ($users/250)*100 . "%\"></div>
</div>
<h4>Total Views: " . ($views-$crawlers-$personal) . "/1,000</h4>
<div class=\"progress progress-striped active\">
<div class=\"progress-bar progress-bar-info\" style=\"width: " . (($views-$crawlers-$personal)/1000)*100 . "%\"></div>
</div>
</div>
</div>
</div>
<div class=\"col-sm-6 col-md-4\">
<div class=\"panel panel-primary\">
<div class=\"panel-heading\">
<h3 class=\"panel-title\">Management</h3>
</div>
<div class=\"panel-body\">
<div class=\"btn-group\" role=\"group\">
<button type=\"button\" class=\"btn " . $autoRefreshStatus . "\" onclick=\"toggleAutoRefresh()\">Refresh</button>
<button type=\"button\" class=\"btn btn-primary\" data-toggle=\"collapse\" data-target=\"#tracking-code-snippets\">Code</button>
</div>
<br><br>
<div class=\"btn-group\" role=\"group\">
<button type=\"button\" class=\"btn btn-warning\" onclick=\"clearLandscape()\">Clear</button>
<button type=\"button\" class=\"btn btn-warning\" onclick=\"renameLandscape()\">Rename</button>
<button type=\"button\" class=\"btn btn-danger\" onclick=\"deleteLandscape()\">Delete</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class=\"container\">
<div class=\"row collapse\" id=\"tracking-code-snippets\">
<h2>Code Snippets</h2>
<h3>Javascript</h3>
<p><pre><code><script type=\"text/javascript\" src=\"" . $GLOBALS['baseURL'] . "assets/js/fingerprint2.min.js\"><br></script><script type=\"text/javascript\">new Fingerprint2().get(function(result, components){var atr = new XMLHttpRequest(); atr.open(\"POST\", \"" . $GLOBALS['baseURL'] . "shadow.php\", true); atr.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\"); atr.send(\"p=" . $landscape . "&fpid=\" + result + \"&ref=\" + document.referrer.split('/')[2]);});</script></code></pre></p>
<h3>Java</h3>
<p><pre><code>HttpURLConnection shadowRequest = (HttpURLConnection) new URL(\"" . $GLOBALS['baseURL'] . "shadow.php?p=" . $landscape . "&fpid=\" + UUID).openConnection();//Replace UUID with constant UUID stored locally<br>shadowRequest.setConnectTimeout(5000);<br>shadowRequest.setReadTimeout(5000);<br>shadowRequest.addRequestProperty(\"User-Agent\", \"Application/Version\");//Replace app and version with actual app and version<br>shadowRequest.connect();<br></code></pre></p>
</div>
<div class=\"row\">
<h2>Requests</h2>
<div class=\"table-responsive\">
<table class=\"table table-striped table-hover table-condensed\">
<thead>
<tr>
<td>Passive ID</td>
<td>Active ID</td>
<td>Page</td>
<td>Referrer</td>
<td>Time Stamp</td>
<td>IP Address</td>
<td>GeoIP</td>
<td>Browser</td>
<td>Device</td>
<td>Operating System</td>
</tr>
</thead>
<script src=\"assets/js/ua-parser.min.js\" type=\"text/javascript\"></script>
<script defer src=\"assets/js/jdenticon.min.js\" type=\"text/javascript\"></script>
<tbody>
" . $clients . "
</tbody>
</table>
</div>
</div>
</div>
</div>
";
}
function cAbout() {
return "
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-sm-6 col-md-4\">
<div class=\"panel panel-info\">
<div class=\"panel-heading\">
<h3 class=\"panel-title\">Project Credits</h3>
</div>
<div class=\"panel-body\">
Divested Computing Group
</div>
</div>
</div>
<div class=\"col-sm-6 col-md-4\">
<div class=\"panel panel-info\">
<div class=\"panel-heading\">
<h3 class=\"panel-title\">Apache/JS/PHP Credits</h3>
</div>
<div class=\"panel-body\">
" . cLink("Bootstrap (MIT)", "https://github.com/twbs/bootstrap", "nofollow") . "<br>" . cLink("FingerprintJS2 (MIT)", "https://github.com/fingerprintjs/fingerprintjs", "nofollow") . "<br>" . cLink("Forge (BSD-2-clause or GPL-2)", "https://github.com/digitalbazaar/forge", "nofollow") . "<br>" . cLink("Jdenticon (MIT)", "https://github.com/dmester/jdenticon", "nofollow") . "<br>" . cLink("jQuery (MIT)", "https://jquery.com", "nofollow") . "<br>" . cLink("MaxMindDB (Apache-2.0)", "https://github.com/maxmind/mod_maxminddb", "nofollow") . "<br>" . cLink("UA-Parser-JS (MIT)", "https://github.com/faisalman/ua-parser-js", "nofollow") . "
</div>
</div>
</div>
<div class=\"col-sm-6 col-md-4\">
<div class=\"panel panel-info\">
<div class=\"panel-heading\">
<h3 class=\"panel-title\">CSS/Font Credits</h3>
</div>
<div class=\"panel-body\">
" . cLink("Bootstrap (MIT)", "https://github.com/twbs/bootstrap", "nofollow") . "<br>" . cLink("Bootswatch (MIT)", "https://github.com/thomaspark/bootswatch", "nofollow") . "
</div>
</div>
</div>
</div>
</div>
</div>";
}
function cBottom() {
return "
<div class=\"container-fluid\">
<div class=\"container\">
<div class=\"row\">
<hr>
<footer>
<p>Divested Computing Group © 2015-2021</p>
</footer>
</div>
</div>
</div>
<script src=\"assets/js/jquery-3.6.4.min.js\" type=\"text/javascript\"></script>
<script src=\"assets/js/bootstrap.min.js\" type=\"text/javascript\"></script>
<script defer src=\"assets/js/forge.min.js\" type=\"text/javascript\"></script>
</body>
</html>
";
}
//END OF SITE FUNCTIONS
?>