feature: random keys upon build

This commit is contained in:
Dobin
2024-05-29 08:35:37 +01:00
parent 8ed47409a2
commit 93b9ea8805
+21 -2
View File
@@ -1,6 +1,10 @@
import yaml
import os
import logging
import random
logger = logging.getLogger("Config")
CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")
@@ -10,8 +14,10 @@ class Config(object):
self.ShowCommandOutput: bool = False
self.debug: bool = False
self.xor_key: int = 0x31
self.xor_key2: bytes = b"\x31\x32"
# Default keys
self.xor_key: int = 0x42
self.xor_key2: bytes = b"\x13\x37"
self.data_fixups = None
self.data_fixup_entries = None
@@ -35,6 +41,19 @@ class Config(object):
self.data["server"] = { "server": server }
print("Using ENV: server={}, overwriting all others from config.yaml".format(
server))
# keys
if self.data["xor_key"] == "":
self.xor_key = random.randint(0, 255)
else:
self.xor_key = self.data["xor_key"]
if self.data["xor_key2"] == "":
self.xor_key = os.urandom(2)
else:
self.xor_key = self.data["xor_key2"]
logger.info("XOR Key: {} XOR2 Key: {}".format(
self.xor_key, self.xor_key2
))
def get(self, value):
return self.data.get(value, "")