Created
August 7, 2013 15:49
-
-
Save seriyps/6175334 to your computer and use it in GitHub Desktop.
Yandex wordstat encrypted AJAX decoder for Python and Erlang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decode_data(Data, UserAgent, Fuid01) -> | |
Key = iolist_to_binary([binary:part(UserAgent, 0, min(25, size(UserAgent))), | |
Fuid01, | |
<<"I keep watch over you ;)">>]), | |
decode_chars(Data, Key, 0). | |
decode_chars(<<>>, _, _) -> | |
<<>>; | |
decode_chars(<<Char:8, Rest/binary>>, Key, Idx) -> | |
KeyPos = Idx rem size(Key), | |
<<_:KeyPos/binary, KeyChr:8, _/binary>> = Key, | |
Decoded = Char bxor KeyChr, | |
Next = decode_chars(Rest, Key, Idx + 1), | |
<<Decoded:8, Next/binary>>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decode_wordstat(l) { | |
var h = navigator['userAgent']['substr'](0, 25) + $['cookie']('fuid01') + 'I keep watch over you ;)'; | |
var n = ''; | |
for (var g = 0; g < l['data']['length']; g++) { | |
n = n + String['fromCharCode'](l['data']['charCodeAt'](g) ^ h['charCodeAt'](g % h['length'])) | |
} | |
return n | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decode_wordstat(response_data, user_agent, fuid01): | |
key = user_agent[:25] + fuid01 + 'I keep watch over you ;)' | |
res = '' | |
for i, char in enumerate(response_data): | |
decoded = chr(ord(char) ^ ord(key[i % len(key)])) | |
res += decoded | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment