mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
refactor: better key handling yet again
This commit is contained in:
@@ -14,19 +14,13 @@ class Config(object):
|
||||
self.ShowCommandOutput: bool = False
|
||||
self.debug: bool = False
|
||||
|
||||
self.data_fixups = None
|
||||
self.data_fixup_entries = None
|
||||
|
||||
# Default keys
|
||||
self.xor_key: int = 0x42
|
||||
self.xor_key2: bytes = b"\x13\x37"
|
||||
|
||||
self.data_fixups = None
|
||||
self.data_fixup_entries = None
|
||||
|
||||
|
||||
def getConfigPath(self):
|
||||
return CONFIG_FILE
|
||||
|
||||
def getConfig(self):
|
||||
return self.data
|
||||
|
||||
def load(self):
|
||||
with open(CONFIG_FILE) as jsonfile:
|
||||
@@ -41,20 +35,32 @@ class Config(object):
|
||||
self.data["server"] = { "server": server }
|
||||
print("Using ENV: server={}, overwriting all others from config.yaml".format(
|
||||
server))
|
||||
|
||||
|
||||
|
||||
def make_encryption_keys(self):
|
||||
# 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)
|
||||
self.xor_key2 = os.urandom(2)
|
||||
else:
|
||||
self.xor_key = self.data["xor_key2"]
|
||||
logger.info("XOR Key: {} XOR2 Key: {}".format(
|
||||
self.xor_key2 = self.data["xor_key2"]
|
||||
|
||||
logger.info("-( Payload encryption keys: XOR: {} XOR2: {}".format(
|
||||
self.xor_key, self.xor_key2
|
||||
))
|
||||
|
||||
|
||||
def getConfigPath(self):
|
||||
return CONFIG_FILE
|
||||
|
||||
|
||||
def getConfig(self):
|
||||
return self.data
|
||||
|
||||
def get(self, value):
|
||||
return self.data.get(value, "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user