diff --git a/printer.py b/printer.py index 4701335..11884e2 100644 --- a/printer.py +++ b/printer.py @@ -108,6 +108,25 @@ def pretty_print_payload(prefix, payload: tuple[int, list[tuple[int, bytes]]]): print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Connected{bcolors.ENDC} {token_str}") elif id == 7: print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Connect Request{bcolors.ENDC}") + elif id == 0xc: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Keep Alive{bcolors.ENDC}") + elif id == 0xd: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Keep Alive Ack{bcolors.ENDC}") + elif id == 0x14: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Set State{bcolors.ENDC}: {_get_field(payload[1], 1).hex()}") + elif id == 0x1d: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.FAIL}Unknown 0x1D{bcolors.ENDC}") + elif id == 0x20: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.FAIL}Unknown 0x20{bcolors.ENDC}") + elif id == 0xe: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.FAIL}Unknown 0xe{bcolors.ENDC}") + elif id == 0xa: + if prefix == "apsd -> APNs": + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKBLUE}OUTGOING Notification{bcolors.ENDC}") + else: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Notification{bcolors.ENDC}") + elif id == 0xb: + print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Notification Ack{bcolors.ENDC}") else: print(prefix, f"Payload ID: {hex(payload[0])}") for field in payload[1]: diff --git a/proxy/proxy.py b/proxy/proxy.py index e0a0e93..b8fd5a9 100644 --- a/proxy/proxy.py +++ b/proxy/proxy.py @@ -16,10 +16,10 @@ def connect() -> tlslite.TLSConnection: sock = socket.create_connection((APNS_HOST, APNS_PORT)) # Wrap the socket in TLS ssock = tlslite.TLSConnection(sock) - print("Handshaking with APNs") + #print("Handshaking with APNs") # Handshake with the server ssock.handshakeClientCert(alpn=[b"apns-security-v3"]) - print("Handshaked with APNs") + #print("Handshaked with APNs") return ssock @@ -60,10 +60,10 @@ def handle(conn: socket.socket): global cert, key chain = tlslite.X509CertChain() chain.parsePemList(cert) - print(chain) + #print(chain) #cert = tlslite.X509CertChain([tlslite.X509().parse(cert)]) key_parsed = tlslite.parsePEMKey(key, private=True) - print(key_parsed) + #print(key_parsed) s_conn.handshakeServer(certChain=chain, privateKey=key_parsed, reqCert=False, alpn=[ALPN]) print("Handling connection")