import json
import base64

def ajouter_marqueur(a, b):
    # Basic example: concatenate strings a and b with a marker '|'
    marked_string = f"{a}|{b}"
    return marked_string

def encrypt(plaintext, password):
    if len(plaintext) == 0:
        return ""
    v = str_to_longs(plaintext.encode('utf-8'))
    if len(v) <= 1:
        v.append(0)
    k = str_to_longs(password[:16].encode('utf-8'))
    n = len(v)
    z = v[n - 1]
    y = v[0]
    delta = -0x658C6C4C
    mx = 0
    q = 6 + 52 // n
    sum = 0

    while q > 0:
        sum += delta
        e = (sum >> 2) & 3
        for p in range(n):
            y = v[(p + 1) % n]
            mx = (z >> 5 ^ (y << 2)) + (y >> 3 ^ (z << 4)) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z)
            z = (v[p] + mx) & 0xffffffff
            v[p] = z
        q -= 1

    ciphertext = longs_to_str(v)

    return base64.b64encode(ciphertext.encode('utf-8')).decode('utf-8')

def decrypt(ciphertext, password):
    if len(ciphertext) == 0:
        return ""
    v = str_to_longs(base64.b64decode(ciphertext))
    k = str_to_longs(password[:16].encode('utf-8'))
    n = len(v)
    z = v[n - 1]
    y = v[0]
    delta = -0x658C6C4C
    mx = 0
    q = 6 + 52 // n
    sum = q * delta

    while sum != 0:
        e = (sum >> 2) & 3
        for p in range(n - 1, -1, -1):
            z = v[p - 1] if p > 0 else v[n - 1]
            mx = (z >> 5 ^ (y << 2)) + (y >> 3 ^ (z << 4)) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z)
            y = (v[p] - mx) & 0xffffffff
            v[p] = y
        sum -= delta

    plaintext = longs_to_str(v)
    plaintext = plaintext.rstrip('\x00')

    return plaintext

def str_to_longs(data):
    l = []
    for i in range(0, len(data), 4):
        a = data[i] if i < len(data) else 0
        b = (data[i + 1] << 8) if i + 1 < len(data) else 0
        c = (data[i + 2] << 16) if i + 2 < len(data) else 0
        d = (data[i + 3] << 24) if i + 3 < len(data) else 0
        l.append(a + b + c + d)
    return l

def longs_to_str(l):
    s = ''
    for num in l:
        s += chr(num & 0xFF)
        s += chr((num >> 8) & 0xFF)
        s += chr((num >> 16) & 0xFF)
        s += chr((num >> 24) & 0xFF)
    return s



def decrypt_and_parse_file(input_filepath, password):
    try:
        with open(input_filepath, 'r') as file:
            ciphertext = file.read()
            plaintext = decrypt(ciphertext, password)
            decrypted_json = plaintext.split("}")[0] + "}"
            json_data = json.loads(decrypted_json)
        return json_data
    except FileNotFoundError:
        print("File not found.")
        return None

def print_json_data(filtered_info):
    print(filtered_info)

# Contoh penggunaan
input_filepath = input("Enter the rez file path: ")
password = "@technore24 2022"

json_data = decrypt_and_parse_file(input_filepath, password)
if json_data:
    filtered_info = "========================\nInfo: ENZO SNIFFER PROJECT\nTelegram: @XDecrytorId\n========================\n"
    for key, value in json_data.items():
        filtered_info += f"[</>] [{key}] : {value}\n"
    filtered_info += "========================\n"
    print_json_data(filtered_info)
else:
    print("Failed to decrypt and parse the file.")