tomer8007 / kik-bot-api-unofficial

Python API for writing unoffical Kik bots that act like humans
MIT License
126 stars 76 forks source link

Some updates to k tag sorting #169

Closed Artificiangel closed 3 years ago

Artificiangel commented 3 years ago

Added functions to sort the anonymous k tag according to decompiled java code. The decompiled code may not be exact, but my python code returns the same results.

This commit is a part of the fix for camera images and proper login. Code tested on python 3.6.4. Should work on older versions.

Recompiling the kik apk without making changes to it still breaks camera images. They are probably checking the apk signature too somewhere.

tomer8007 commented 3 years ago

So basically what's the difference between sort_kik_map and sort_kik_map_v2? They both appear to be translated code from SortedMap.java. I think @bluemods has said only the spaces in the beginning are missing if I remember correctly.

Also we know they are using the APK signature in build_hmac_key, so this is a possible explanation to what you've seen, isn't it?

bluemods commented 3 years ago

Everything looks correct except for the hmac key

Artificiangel commented 3 years ago

I must have missed it and decided to start from scratch.

Had to fix a couple small issues. In kik_map_hash_code, lines 178 and 181 dictionary[key] needs to be converted to a string before getting added to string1. But my test shows it does sort the dict correctly.

I will work on a new pull request that merges the code that generates the spaces at the beginning with these existing functions.

While looking at the sort_kik_map function I noticed it's only doing one sort. Kik's code is sorting the dict twice. On the first sort using -310256979 as the base and 13 as the offset the hash for the spaces is calculated. Then it is sorted again with base -1964139357 and offset 7 for the tag's contents.