import base64
import hashlib
import sys
import tempfile
import subprocess
import os
from Crypto.Cipher import AES

# ==========================
# FUSELOCK LOADER
# ==========================

HARDCODED_KEY = b"my-very-secret-key"  # 16/24/32 bytes for AES-128/192/256

class Anubis:
    def __init__(self, key):
        self.bs = AES.block_size
        self.key = hashlib.sha256(key).digest()

    def decrypt(self, enc):
        enc = base64.b64decode(enc)
        iv = enc[:AES.block_size]
        cipher = AES.new(self.key, AES.MODE_CBC, iv)
        return self._unpad(cipher.decrypt(enc[AES.block_size:])).decode('utf-8')

    @staticmethod
    def _unpad(s):
        return s[:-ord(s[-1:])]

def run(encrypted_blocks):
    """Decrypt multiple encrypted blocks and execute in memory."""
    an = Anubis(HARDCODED_KEY)
    src = ""

    for block in encrypted_blocks:
        src += an.decrypt(block) + "\n"

    # Execute without writing to disk using exec in a new namespace
    namespace = {}
    exec(src, namespace)


# Example usage for encrypted code blocks
if __name__ == "__main__":
    test_blocks = [
        # list of encrypted strings goes here
    ]
    run(test_blocks)
