mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
feature: random keys upon build
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
import yaml
|
import yaml
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import random
|
||||||
|
|
||||||
|
logger = logging.getLogger("Config")
|
||||||
|
|
||||||
|
|
||||||
CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")
|
CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")
|
||||||
|
|
||||||
@@ -10,8 +14,10 @@ class Config(object):
|
|||||||
self.ShowCommandOutput: bool = False
|
self.ShowCommandOutput: bool = False
|
||||||
self.debug: bool = False
|
self.debug: bool = False
|
||||||
|
|
||||||
self.xor_key: int = 0x31
|
# Default keys
|
||||||
self.xor_key2: bytes = b"\x31\x32"
|
self.xor_key: int = 0x42
|
||||||
|
self.xor_key2: bytes = b"\x13\x37"
|
||||||
|
|
||||||
self.data_fixups = None
|
self.data_fixups = None
|
||||||
self.data_fixup_entries = None
|
self.data_fixup_entries = None
|
||||||
|
|
||||||
@@ -35,6 +41,19 @@ class Config(object):
|
|||||||
self.data["server"] = { "server": server }
|
self.data["server"] = { "server": server }
|
||||||
print("Using ENV: server={}, overwriting all others from config.yaml".format(
|
print("Using ENV: server={}, overwriting all others from config.yaml".format(
|
||||||
server))
|
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):
|
def get(self, value):
|
||||||
return self.data.get(value, "")
|
return self.data.get(value, "")
|
||||||
|
|||||||
Reference in New Issue
Block a user