Skip to content

Instantly share code, notes, and snippets.

@seriyps
Created August 7, 2013 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seriyps/6175334 to your computer and use it in GitHub Desktop.
Save seriyps/6175334 to your computer and use it in GitHub Desktop.
Yandex wordstat encrypted AJAX decoder for Python and Erlang
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>>.
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
}
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