2023-04-21 20:47:13 -05:00
|
|
|
import hashlib
|
|
|
|
import plistlib
|
2023-05-02 19:53:18 -05:00
|
|
|
import zlib
|
|
|
|
from base64 import b64decode
|
2023-04-21 20:47:13 -05:00
|
|
|
|
2023-05-02 19:53:18 -05:00
|
|
|
import ids
|
|
|
|
|
|
|
|
with open("body.txt", "r") as f:
|
2023-04-21 20:47:13 -05:00
|
|
|
BODY = f.read()
|
|
|
|
|
|
|
|
CERT = "MIIIKTCCBxGgAwIBAgIRAMRS4zTbARHt//////////8wDQYJKoZIhvcNAQEFBQAwbjELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xEjAQBgNVBAsMCUFwcGxlIElEUzEOMAwGA1UEDwwFZHMtaWQxJjAkBgNVBAMMHUFwcGxlIElEUyBEUy1JRCBSZWFsbSBDQSAtIFIxMB4XDTIzMDQxNDIwMjAxNVoXDTMzMDQxMTIwMjAxNVowXDELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xCTAHBgNVBAsMADEOMAwGA1UEDwwFZHMtaWQxHTAbBgoJkiaJk/IsZAEBDA1EOjEwMTA0MjI0OTc0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAteCyewpP4kvYA3Yb8T5Pt2S1Y8T1BRStnM4pZelzN+61sQvgFgbnO+5cs0swDKxexRpbHQ4Lo7FrVQhHry0AhxI4FAw7L4dilRH9XAvWvt+VrOiDY6V2ha+DQwpLjZpgLJ0Zgofh35CxGg5A/uUmeNhldGfo8DxdnR6t8FvE/qkkePNYZDMtk9X9xa3XcQypH89iG7AqIDnueTGReZ0IOPwOWb6AQ2HUQz2Ihz3PwfHxknQcYMMnm9iRFsDGeit/hByYTKvGzpcsd+2A5jRg5jeiPYi7olNOi2qaDEGaOa4vsJV3Z9aJpFPGTxXFDzSM+5sSP9XZtrfQ9WxExeW1FwIDAQABo4IE0jCCBM4wggRKBgNVHREEggRBMIIEPaAgBgoqhkiG92NkB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FCzxUaAZAPFPDna+8tvRwd0q3kuK9b0w/kuT16X1SL166fFNzmsQGcBqob9C9xX0VlYGqSd4K975gWdYsPo/kiY0ni4Q130oc6oAANr8ATN0bEeAO6/AfVM2aqHJTGlYlekBFWf8Tp8AJLUc4cm676346IEBST+l4rYGxYYStV2PEmp9cZ+"
|
|
|
|
TOKEN = "5V7AY+ikHr4DiSfq1W2UBa71G3FLGkpUSKTrOLg81yk="
|
|
|
|
NONCE = "AQAAAYeBb0XwKDMBW5PfAPM="
|
|
|
|
|
2023-05-02 19:53:18 -05:00
|
|
|
|
2023-04-21 20:47:13 -05:00
|
|
|
def extract_hash(sig: bytes, cert: str) -> str:
|
2023-05-02 19:53:18 -05:00
|
|
|
# sig = b64decode(SIG)[2:]
|
2023-04-21 20:47:13 -05:00
|
|
|
sig = int.from_bytes(sig)
|
|
|
|
|
|
|
|
# Get the correct hash
|
|
|
|
from cryptography.hazmat.backends import default_backend
|
|
|
|
from cryptography.x509 import load_pem_x509_certificate
|
2023-05-02 19:53:18 -05:00
|
|
|
|
|
|
|
# key, cert = load_keys()
|
2023-04-21 20:47:13 -05:00
|
|
|
cert = "-----BEGIN CERTIFICATE-----\n" + cert + "\n-----END CERTIFICATE-----"
|
|
|
|
cert = load_pem_x509_certificate(cert.encode(), default_backend())
|
|
|
|
modulus = cert.public_key().public_numbers().n
|
|
|
|
power = cert.public_key().public_numbers().e
|
2023-05-02 19:53:18 -05:00
|
|
|
# print(hex(pow(sig, power, modulus)))
|
2023-04-21 20:47:13 -05:00
|
|
|
|
|
|
|
return pow(sig, power, modulus)
|
|
|
|
# from cryptography import x509
|
|
|
|
|
|
|
|
# cert = "-----BEGIN CERTIFICATE-----\n" + cert + "\n-----END CERTIFICATE-----"
|
|
|
|
# cert = x509.load_pem_x509_certificate(cert.encode())
|
|
|
|
# pub = cert.public_key()
|
|
|
|
# modulus = pub.public_numbers().n
|
|
|
|
# # Get the power
|
|
|
|
# power = pub.public_numbers().e
|
|
|
|
# # Get the hash from the sig
|
|
|
|
# sig = b64decode(sig)
|
|
|
|
# sig = sig[2:]
|
|
|
|
# sig = int.from_bytes(sig)
|
|
|
|
# hash = pow(sig, power, modulus)
|
|
|
|
|
|
|
|
# print(hex(hash))
|
|
|
|
|
|
|
|
# return hash
|
|
|
|
|
2023-05-02 19:53:18 -05:00
|
|
|
|
2023-04-21 20:47:13 -05:00
|
|
|
body = plistlib.dumps(plistlib.loads(BODY.encode()))
|
2023-05-02 19:53:18 -05:00
|
|
|
body = zlib.compress(BODY.encode(), wbits=16 + zlib.MAX_WBITS)
|
2023-04-21 20:47:13 -05:00
|
|
|
|
2023-05-02 19:53:18 -05:00
|
|
|
p = ids._create_payload("id-register", "", TOKEN, body, b64decode(NONCE))[0]
|
2023-04-21 20:47:13 -05:00
|
|
|
s = hashlib.sha1(p).digest()
|
|
|
|
print(s.hex())
|
2023-05-02 19:53:18 -05:00
|
|
|
# extract_hash(SIG, CERT)
|
2023-04-21 20:47:13 -05:00
|
|
|
|
|
|
|
# Loop through all POSSIBLE ranges
|
|
|
|
# sig = b64decode(SIG)
|
|
|
|
# print(sig[:2])
|
|
|
|
# for i in range(len(sig)):
|
|
|
|
# for j in range(i, len(sig)):
|
|
|
|
# h = extract_hash(sig[i:j], CERT)
|
|
|
|
# t = hex(h)
|
|
|
|
# if 'ffffff' in t:
|
|
|
|
# print(i, j, t)
|
|
|
|
# sig = b64decode(SIG)[2:]
|
|
|
|
# for i in range(len(sig)):
|
|
|
|
# h = extract_hash(sig[:i], CERT)
|
|
|
|
# t = hex(h)
|
|
|
|
# if 'ffff' in t:
|
|
|
|
# print(i, t)
|
|
|
|
|
|
|
|
# #print(hex(extract_hash(SIG, CERT)))
|
|
|
|
|
2023-05-02 19:53:18 -05:00
|
|
|
# CERT2 = "MIICnjCCAgegAwIBAgIKBAr40/DyW42YxjANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJVUzETMBEGA1UEChMKQXBwbGUgSW5jLjEVMBMGA1UECxMMQXB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