def serialize(self): can = 'CAN' # XmppSocketV2.java line 180, device = self.device_id_override if self.device_id_override else device_id timestamp = str(CryptographicUtils.make_kik_timestamp()) sid = CryptographicUtils.make_kik_uuid() signature = rsa.sign( "{}:{}:{}:{}".format(can + device, kik_version, timestamp, sid).encode(), private_key, 'SHA-256') signature = base64.b64encode(signature, '-_'.encode()).decode().rstrip('=') hmac_data = timestamp + ":" + can + device hmac_secret_key = CryptographicUtils.build_hmac_key() cv = binascii.hexlify( hmac.new(hmac_secret_key, hmac_data.encode(), hashlib.sha1).digest()).decode() the_map = { 'signed': signature, 'lang': 'en_US', 'sid': sid, 'anon': '1', 'ts': timestamp, 'v': kik_version, 'cv': cv, 'conn': 'WIFI', 'dev': can + device, } # Test data to confirm the sort_kik_map function returns the correct result. # the_map = { # 'signed': 'signature', # 'lang': 'en_US', # 'sid': 'sid', # 'anon': '1', # 'ts': 'timestamp', # 'v': 'kik_version', # 'cv': 'cv', # 'conn': 'WIFI', # 'dev': 'can+device', # } if self.n > 0: the_map['n'] = self.n packet = CryptographicUtils.make_connection_payload( *CryptographicUtils.sort_kik_map(the_map)) return packet.encode()
def serialize(self): jid = self.node + "@talk.kik.com" jid_with_resource = jid + "/CAN" + ( self.device_id_override if self.device_id_override else device_id) timestamp = str(CryptographicUtils.make_kik_timestamp()) sid = CryptographicUtils.make_kik_uuid() # some super secret cryptographic stuff signature = rsa.sign( "{}:{}:{}:{}".format(jid, kik_version, timestamp, sid).encode(), private_key, 'SHA-256') signature = base64.b64encode(signature, '-_'.encode()).decode().rstrip('=') hmac_data = timestamp + ":" + jid hmac_secret_key = CryptographicUtils.build_hmac_key() cv = binascii.hexlify( hmac.new(hmac_secret_key, hmac_data.encode(), hashlib.sha1).digest()).decode() password_key = CryptographicUtils.key_from_password( self.username, self.password) the_map = { 'from': jid_with_resource, 'to': 'talk.kik.com', 'p': password_key, 'cv': cv, 'v': kik_version, 'sid': sid, 'n': '1', 'conn': 'WIFI', 'ts': timestamp, 'lang': 'en_US', 'signed': signature } packet = CryptographicUtils.make_connection_payload( *CryptographicUtils.sort_kik_map(the_map)) return packet.encode()