more printing stuff

This commit is contained in:
JJTech0130 2023-04-07 09:47:21 -04:00
parent abb47ddaf7
commit b17ae3f6f6
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6
2 changed files with 23 additions and 4 deletions

View file

@ -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}") print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Connected{bcolors.ENDC} {token_str}")
elif id == 7: elif id == 7:
print(f"{bcolors.OKGREEN}{prefix}{bcolors.ENDC}: {bcolors.OKCYAN}Connect Request{bcolors.ENDC}") 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: else:
print(prefix, f"Payload ID: {hex(payload[0])}") print(prefix, f"Payload ID: {hex(payload[0])}")
for field in payload[1]: for field in payload[1]:

View file

@ -16,10 +16,10 @@ def connect() -> tlslite.TLSConnection:
sock = socket.create_connection((APNS_HOST, APNS_PORT)) sock = socket.create_connection((APNS_HOST, APNS_PORT))
# Wrap the socket in TLS # Wrap the socket in TLS
ssock = tlslite.TLSConnection(sock) ssock = tlslite.TLSConnection(sock)
print("Handshaking with APNs") #print("Handshaking with APNs")
# Handshake with the server # Handshake with the server
ssock.handshakeClientCert(alpn=[b"apns-security-v3"]) ssock.handshakeClientCert(alpn=[b"apns-security-v3"])
print("Handshaked with APNs") #print("Handshaked with APNs")
return ssock return ssock
@ -60,10 +60,10 @@ def handle(conn: socket.socket):
global cert, key global cert, key
chain = tlslite.X509CertChain() chain = tlslite.X509CertChain()
chain.parsePemList(cert) chain.parsePemList(cert)
print(chain) #print(chain)
#cert = tlslite.X509CertChain([tlslite.X509().parse(cert)]) #cert = tlslite.X509CertChain([tlslite.X509().parse(cert)])
key_parsed = tlslite.parsePEMKey(key, private=True) 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]) s_conn.handshakeServer(certChain=chain, privateKey=key_parsed, reqCert=False, alpn=[ALPN])
print("Handling connection") print("Handling connection")