吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 324|回复: 5
收起左侧

[求助] python逆向中找到验证文件,后面该如何处理呢?

[复制链接]
backer 发表于 2024-1-16 01:12
最近一直在学习python的逆向,纯小白,刚刚在提示下找到了验证文件,不过后面不知道该如何处理呢?
比如算法,比如改成本地验证?
不知道有没有大佬给讲讲?
[Python] 纯文本查看 复制代码
import json
import hashlib
import platform
import time
import uuid
import requests
from Crypto.Random import get_random_bytes
from Crypto.Util.Padding import pad, unpad
from cryptography.fernet import Fernet
from services.config_manager import ConfigManager
from utils.helpers import *
import binascii
import base64
from Crypto.Cipher import AES

class Licence:
    SECRET_KEY = 'UjPpJ9xAVIR9eNwTz9ZBVD66Uml/Tlu8n/iDRX7cTyU='
    
    def __init__(self):
        self.config = ConfigManager('licence')
        self.base_url = self.config.get('base_url', 'https://sw.jiusuan.art/v1')

    
    def is_active(self):
        licence = self.get_licence_info()
        license_key = licence.get('license_key')
        if license_key is None or license_key == '':
            message = licence.get('message')
            return (False, message)
        device_changed = None.get_changed_data()
        if device_changed > 1:
            return (False, '设备已变更,需要重新激活')
        current_time = None()
        if licence.get('licence_expires_date', 0) < current_time:
            return (False, '许可证过期')
        return (True, '')

    
    def register(self = None, license_key = None, name = None):
        key = base64.b64decode(self.SECRET_KEY)
        url = '/activeCode/active'
        device_id = self.get_device_id()
        device_data = self.get_device_data()
        data = {
            'code': license_key,
            'device_name': name,
            'device_data': device_data,
            'mac_sn': device_id,
            'timestamp': get_current_timestamp() }
        (res, msg) = self.send_request(url, data)
        if res is None:
            return (False, f'''激活失败【{msg}】(0x50000)''')
        res_code = None.get('code', 0)
        if res_code != 200:
            res_data = res.get('data', '')
            return (False, f'''激活失败:{res_data}【{res_code}】(0x50001)''')
        res_data = None.get('data', { })
        token = res_data.get('token', '')
        token_expires_at = res_data.get('expires_at', 0)
        licence_expires_date = res_data.get('licence_expires_date', 0)
        self.create_licence(license_key, token, token_expires_at, name, device_id, licence_expires_date, **('license_key', 'token', 'token_expires_at', 'name', 'device_id', 'licence_expires_date'))
        return (True, '设备激活成功')

    
    def refresh(self):
        url = '/macToken/validateToken'
        licence = self.get_licence_info()
        license_key = licence.get('license_key')
        if license_key is None or license_key == '':
            print_log('未激活的版本')
            return False
        device_id = None.get_device_id()
        device_data = self.get_device_data()
        data = {
            'token': licence.get('token'),
            'mac_sn': device_id,
            'timestamp': get_current_timestamp(),
            'device_data': device_data }
        (res, msg) = self.send_request(url, data)
        if res is None:
            print_log(f'''续签失败【{msg}】(0x50010)''')
            return False
        res_code = None.get('code', 0)
        if res_code == 401:
            res_data = res.get('data', '')
            self.remove_licence(f'''许可证异常:{res_data}(0x40001)''')
            return False
        if None != 200:
            print_log('续签失败(0x50011)')
            return False
        res_data = None.get('data', { })
        token = res_data.get('token', '')
        token_expires_at = res_data.get('expires_at', 0)
        licence_expires_date = res_data.get('licence_expires_date', 0)
        token_expires_at = min(token_expires_at, licence_expires_date)
        self.create_licence(licence.get('license_key'), token, token_expires_at, licence_expires_date, licence.get('name'), device_id, **('license_key', 'token', 'token_expires_at', 'licence_expires_date', 'name', 'device_id'))
        current_time = get_current_timestamp()
        if token_expires_at < current_time:
            print_log('续签失败(0x50012)')
            return False
        None('续签成功')
        return True

    
    def create_licence(self, license_key, token, message = None, token_expires_at = None, name = None, device_id = ('', 0, '', None, 0), licence_expires_date = ('license_key', str, 'token', str, 'token_expires_at', int, 'name', str, 'device_id', str)):
        if device_id is None:
            device_id = self.get_device_id()
        token_expires_at = min(token_expires_at, licence_expires_date)
        key = self.SECRET_KEY
        cipher_suite = Fernet(key)
        device_data = self.get_device_data()
    # WARNING: Decompyle incomplete

    
    def remove_licence(self, message = ('',)):
        self.create_licence('', '', 0, message, **('license_key', 'token', 'token_expires_at', 'message'))

    
    def get_licence_info(self):
        self.config.reload()
        cipher_text = self.config.get('LICENCE')
        key = self.SECRET_KEY
        cipher_suite = Fernet(key)
    # WARNING: Decompyle incomplete

    
    def get_licence_info1(self):
        cipher_text = self.config.get('LICENCE')
        key = base64.b64decode(self.SECRET_KEY)
        plaintext = self.decrypt_aes256ecb(key, cipher_text).decode('utf-8')
        key = self.SECRET_KEY
        cipher_suite = Fernet(key)
    # WARNING: Decompyle incomplete

    
    def send_request(self = None, url = None, data = None, timeout = (5,)):
        key = base64.b64decode(self.SECRET_KEY)
        plaintext = json.dumps(data)
        cipher_text = self.encrypt_aes256ecb(key, plaintext).decode('utf-8')
        post_data = {
            'data': cipher_text }
        msg = ''
    # WARNING: Decompyle incomplete

    
    def get_device_id(self):
        licence_info = self.get_licence_info()
        device_id = licence_info.get('device_id')
        if device_id:
            return device_id
        device_id = None.get_device_id1()
        self.create_licence(device_id, '', '', 0, **('device_id', 'license_key', 'token', 'token_expires_at'))
        return device_id

    
    def get_device_id2():
        return Licence.get_device_id1()

    get_device_id2 = staticmethod(get_device_id2)
    
    def get_device_data():
        mac_address = ':'.join((lambda .0: [ '{:02x}'.format(uuid.getnode() >> elements & 255) for elements in .0 ])(range(0, 12, 2))[::-1])
        processor_id = platform.processor()
        architecture = platform.architecture()
        main_board_serial = Licence.get_main_board_serial()
        device_uuid = Licence.get_device_uuid()
        hard_drive_serial = Licence.get_hard_drive_serial()
        user_directory = os.path.expanduser('~')
        device_data = {
            'mac_address': mac_address,
            'processor_id': processor_id,
            'architecture': architecture,
            'main_board_serial': main_board_serial,
            'device_uuid': device_uuid,
            'hard_drive_serial': hard_drive_serial,
            'user_directory': user_directory }
        return device_data

    get_device_data = staticmethod(get_device_data)
    
    def get_changed_data(self):
        licence_info = self.get_licence_info()
        main_board_serial = Licence.get_main_board_serial()
        device_uuid = Licence.get_device_uuid()
        hard_drive_serial = Licence.get_hard_drive_serial()
        user_directory = os.path.expanduser('~')
        licence_main_board_serial = licence_info.get('main_board_serial')
        licence_hard_drive_serial = licence_info.get('hard_drive_serial')
        licence_user_directory = licence_info.get('user_directory')
        licence_device_uuid = licence_info.get('device_uuid')
        changed = 0
        if licence_main_board_serial and main_board_serial != licence_main_board_serial:
            changed += 2
        if licence_device_uuid and device_uuid != licence_device_uuid:
            changed += 2
        if licence_hard_drive_serial and hard_drive_serial != licence_hard_drive_serial:
            changed += 1
        if licence_user_directory and user_directory != licence_user_directory:
            changed += 1
        return changed

    
    def get_device_id1():
        main_board_serial = Licence.get_main_board_serial()
        serial = None
        if main_board_serial:
            serial = f'''{main_board_serial}'''
            device_uuid = Licence.get_device_uuid()
            serial = f'''{serial}-{device_uuid}'''
            hard_drive_serial = Licence.get_hard_drive_serial()
            if hard_drive_serial:
                serial = f'''{serial}-{hard_drive_serial}'''
        if serial is None or serial == '':
            mac_address = ':'.join((lambda .0: [ '{:02x}'.format(uuid.getnode() >> elements & 255) for elements in .0 ])(range(0, 12, 2))[::-1])
            processor_id = platform.processor()
            architecture = platform.architecture()
            device_uuid = Licence.get_device_uuid()
            serial = f'''{device_uuid}-{mac_address}-{processor_id}-{architecture}'''
            hard_drive_serial = Licence.get_hard_drive_serial()
            if hard_drive_serial:
                serial = f'''{hard_drive_serial}-{serial}'''
        device_info = f'''HeRmEs-#SiLenCe#-{serial}-#END#'''
        device_id = hashlib.sha256(device_info.encode()).hexdigest()
        return device_id

    get_device_id1 = staticmethod(get_device_id1)
    
    def get_main_board_serial():
        serial_number = None
    # WARNING: Decompyle incomplete

    get_main_board_serial = staticmethod(get_main_board_serial)
    
    def get_device_uuid():
        serial_number = None
    # WARNING: Decompyle incomplete

    get_device_uuid = staticmethod(get_device_uuid)
    
    def get_hard_drive_serial():
        serial_number = None
    # WARNING: Decompyle incomplete

    get_hard_drive_serial = staticmethod(get_hard_drive_serial)
    
    def encrypt_aes256ecb(key, ciphertext):
        cipher = AES.new(key, AES.MODE_ECB)
        ciphertext = cipher.encrypt(pad(ciphertext.encode(), AES.block_size))
        return base64.b64encode(ciphertext)

    encrypt_aes256ecb = staticmethod(encrypt_aes256ecb)
    
    def decrypt_aes256ecb(key, ciphertext):
        hex_ciphertext = base64.b64decode(ciphertext)
        cipher = AES.new(key, AES.MODE_ECB)
        plaintext = cipher.decrypt(hex_ciphertext).strip()
    # WARNING: Decompyle incomplete

    decrypt_aes256ecb = staticmethod(decrypt_aes256ecb)
    
    def encrypt_aes256gcm(key, ciphertext):
        iv = get_random_bytes(16)
        cipher = AES.new(key, AES.MODE_GCM, iv)
        (ed, auth_tag) = cipher.encrypt_and_digest(ciphertext.encode())
        return base64.b64encode(iv + ed + auth_tag)

    encrypt_aes256gcm = staticmethod(encrypt_aes256gcm)
    
    def decrypt_aes256gcm(key, ciphertext):
        hex_ciphertext = binascii.unhexlify(ciphertext)
        iv = hex_ciphertext[:12]
        data = hex_ciphertext[12:-16]
        auth_tag = hex_ciphertext[-16:]
        cipher = AES.new(key, AES.MODE_GCM, iv)
        dd = cipher.decrypt_and_verify(data, auth_tag)
        return dd.decode()

    decrypt_aes256gcm = staticmethod(decrypt_aes256gcm)
    
    def check_auth(self, name = ('ttv',)):
        return False

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

a346349632 发表于 2024-1-16 12:05
反编译修改后,能重新打包回去?
losingstars 发表于 2024-1-16 12:45
 楼主| backer 发表于 2024-1-16 13:31
a346349632 发表于 2024-1-16 12:05
反编译修改后,能重新打包回去?

直接本地劫持应该就可以吧?不需要重新打包吧
 楼主| backer 发表于 2024-1-17 16:06
这里面的验证和网址应该都有了,返回的时候返回了code\date和时间,不知道有大佬们指导一下吗?
pythonhnm 发表于 2024-1-23 16:25
原程序还是尽可能发一下,这里反编译的不全
山寨数据具体还得看接口返回值
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-8 03:45

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表