mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
feature: 2-byte xor key
This commit is contained in:
@@ -11,6 +11,7 @@ class Config(object):
|
||||
self.debug: bool = False
|
||||
|
||||
self.xor_key: int = 0x31
|
||||
self.xor_key2: bytes = b"\x31\x32"
|
||||
self.data_fixups = None
|
||||
self.data_fixup_entries = None
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Multibyte XOR (untested)
|
||||
// Need: key, key_len
|
||||
for ( int i = 0; i < {{PAYLOAD_LEN}}; i++ ) {
|
||||
dest[i] = supermega_payload[i] ^ key[i % key_len];
|
||||
}
|
||||
// Multibyte XOR
|
||||
char *key = "{{XOR_KEY2}}";
|
||||
for ( int i = 0; i < {{PAYLOAD_LEN}}; i++ ) {
|
||||
dest[i] = supermega_payload[i] ^ key[i % 2];
|
||||
}
|
||||
|
||||
@@ -176,3 +176,8 @@ def ui_string_decode(data):
|
||||
return "(utf16) " + data.decode("utf-16le")
|
||||
else:
|
||||
return "(utf8) " + data.decode("utf-8")
|
||||
|
||||
|
||||
def ascii_to_hex_bytes(ascii_bytes):
|
||||
hex_escaped = ''.join(f'\\x{byte:02x}' for byte in ascii_bytes)
|
||||
return hex_escaped
|
||||
|
||||
@@ -23,6 +23,7 @@ PATH_WEB_PROJECT = "projects/"
|
||||
class DecoderStyle(Enum):
|
||||
PLAIN_1 = "plain_1"
|
||||
XOR_1 = "xor_1"
|
||||
XOR_2 = "xor_2"
|
||||
|
||||
|
||||
class PayloadLocation(Enum):
|
||||
|
||||
@@ -46,5 +46,12 @@ def encode_payload(payload: bytes, decoder_style: DecoderStyle) -> bytes:
|
||||
logger.info("---[ XOR payload with key 0x{:X}".format(xor_key))
|
||||
xored = bytes([byte ^ xor_key for byte in payload])
|
||||
return xored
|
||||
elif decoder_style == DecoderStyle.XOR_2:
|
||||
xor_key = config.xor_key2
|
||||
logger.info("---[ XOR2 payload with key {}".format(xor_key))
|
||||
xored = bytearray(payload)
|
||||
for i in range(len(xored)):
|
||||
xored[i] ^= xor_key[i % 2]
|
||||
return xored
|
||||
else:
|
||||
raise Exception("Unknown decoder style")
|
||||
|
||||
@@ -34,6 +34,7 @@ def create_c_from_template(settings: Settings, payload_len: int):
|
||||
plugin_decoder = Template(plugin_decoder).render({
|
||||
'PAYLOAD_LEN': payload_len,
|
||||
'XOR_KEY': config.xor_key,
|
||||
'XOR_KEY2': ascii_to_hex_bytes(config.xor_key2),
|
||||
})
|
||||
|
||||
# Choose correct template
|
||||
|
||||
@@ -59,6 +59,8 @@ def main():
|
||||
settings.decoder_style = DecoderStyle.PLAIN_1
|
||||
elif args.decoder == "xor_1":
|
||||
settings.decoder_style = DecoderStyle.XOR_1
|
||||
elif args.decoder == "xor_2":
|
||||
settings.decoder_style = DecoderStyle.XOR_2
|
||||
if args.inject:
|
||||
if args.carrier_invoke == "eop":
|
||||
settings.carrier_invoke_style = CarrierInvokeStyle.ChangeEntryPoint
|
||||
|
||||
Reference in New Issue
Block a user