Skip to content

Instantly share code, notes, and snippets.

@troufster
Created April 27, 2012 18:52
Show Gist options
  • Select an option

  • Save troufster/2511828 to your computer and use it in GitHub Desktop.

Select an option

Save troufster/2511828 to your computer and use it in GitHub Desktop.

Revisions

  1. troufster created this gist Apr 27, 2012.
    32 changes: 32 additions & 0 deletions formsdec.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@

    function hex2a(hex) {
    var str = '';
    for (var i = 0; i < hex.length; i += 2)
    str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
    return str;
    }

    //Raw cookie
    var cookie = "B417B464CA63FE780584563D2DA4709B03F6195189044C26A29770F3203881DD90B1428139088D945CF6807CA408F201DABBADD59CE1D740F853A894692273F1CA83EC3F26493744E3D25D720374E03393F71E21BE2D96B6110CB7AC12E44447FFBD810D3D57FBACA8DF5249EB503C3DFD255692409F084650EFED205388DD8C08BF7B941E1AC1B3B70B9A8E09118D756BEAFF25834E72357FD40E80E76458091224FAE8";

    //decryptionKey from issuers <machineKey>
    var deckey = "FFA87B82D4A1BEAA15C06F6434A7EB2251976A838784E134900E6629B9F954B7";


    var crypto = require('crypto');

    var ivc = cookie, iv, cipherText, ivSize = 16, res = "";

    ivc = new Buffer(ivc, 'hex');
    iv = new Buffer(ivSize);
    cipherText = new Buffer(ivc.length - ivSize);
    ivc.copy(iv, 0, 0, ivSize);
    ivc.copy(cipherText, 0, ivSize);

    c = crypto.createDecipheriv('aes-256-cbc', hex2a(deckey), iv.toString('binary'));
    res = c.update(cipherText, "binary", "utf8");
    res += c.final('utf8');


    console.log(res);