Skip to content

Commit 4025709

Browse files
committed
Added some security restrictions to the server.
1 parent f3714f9 commit 4025709

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

main.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Description: Main file for the LockDown project
22
import os
33
from flask import Flask, render_template, request, redirect, url_for
4+
from werkzeug.exceptions import Forbidden
45
from modules.config import readAppConfig, updateAppConfig, loadLanguageFiles, tryLoad
56
import sys
67

@@ -12,6 +13,14 @@
1213
author = tryLoad("app_author")
1314
port = tryLoad("app_port")
1415

16+
restricted_routes = ["/set_language", "/reset_everything", "/set_port", "/"] # Add the routes you want to restrict
17+
18+
19+
@app.before_request
20+
def restrict_access():
21+
if request.path in restricted_routes and request.remote_addr != "127.0.0.1":
22+
raise Forbidden("Access to this route is limited to localhost.")
23+
1524

1625
def restart_server():
1726
"""Restarts the current Python script."""

screenloc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from PyQt5 import uic, QtCore, QtWidgets
2-
import cryptography.fernet
32
import requests
43
import platform
54
import socket
@@ -25,6 +24,7 @@ def save_new_client():
2524
# Generate a key for the client
2625

2726

27+
2828
def report_client_to_server(client_token):
2929
# Get the IP address, Mac address, Username, CPU Info, Memory Info, Disk Info, OS Info
3030
try:

0 commit comments

Comments
 (0)