def login(self, username, password): self._log("[+] Logging in (username: "******", password: "******")...") device_id = "167da12427ee4dc4a36b40e8debafc25" password_key = KikCryptographicUtils.key_from_password(username, password) data = ('<iq type="set" id="{}">' '<query xmlns="jabber:iq:register">' '<username>{}</username>' '<passkey-u>{}</passkey-u>' '<device-id>{}</device-id>' '<install-referrer>utm_source=google-play&utm_medium=organic</install-referrer>' '<operator>310260</operator>' '<install-date>1494078709023</install-date>' '<device-type>android</device-type>' '<brand>generic</brand>' '<logins-since-install>1</logins-since-install>' '<version>11.1.1.12218</version>' '<lang>en_US</lang>' '<android-sdk>19</android-sdk>' '<registrations-since-install>0</registrations-since-install>' '<prefix>CAN</prefix>' '<android-id>c10d47ba7ee17193</android-id>' '<model>Samsung Galaxy S5 - 4.4.4 - API 19 - 1080x1920</model>' '</query>' '</iq>').format(KikCryptographicUtils.make_kik_uuid(), username, password_key, device_id) self._make_request(data) response = self._get_response() if response.error: self._log("[-] Error! Code: {}".format(response.error['code']), DebugLevel.ERROR) self._log(response.error.prettify(), DebugLevel.ERROR) return False captcha = response.find('captcha-type') if captcha: self._log("[-] Captcha! URL:" + captcha, DebugLevel.WARNING) return False if response.find('password-mismatch'): self._log("[-] Password mismatch", DebugLevel.WARNING) return False if response.find("kik:error"): self._log("[-] Could not log in. response:", DebugLevel.ERROR) self._log(response.prettify(), DebugLevel.ERROR) return False user_info = dict() user_info["node"] = response.find('node').text user_info["username"] = response.find('username').text user_info["email"] = response.find('email').text user_info["first"] = response.find('first').text user_info["last"] = response.find('last').text user_info["public_key"] = response.find('record', {'pk': 'messaging_pub_key'}).text user_info["private_key"] = response.find('record', {'pk': 'enc_messaging_priv_key'}).text user_info["chat_list"] = self._parse_chat_list_bin( Utilities.decode_base64(response.find('record', {'pk': 'chat_list_bins'}).text.encode('UTF-8'))) self._log("[+] Logged in.") if self.debug_level == DebugLevel.VERBOSE: Utilities.print_dictionary(user_info) self.user_info = user_info return user_info
def kik_map_hash_code(dictionary): keys = list(dictionary.keys()) keys.sort() string1 = "" for key in keys: string1 += key + dictionary[key] string2 = "" for key in reversed(keys): string2 += key + dictionary[key] bytes1 = string1.encode('UTF-8') bytes2 = string2.encode('UTF-8') array = [ KikCryptographicUtils.kik_hash_code_sub_func(0, bytes1), KikCryptographicUtils.kik_hash_code_sub_func(1, bytes1), KikCryptographicUtils.kik_hash_code_sub_func(2, bytes1), KikCryptographicUtils.kik_hash_code_sub_func(0, bytes2), KikCryptographicUtils.kik_hash_code_sub_func(1, bytes2), KikCryptographicUtils.kik_hash_code_sub_func(2, bytes2) ] hash_code_base = -1964139357 hash_code_offset = 7 return (( (hash_code_base ^ (Utilities.sign_extend_with_mask(array[0] << hash_code_offset))) ^ (Utilities.sign_extend_with_mask(array[5] << (hash_code_offset * 2)))) ^ (Utilities.sign_extend_with_mask(array[1] << hash_code_offset)) ) ^ array[0]
def serialize(self): timestamp = str(int(round(time.time() * 1000))) data = ('<message type="chat" to="{}" id="{}" cts="{}">' '<body>{}</body>' '<preview>{}</preview>' '<kik push="true" qos="true" timestamp="{}" />' '<request xmlns="kik:message:receipt" r="true" d="true" />' '<ri></ri>' '</message>' ).format(self.peer_jid, self.message_id, timestamp, Utilities.escape_xml(self.body), Utilities.escape_xml(self.body[0:20]), timestamp) return data.encode()
def kik_hash_code_sub_func(hash_id, bytes_array): j = 0 if hash_id == 0: digest = hashlib.sha256(bytes_array).digest() elif hash_id == 1: digest = hashlib.sha1(bytes_array).digest() else: digest = hashlib.md5(bytes_array).digest() for i in range(0, len(digest), 4): j ^= ((((Utilities.byte_to_signed_int(digest[i + 3])) << 24) | ((Utilities.byte_to_signed_int(digest[i + 2])) << 16)) | ((Utilities.byte_to_signed_int(digest[i + 1])) << 8)) | ( Utilities.byte_to_signed_int(digest[i])) return j
def login(self, username, password, establish_session_on_success=True): self._log("[+] Logging in (username: "******", password: "******")...") device_id = self.device_id password_key = KikCryptographicUtils.key_from_password( username, password) data = ( '<iq type="set" id="{}">' '<query xmlns="jabber:iq:register">' '<username>{}</username>' '<passkey-u>{}</passkey-u>' '<device-id>{}</device-id>' '<install-referrer>utm_source=google-play&utm_medium=organic</install-referrer>' '<operator>310260</operator>' '<install-date>1494078709023</install-date>' '<device-type>android</device-type>' '<brand>generic</brand>' '<logins-since-install>1</logins-since-install>' '<version>{}</version>' '<lang>en_US</lang>' '<android-sdk>19</android-sdk>' '<registrations-since-install>0</registrations-since-install>' '<prefix>CAN</prefix>' '<android-id>c10d47ba7ee17193</android-id>' '<model>Samsung Galaxy S5 - 4.4.4 - API 19 - 1080x1920</model>' '</query>' '</iq>').format(KikCryptographicUtils.make_kik_uuid(), username, password_key, device_id, self.kik_version) self._make_request(data) response = self._get_response() if response.error: if response.find('password-mismatch'): self._log("[-] Password mismatch, can't login", DebugLevel.ERROR) raise KikLoginException(response.error, "Password mismatch") elif response.error.find('not-registered'): self._log("[-] User not registered, can't login", DebugLevel.ERROR) raise KikLoginException(response.error, "Not registered") else: captcha = response.find('captcha-url') if captcha: self._log( "[-} Encountered a captcha. URL: " + captcha.string, DebugLevel.ERROR) raise KikCaptchaException( response.error, "Captcha when trying to log in! URL: " + captcha.string, captcha.string) else: self._log( "[-] Kik error code: {}".format( response.error['code']), DebugLevel.ERROR) self._log(response.error.prettify(), DebugLevel.ERROR) raise KikLoginException( response.error, "Kik error code: {}".format(response.error['code'])) if response.find("kik:error"): captcha = response.find('captcha-type') if captcha: self._log("[-} Encountered a captcha. URL: " + captcha.string, DebugLevel.ERROR) raise KikLoginException(response, "Captcha! URL:" + captcha.string) user_info = dict() user_info["node"] = response.find('node').text user_info["username"] = response.find('username').text user_info["email"] = response.find('email').text user_info["first"] = response.find('first').text user_info["last"] = response.find('last').text pubkey = response.find('record', {'pk': 'messaging_pub_key'}) if pubkey: user_info["public_key"] = pubkey.text user_info["private_key"] = response.find( 'record', { 'pk': 'enc_messaging_priv_key' }).text if response.find('record', {'pk': 'chat_list_bins'}): user_info["chat_list"] = self._parse_chat_list_bin( Utilities.decode_base64( response.find('record', { 'pk': 'chat_list_bins' }).text.encode('UTF-8'))) self._log("[+] Logged in.") if self.debug_level == DebugLevel.VERBOSE: Utilities.print_dictionary(user_info) self.user_info = user_info if establish_session_on_success: self.establish_session(self.user_info["username"], self.user_info["node"], password) return self.user_info
def login(self, username, password, establish_session_on_success=True): self._log("[+] Logging in (username: "******", password: "******")...") device_id = self.device_id password_key = KikCryptographicUtils.key_from_password(username, password) data = ('<iq type="set" id="{}">' '<query xmlns="jabber:iq:register">' '<username>{}</username>' '<passkey-u>{}</passkey-u>' '<device-id>{}</device-id>' '<install-referrer>utm_source=google-play&utm_medium=organic</install-referrer>' '<operator>310260</operator>' '<install-date>1494078709023</install-date>' '<device-type>android</device-type>' '<brand>generic</brand>' '<logins-since-install>1</logins-since-install>' '<version>{}</version>' '<lang>en_US</lang>' '<android-sdk>19</android-sdk>' '<registrations-since-install>0</registrations-since-install>' '<prefix>CAN</prefix>' '<android-id>c10d47ba7ee17193</android-id>' '<model>Samsung Galaxy S5 - 4.4.4 - API 19 - 1080x1920</model>' '</query>' '</iq>').format(KikCryptographicUtils.make_kik_uuid(), username, password_key, device_id, self.kik_version) self._make_request(data) response = self._get_response() if response.error: if response.find('password-mismatch'): self._log("[-] Password mismatch, can't login", DebugLevel.ERROR) raise KikLoginException(response.error, "Password mismatch") elif response.error.find('not-registered'): self._log("[-] User not registered, can't login", DebugLevel.ERROR) raise KikLoginException(response.error, "Not registered") else: captcha = response.find('captcha-url') if captcha: self._log("[-} Encountered a captcha. URL: " + captcha.string, DebugLevel.ERROR) raise KikCaptchaException(response.error, "Captcha when trying to log in! URL: " + captcha.string, captcha.string) else: self._log("[-] Kik error code: {}".format(response.error['code']), DebugLevel.ERROR) self._log(response.error.prettify(), DebugLevel.ERROR) raise KikLoginException(response.error, "Kik error code: {}".format(response.error['code'])) if response.find("kik:error"): captcha = response.find('captcha-type') if captcha: self._log("[-} Encountered a captcha. URL: " + captcha.string, DebugLevel.ERROR) raise KikLoginException(response, "Captcha! URL:" + captcha.string) user_info = dict() user_info["node"] = response.find('node').text user_info["username"] = response.find('username').text user_info["email"] = response.find('email').text user_info["first"] = response.find('first').text user_info["last"] = response.find('last').text pubkey = response.find('record', {'pk': 'messaging_pub_key'}) if pubkey: user_info["public_key"] = pubkey.text user_info["private_key"] = response.find('record', {'pk': 'enc_messaging_priv_key'}).text if response.find('record', {'pk': 'chat_list_bins'}): user_info["chat_list"] = self._parse_chat_list_bin( Utilities.decode_base64(response.find('record', {'pk': 'chat_list_bins'}).text.encode('UTF-8'))) self._log("[+] Logged in.") if self.debug_level == DebugLevel.VERBOSE: Utilities.print_dictionary(user_info) self.user_info = user_info if establish_session_on_success: self.establish_session(self.user_info["username"], self.user_info["node"], password) return self.user_info