Spaces:
Paused
Paused
j49_c commited on
Commit ·
18ecad3
1
Parent(s): 379a445
Added frontend source protection and backend security headers
Browse files- admin.html +13 -0
- app.py +8 -0
- index.html +13 -0
- login.html +18 -0
admin.html
CHANGED
|
@@ -487,6 +487,19 @@
|
|
| 487 |
document.getElementById('msg').innerHTML = '<span style="color:var(--success)">SYNC COMPLETE.</span>';
|
| 488 |
}
|
| 489 |
document.addEventListener('DOMContentLoaded', refreshAll);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
</script>
|
| 491 |
</body>
|
| 492 |
|
|
|
|
| 487 |
document.getElementById('msg').innerHTML = '<span style="color:var(--success)">SYNC COMPLETE.</span>';
|
| 488 |
}
|
| 489 |
document.addEventListener('DOMContentLoaded', refreshAll);
|
| 490 |
+
|
| 491 |
+
// --- SECURITY PROTOCOL: ANTI-INSPECTION ---
|
| 492 |
+
document.addEventListener('contextmenu', e => e.preventDefault());
|
| 493 |
+
document.onkeydown = function (e) {
|
| 494 |
+
if (e.keyCode == 123) return false;
|
| 495 |
+
if (e.ctrlKey && e.shiftKey && (e.keyCode == 'I'.charCodeAt(0) || e.keyCode == 'J'.charCodeAt(0) || e.keyCode == 'C'.charCodeAt(0))) return false;
|
| 496 |
+
if (e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) return false;
|
| 497 |
+
};
|
| 498 |
+
setInterval(() => {
|
| 499 |
+
const start = performance.now();
|
| 500 |
+
debugger;
|
| 501 |
+
if (performance.now() - start > 100) window.location.href = "about:blank";
|
| 502 |
+
}, 500);
|
| 503 |
</script>
|
| 504 |
</body>
|
| 505 |
|
app.py
CHANGED
|
@@ -35,6 +35,14 @@ app.config.update(
|
|
| 35 |
PERMANENT_SESSION_LIFETIME=604800 # 1 week
|
| 36 |
)
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
ADMIN_USERNAME = os.environ.get("ADMIN_USER", "moh777")
|
| 39 |
# If the environment variable is not set, we use the default password,
|
| 40 |
# but it's better to store a hash or use a secret key.
|
|
|
|
| 35 |
PERMANENT_SESSION_LIFETIME=604800 # 1 week
|
| 36 |
)
|
| 37 |
|
| 38 |
+
@app.after_request
|
| 39 |
+
def add_security_headers(response):
|
| 40 |
+
response.headers['X-Content-Type-Options'] = 'nosniff'
|
| 41 |
+
response.headers['X-Frame-Options'] = 'SAMEORIGIN'
|
| 42 |
+
response.headers['X-XSS-Protection'] = '1; mode=block'
|
| 43 |
+
response.headers['Strict-Transport-Security'] = 'max-age=31536000; includeSubDomains'
|
| 44 |
+
return response
|
| 45 |
+
|
| 46 |
ADMIN_USERNAME = os.environ.get("ADMIN_USER", "moh777")
|
| 47 |
# If the environment variable is not set, we use the default password,
|
| 48 |
# but it's better to store a hash or use a secret key.
|
index.html
CHANGED
|
@@ -934,6 +934,19 @@
|
|
| 934 |
});
|
| 935 |
|
| 936 |
document.addEventListener('DOMContentLoaded', () => { loadServers(); loadPythonHost(); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 937 |
</script>
|
| 938 |
</body>
|
| 939 |
|
|
|
|
| 934 |
});
|
| 935 |
|
| 936 |
document.addEventListener('DOMContentLoaded', () => { loadServers(); loadPythonHost(); });
|
| 937 |
+
|
| 938 |
+
// --- SECURITY PROTOCOL: ANTI-INSPECTION ---
|
| 939 |
+
document.addEventListener('contextmenu', e => e.preventDefault());
|
| 940 |
+
document.onkeydown = function (e) {
|
| 941 |
+
if (e.keyCode == 123) return false;
|
| 942 |
+
if (e.ctrlKey && e.shiftKey && (e.keyCode == 'I'.charCodeAt(0) || e.keyCode == 'J'.charCodeAt(0) || e.keyCode == 'C'.charCodeAt(0))) return false;
|
| 943 |
+
if (e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) return false;
|
| 944 |
+
};
|
| 945 |
+
setInterval(() => {
|
| 946 |
+
const start = performance.now();
|
| 947 |
+
debugger;
|
| 948 |
+
if (performance.now() - start > 100) window.location.href = "about:blank";
|
| 949 |
+
}, 500);
|
| 950 |
</script>
|
| 951 |
</body>
|
| 952 |
|
login.html
CHANGED
|
@@ -155,6 +155,7 @@
|
|
| 155 |
margin-bottom: 8px;
|
| 156 |
background: linear-gradient(180deg, #FFFFFF 0%, #A1A1A6 100%);
|
| 157 |
-webkit-background-clip: text;
|
|
|
|
| 158 |
-webkit-text-fill-color: transparent;
|
| 159 |
}
|
| 160 |
|
|
@@ -337,6 +338,23 @@
|
|
| 337 |
}
|
| 338 |
}
|
| 339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
// Hit enter to login
|
| 341 |
document.addEventListener('keypress', (e) => {
|
| 342 |
if (e.key === 'Enter') doLogin();
|
|
|
|
| 155 |
margin-bottom: 8px;
|
| 156 |
background: linear-gradient(180deg, #FFFFFF 0%, #A1A1A6 100%);
|
| 157 |
-webkit-background-clip: text;
|
| 158 |
+
background-clip: text;
|
| 159 |
-webkit-text-fill-color: transparent;
|
| 160 |
}
|
| 161 |
|
|
|
|
| 338 |
}
|
| 339 |
}
|
| 340 |
|
| 341 |
+
// --- SECURITY PROTOCOL: ANTI-INSPECTION ---
|
| 342 |
+
document.addEventListener('contextmenu', e => e.preventDefault());
|
| 343 |
+
document.onkeydown = function (e) {
|
| 344 |
+
if (e.keyCode == 123) return false; // F12
|
| 345 |
+
if (e.ctrlKey && e.shiftKey && (e.keyCode == 'I'.charCodeAt(0) || e.keyCode == 'J'.charCodeAt(0) || e.keyCode == 'C'.charCodeAt(0))) return false;
|
| 346 |
+
if (e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) return false; // View Source
|
| 347 |
+
};
|
| 348 |
+
|
| 349 |
+
// Debugger trap to hinder devtools
|
| 350 |
+
setInterval(() => {
|
| 351 |
+
const start = performance.now();
|
| 352 |
+
debugger;
|
| 353 |
+
if (performance.now() - start > 100) {
|
| 354 |
+
window.location.href = "about:blank";
|
| 355 |
+
}
|
| 356 |
+
}, 500);
|
| 357 |
+
|
| 358 |
// Hit enter to login
|
| 359 |
document.addEventListener('keypress', (e) => {
|
| 360 |
if (e.key === 'Enter') doLogin();
|