From 0aebfd413f5451b634f5e2fd8da3da7654d87d0b Mon Sep 17 00:00:00 2001 From: May Date: Fri, 6 Sep 2024 23:05:57 +0000 Subject: Add files via upload --- kh_editlic.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 kh_editlic.py (limited to 'kh_editlic.py') diff --git a/kh_editlic.py b/kh_editlic.py new file mode 100644 index 0000000..15275a3 --- /dev/null +++ b/kh_editlic.py @@ -0,0 +1,70 @@ +import sys +import random +import struct +import time +import binascii +import hashlib + +tlv_types = { + "SignedBlock": 0x14, + "DeviceLicenseExpirationTime": 0x1f, + "PollingTime": 0xd3, + "LicenseExpirationTime": 0x20, + "ClepSignState": 0x12d, + "LicenseDeviceId": 0xd2, + "UnkBlock1": 0xd1, + "LicenseId": 0xcb, + "HardwareId": 0xd0, + "UnkBlock2": 0xcf, + "UplinkKeyId": 0x18, + "UnkBlock3": 0x0, + "UnkBlock4": 0x12e, + "UnkBlock5": 0xd5, + "PackageFullName": 0xce, + "LicenseInformation": 0xc9, + "PackedContentKeys": 0xca, + "EncryptedDeviceKey": 0x1, + "DeviceLicenseDeviceId": 0x2, + "LicenseEntryIds": 0xcd, + "LicensePolicies": 0xd4, + "KeyholderPublicSigningKey": 0xdc, + "KeyholderPolicies": 0xdd, + "KeyholderKeyLicenseId": 0xde, + "SignatureBlock": 0xcc, +}; + +def encode_tlvblock(type, data): + return struct.pack("= 5: + extra_file = sys.argv[4] + + with open(extra_file, "rb") as f: + extradata = f.read() + +with open(lic_file, "rb") as f: + data = f.read() + +data += encode_tlvblock("PackageFullName", new_pfn.encode("utf-16-le") + b"\x00\x00") + +basic_pol = 0x0a +if "addon" in new_pfn: + basic_pol = 0x00 + +lic_info = struct.pack("