# Decompiled with PyLingual (https://pylingual.io)
# Internal filename: Src\Support.py
# Bytecode version: 3.9.0beta5 (3425)
# Source timestamp: 1970-01-01 00:00:00 UTC (0)

import pytz
import random
import requests
import wmi
import base64
import uuid
import time
from datetime import datetime, timezone
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.fernet import Fernet
combined_pem = b'-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCypV4nZLqX5733\n11ePNz9MjJltfkaPOF79kUVqMcJ+/x7k85omgihRQnaLYLkIZhCk5WCU2Q5BxSwm\nGupWbrBLMKSRROTjNxhs28Sj7W04YiPn23Mqq3GQlrpn9tLUyE4rxHy81YE53EPt\nJDwFlfEkq5TVWZcQ1uM63y9X812w1d5420lp4Y3CCNdzEKyboBGY3gpyl51JkP/w\n+a3MaJ+Jo2TD8FwuZrNeXlWqMOHoAXRME0gfV26kB90N4GliItOerXBjbwYwI/bD\ncs8S0f9318HnasxRg3M0lCp7MLNfNfbMO3lwuJK07X4gUvkLnWSI4WTQlDI8haDf\nUqC7LczXAgMBAAECggEAKqmpYZkBorNaP6zyoSYdfMd7AJYOfbeFn+KohCLcAv4k\nP6MZZibhP/6yVrjDl4jgYrDQrttjNzvCPlthKUEH4vz74CFm1AhdUent/QP/eF6f\nmohi6YbF+TS10Yw1b1Fisbsb2vDWCp5arnBf0SmszAgZ5BWgKQpYe7+/C6736fnS\nR9KxXbSpTJijimgfiew/nEknZ2zSqVaWRW3KfcxSmBCgcH3dE/+HgrC7pleIqLMv\n127nzUIQMnq2YbOSN5zCdVDmhB/XYKTdlRXQ3tf8iCVk9ErAYeSsQHE0ikA7HH+Y\nZHXNnHEh5mg1B6QKopfkBBpnn9DC4wup8IEbqyLciQKBgQDzThXRepFEQarNehaL\nzMt/0YRtR/A+Vxen52unrDAtXMziZDL9u+1p03UP/HNpIiYFAAZ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mXENbjOt8vV/NdsNXeeNtJaeGNwgjXcxCsm6ARmN4KcpedSZD/8PmtzGif\niaNkw/BcLmazXl5VqjDh6AF0TBNIH1dupAfdDeBpYiLTnq1wY28GMCP2w3LPEtH/\nd9fB52rMUYNzNJQqezCzXzX2zDt5cLiStO1+IFL5C51kiOFk0JQyPIWg31Kguy3M\n1wIDAQAB\n-----END PUBLIC KEY-----\n'
private_key = serialization.load_pem_private_key(combined_pem, password=None, backend=None)
public_key = private_key.public_key()
symmetric_key = Fernet.generate_key()
cipher_suite = Fernet(symmetric_key)

def get_windows_uuid():
    c = wmi.WMI()
    id_pc = None
    for system in c.Win32_ComputerSystemProduct():
        id_pc = system.UUID
        break
    mac = uuid.getnode()
    mac_string = ''.join((('%012X' % mac)[i:i + 2] for i in range(0, 12, 2)))
    return id_pc + '-' + mac_string

def base64_encode_dict(input_dict):
    dict_str = str(input_dict)
    encoded_str = base64.b64encode(dict_str.encode('utf-8')).decode('utf-8')
    return encoded_str

def base64_decode_dict(encoded_str):
    decoded_str = base64.b64decode(encoded_str.encode('utf-8')).decode('utf-8')
    decoded_dict = eval(decoded_str)
    return decoded_dict

def generate_license_key(expiration_date, public_key):
    unique_id = get_windows_uuid()
    license_info = f'{unique_id}|{expiration_date}|checksum'
    encrypted_license_info = cipher_suite.encrypt(license_info.encode())
    encrypted_symmetric_key = public_key.encrypt(symmetric_key, padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None))
    license_key = {'encrypted_license_info': encrypted_license_info, 'encrypted_symmetric_key': encrypted_symmetric_key}
    return base64_encode_dict(license_key)

def get_timestamp():
    try:
        response = requests.get('http://worldtimeapi.org/api/ip')
        data = response.json()
        return int(data['unixtime'])
    except:
        return int(time.time())

def validate_license_key(license_key):
    license_key = base64_decode_dict(license_key)
    decrypted_symmetric_key = private_key.decrypt(license_key['encrypted_symmetric_key'], padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None))
    cipher_suite_decrypted = Fernet(decrypted_symmetric_key)
    decrypted_license_info = cipher_suite_decrypted.decrypt(license_key['encrypted_license_info']).decode()
    unique_id, expiration_date_str, checksum = decrypted_license_info.split('|')
    expiration_date = datetime.strptime(expiration_date_str, '%Y-%m-%d')
    expiration_date_timestamp = expiration_date.timestamp()
    unix_timestamp = get_timestamp()
    timestamp_datetime = datetime.fromtimestamp(unix_timestamp).timestamp()
    print(unique_id)
    if unique_id != get_windows_uuid():
        return (False, 'Invalid license key')
    if timestamp_datetime > expiration_date_timestamp:
        return (False, 'License expired')
    return (True, expiration_date_str)

def GetTimestamp():
    gmt_time = datetime.now(timezone.utc)
    gmt_timestamp = gmt_time.timestamp()
    return int(gmt_timestamp * 1000)

def get_time():
    gmt_time = datetime.now(timezone.utc)
    gmt_timestamp = gmt_time.timestamp()
    return int(gmt_timestamp)

def generate_random_string(e=10):
    return ''.join((random.choice('abcdefghijklmnopqrstuvwxyz0123456789') for _ in range(e)))

def GetTime(timestamp=None):
    if timestamp is None:
        gmt = pytz.timezone('GMT')
        current_time = datetime.now(gmt)
    else:
        current_time = datetime.utcfromtimestamp(timestamp)
    formatted_time = current_time.strftime('%H:%M:%S')
    return formatted_time

def GetReplyId(e, timeStamp):
    return f'{e}-{random.randint(100000000, 999999999)}-{timeStamp}'

def get_current_datetime_string(format='%Y-%m-%d %H:%M:%S'):
    return datetime.now().strftime(format)