security: enforce pre-parse payload limit and stronger api key diversity

Agent-Logs-Url: https://github.com/Stalin-143/Keylogger/sessions/cef34b0e-605b-4ab9-8da6-2559d1dd4529

Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-19 04:50:08 +00:00
committed by GitHub
parent e938f21e92
commit 6d9a9d65a6
+12 -6
View File
@@ -25,12 +25,6 @@ BANNER = r"""
Github: https://github.com/Stalin-143 Github: https://github.com/Stalin-143
""" """
app = Flask(__name__)
# Set a secure secret key for session management
app.secret_key = os.getenv('FLASK_SECRET_KEY', secrets.token_hex(32))
# Global configuration
CONFIG = { CONFIG = {
'log_file_path': 'logs/keylog.txt', 'log_file_path': 'logs/keylog.txt',
'username': 'admin', 'username': 'admin',
@@ -42,6 +36,12 @@ MIN_PASSWORD_LENGTH = 12
MIN_API_KEY_LENGTH = 24 MIN_API_KEY_LENGTH = 24
MIN_API_KEY_UNIQUE_CHARS = 8 MIN_API_KEY_UNIQUE_CHARS = 8
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = MAX_LOG_PAYLOAD_BYTES
# Set a secure secret key for session management
app.secret_key = os.getenv('FLASK_SECRET_KEY', secrets.token_hex(32))
def check_auth(username, password): def check_auth(username, password):
""" """
@@ -135,6 +135,12 @@ def has_sufficient_key_entropy(value):
return False return False
if len(set(value)) < MIN_API_KEY_UNIQUE_CHARS: if len(set(value)) < MIN_API_KEY_UNIQUE_CHARS:
return False return False
has_upper = any(char.isupper() for char in value)
has_lower = any(char.islower() for char in value)
has_digit = any(char.isdigit() for char in value)
has_special = any(char in string.punctuation for char in value)
if sum([has_upper, has_lower, has_digit, has_special]) < 3:
return False
return True return True