da
Doxygen to Wiki / Build Doxygen and publish to Wiki (push) Failing after 1m0s

This commit is contained in:
2025-08-15 21:06:31 -07:00
parent 387c694efe
commit 69184c7cb8
16 changed files with 444 additions and 64 deletions
+28 -7
View File
@@ -1,18 +1,38 @@
"""
@file utils/encryption.py
@brief String encryption utilities for OMG-Fuscator.
@details Provides the StringEncryptor used by the obfuscation pipeline to transform
string literals into runtime-decrypted expressions, making static analysis
significantly harder.
"""
import base64
import hashlib
import random
from typing import Tuple
class StringEncryptor:
"""
@brief Encrypts strings for obfuscation using layered XOR and Base85 encoding.
@details Produces both an encoded payload and Python code that reconstructs
the keys at runtime without embedding raw key bytes.
"""
def __init__(self, primary_key: bytes, secondary_key: bytes, salt: bytes):
"""
@brief Initialize encryptor keys.
@param primary_key Primary XOR key bytes.
@param secondary_key Secondary XOR key bytes.
@param salt Salt bytes used to derive a per-string modifier.
"""
self.primary_key = primary_key
self.secondary_key = secondary_key
self.salt = salt
def hide_byte(self, b: int) -> str:
"""
Obfuscates a single byte as a random arithmetic or bitwise expression.
Used in the string encryption code to hide key bytes.
@brief Obfuscate a single key byte into an arithmetic/bitwise expression.
@param b Input byte value in range [0, 255].
@return Python expression string that evaluates to the original byte at runtime.
"""
pattern = random.randint(1, 5)
if pattern == 1:
@@ -41,11 +61,12 @@ class StringEncryptor:
def encrypt_string(self, s: str) -> Tuple[str, str, str]:
"""
Encrypts a string with a multi-layer XOR scheme
and base85-encodes the result. Returns:
- encoded string,
- the code snippet that re-creates the keys in Python,
- the hex digest for the 'modifier'.
@brief Encrypt a string with layered XOR and Base85 encoding.
@param s UTF-8 string to encrypt.
@return Tuple[str, str, str]:
- encoded: Base85 text of the encrypted payload
- key_setup: Python code that reconstructs keys at runtime
- modifier_hex: Hex string for the per-string modifier
"""
data = s.encode('utf-8')
modifier = hashlib.sha256(self.salt + data).digest()[:8]