0

How was this code encrypted? A former webmaster left me code encrypted this way. I do not know how to solve.

Code:

function setCookie(a, b, c) {
    var d = new Date();
    d[_0x6fff[1]](d[_0x6fff[0]]() + 24 * c * 60 * 60 * 1e3);
    var e = _0x6fff[2] + d[_0x6fff[3]]();
    document[_0x6fff[4]] = a + _0x6fff[5] + b + _0x6fff[6] + e;
}

function getCookie(a) {
    var b = a + _0x6fff[5];
    var c = document[_0x6fff[4]][_0x6fff[8]](_0x6fff[7]);
    for (var d = 0; d < c[_0x6fff[9]]; d++) {
        var e = c[d];
        while (_0x6fff[11] == e[_0x6fff[12]](0)) e = e[_0x6fff[10]](1);
        if (e[_0x6fff[13]](b) != -1) return e[_0x6fff[10]](b[_0x6fff[9]], e[_0x6fff[9]]);
    }
    return _0x6fff[14];
}
Pang
  • 9,564
  • 146
  • 81
  • 122
  • 6
    It's not encrypted, its obfuscated. – Ryan Mar 04 '15 at 01:56
  • Sadly this question was 'put on hold' so I can't post this as proper answer. This is an unimaginatively obscured [standard](http://www.quirksmode.org/js/cookies.html) cookie getter `getCookie(name)` and setter `setCookie(name, value, noOfDays)`. As you haven't posted `array _0x6fff` *I found it fun to work out **what it should be:*** `var _0x6fff=['getTime', 'setTime', 'expires=', 'toGMTString', 'cookie', '=', '; ', ';', 'split', 'length', 'substring', ' ', 'charAt', 'indexOf', null];`. It works because _0x6fff is a [valid identifier in javascript](https://mothereff.in/js-variables) – GitaarLAB Mar 06 '15 at 02:13

1 Answers1

1

Looks like it's a combination of minification and Hex-encoded Chinese characters:

Minification is a way of reducing the size of a javascript file by replacing long variable names with single letters (a, b, c in your example above)

_0x6fff is the HEX representation of a HAN character: cross on stepping-stones

Once code has been minified, you can't really undo it. See here

Community
  • 1
  • 1
jasonscript
  • 6,039
  • 3
  • 28
  • 43
  • Haha, so the code threw you off track haha. `_0x6fff` is a perfectly valid identifier and it has nothing to do with HAN Characters. Itching to downvote but.. that would cost me +/-60minuts/10rep=6 minutes of my life `:)` Also, there is no secret in the code, no need to 'undo' it. The only thing not retrievable from minified code are original identifiers. – GitaarLAB Mar 05 '15 at 18:20