diff --git a/apps/setup_2fa.php b/apps/setup_2fa.php index 3193e06..a4abb2f 100644 --- a/apps/setup_2fa.php +++ b/apps/setup_2fa.php @@ -24,8 +24,15 @@ if (userHasTOTP($_SESSION['username'])) { $codesecret = $totp->getSecret(); $chunk_secret = trim(chunk_split($codesecret, 8, ' ')); $APPS["setup_2fa"]["content"] = '
' . lang("scan 2fa qrcode", false) . '
' . << +.mono-chunk { + text-align: center; + font-size: 110%; + font-family: monospace; +} + -
$chunk_secret
+
$chunk_secret
diff --git a/apps/sync_mobile.php b/apps/sync_mobile.php index f354aab..87ad14d 100644 --- a/apps/sync_mobile.php +++ b/apps/sync_mobile.php @@ -52,19 +52,29 @@ if (MOBILE_ENABLED) { . lang("scan sync qrcode", false) . '' . << +.margintop-15px { + margin-top: 15px; +} +.mono-chunk { + text-align: center; + font-size: 110%; + font-family: monospace; +} + -
+
END . "" . lang("manual setup", false) . "
" - . '
' . $_SESSION['username'] . '
' + . '
' . $_SESSION['username'] . '
' . "" . <<$chunk_code
+
$chunk_code
END . "" . <<$url
+
$url
$lang_done @@ -78,19 +88,23 @@ END; $content .= "
"; if (count($activecodes) > 0) { foreach ($activecodes as $c) { - $content .= "
" . trim(chunk_split($c['code'], 5, ' ')) . "
"; + $content .= "
" . trim(chunk_split($c['code'], 5, ' ')) . "
"; } } else { $content .= "
" . lang("no active codes", false) . "
"; } $content .= "
"; $content .= << + END; $APPS["sync_mobile"]["content"] = $content; diff --git a/home.php b/home.php index d5b7f7b..16a077a 100644 --- a/home.php +++ b/home.php @@ -67,7 +67,7 @@ if (!is_empty($_GET['page'])) { } ?> - + -
+
diff --git a/mobile/index.php b/mobile/index.php index 1afb987..a6d78c5 100644 --- a/mobile/index.php +++ b/mobile/index.php @@ -97,6 +97,7 @@ switch ($VARS['action']) { if (get_account_status($username) == "NORMAL") { if (authenticate_user($username, $VARS['password'], $autherror)) { doLoginUser($username, $VARS['password']); + $_SESSION['mobile'] = true; exit(json_encode(["status" => "OK"])); } } diff --git a/required.php b/required.php index 916dde1..a252d6c 100644 --- a/required.php +++ b/required.php @@ -10,7 +10,11 @@ header('Content-Type: text/html; charset=utf-8'); // l33t $ecurity h4x header('X-Content-Type-Options: nosniff'); header('X-XSS-Protection: 1; mode=block'); -header('X-Powered-By: Late-night coding frenzies (plz send caffeine, thx)'); +header('X-Powered-By: PHP'); // no versions makes it harder to find vulns +header('X-Frame-Options: "DENY"'); +header('Referrer-Policy: "no-referrer, strict-origin-when-cross-origin"'); +$SECURE_NONCE = base64_encode(random_bytes(8)); + $session_length = 60 * 60; // 1 hour session_set_cookie_params($session_length, "/", null, false, false); @@ -18,6 +22,30 @@ session_set_cookie_params($session_length, "/", null, false, false); session_start(); // stick some cookies in it //// renew session cookie setcookie(session_name(), session_id(), time() + $session_length); + +if ($_SESSION['mobile'] === TRUE) { + header("Content-Security-Policy: " + . "default-src 'self';" + . "object-src 'none'; " + . "img-src * data:; " + . "media-src 'self'; " + . "frame-src 'none'; " + . "font-src 'self'; " + . "connect-src *; " + . "style-src 'self' 'unsafe-inline'; " + . "script-src 'self' 'unsafe-inline'"); +} else { + header("Content-Security-Policy: " + . "default-src 'self';" + . "object-src 'none'; " + . "img-src * data:; " + . "media-src 'self'; " + . "frame-src 'none'; " + . "font-src 'self'; " + . "connect-src *; " + . "style-src 'self' 'nonce-$SECURE_NONCE'; " + . "script-src 'self' 'nonce-$SECURE_NONCE'"); +} // // Composer require __DIR__ . '/vendor/autoload.php'; @@ -30,7 +58,21 @@ require __DIR__ . '/lang/messages.php'; require __DIR__ . '/lang/' . LANGUAGE . ".php"; function sendError($error) { - die("Error

" . htmlspecialchars($error) . "

"); + global $SECURE_NONCE; + die("" + . "" + . "" + . "Error" + . "" + . "

A fatal application error has occurred.

" + . "(This isn't your fault.)" + . "

Details:

" + . "

". htmlspecialchars($error) . "

"); } date_default_timezone_set(TIMEZONE); diff --git a/static/css/app.css b/static/css/app.css index f4a1902..583e814 100644 --- a/static/css/app.css +++ b/static/css/app.css @@ -9,6 +9,16 @@ font-size: 110%; } +.navbar-brand img { + height: 35px; + padding-bottom: 12px; + padding-left: 5px; +} + +.pad-75px { + height: 75px; +} + .footer { margin-top: 10em; text-align: center;