hacks around design flaw in my APNs stuff; can now do multiple lookups

This commit is contained in:
JJTech0130 2023-05-02 18:11:14 -04:00
parent 98c861c625
commit cc54c4b79a
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6
2 changed files with 32 additions and 32 deletions

View file

@ -33,6 +33,10 @@ def _connect(private_key: str, cert: str) -> tlslite.TLSConnection:
class APNSConnection: class APNSConnection:
incoming_queue = [] incoming_queue = []
# Sink everything in the queue
def sink(self):
self.incoming_queue = []
def _queue_filler(self): def _queue_filler(self):
while True and not self.sock.closed: while True and not self.sock.closed:
# print(self.sock.closed) # print(self.sock.closed)

60
demo.py
View file

@ -134,42 +134,38 @@ if not 'ids_cert' in CONFIG:
refresh_ids_cert() refresh_ids_cert()
print("Got IDS certificate!") print("Got IDS certificate!")
# This is the actual lookup!
print("Looking up user...")
ids_keypair = ids.KeyPair(CONFIG['key'], CONFIG['ids_cert']) ids_keypair = ids.KeyPair(CONFIG['key'], CONFIG['ids_cert'])
resp = ids.lookup(conn, CONFIG['username'], ids_keypair, 'com.apple.madrid', ['mailto:user_test2@icloud.com'])
print("Got response!")
#print(resp)
r = list(resp['results'].values())[0] def lookup(topic:str, users: list[str]):
i = r['identities'] print(f"Looking up users {users} for topic {topic}...")
print(f"IDENTITIES: {len(i)}") resp = ids.lookup(conn, CONFIG['username'], ids_keypair, topic, users)
for iden in i:
print("IDENTITY", end=" ")
#print("========")
print(f"Push Token: {b64encode(iden['push-token']).decode()}", end=" ")
if 'client-data' in iden:
print(f"Client Data: {len(iden['client-data'])}")
# cl = iden['client-data']
# for key, value in cl.items():
# print(f"{key}: {value}")
else:
print("No client data")
#print("\n\n\n")
#print("\n\n\n")
#print(iden)
#
# for key, value in iden.items():
# print(f"{key}: {value}")
#for key, value in r.items():
# print(f"{key}: {value}")
#print(r)
#print(len(str(resp)))
#print("\n\n\n\n") #r = list(resp['results'].values())[0]
for k, v in resp['results'].items():
print(f"Result for user {k} topic {topic}:")
i = v['identities']
print(f"IDENTITIES: {len(i)}")
for iden in i:
print("IDENTITY", end=" ")
print(f"Push Token: {b64encode(iden['push-token']).decode()}", end=" ")
if 'client-data' in iden:
print(f"Client Data: {len(iden['client-data'])}")
#for key, value in resp['results']['mailto:user_test2@icloud.com'].items(): else:
# print(f"{key}: {value}") print("No client data")
# Hack to make sure that the requests and responses match up
# This filter MUST contain all the topics you are looking up
conn.filter(['com.apple.madrid', 'com.apple.private.alloy.facetime.multi'])
import time
time.sleep(5) # Let the server send us any messages it was holding
conn.sink() # Dump the messages
lookup("com.apple.madrid", ["mailto:jjtech@jjtech.dev"])
lookup("com.apple.private.alloy.facetime.multi", ["mailto:jjtech@jjtech.dev"])
lookup("com.apple.private.alloy.facetime.multi", ["mailto:user_test2@icloud.com"])
lookup("com.apple.madrid", ["mailto:user_test2@icloud.com"])
# Save config # Save config
with open("config.json", "w") as f: with open("config.json", "w") as f: