Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akaNightmare/30985da516873f6d8d5b18b1877f325d to your computer and use it in GitHub Desktop.
Save akaNightmare/30985da516873f6d8d5b18b1877f325d to your computer and use it in GitHub Desktop.
@mdmsazm
Copy link

mdmsazm commented Oct 21, 2021

The "aes-256-cbc" version of the above code.

const decipher = crypto.createDecipheriv('aes-256-cbc', Buffer.from(this.decryptionKey, 'hex'), Buffer.alloc(16));
let decoded = Buffer.from(decipher.update(cookie, 'binary', 'binary') + decipher.final(), 'binary').slice(32);

let dotnetTicks = parseInt(this.__reverseHexString(decoded.slice(11, 19).toString('hex')), 16);
console.log('.net ticks ', dotnetTicks);
const utcExpireTicks = Math.floor((dotnetTicks - baseTicks) / 10000);
const isPersistent = parseInt(decoded.slice(19, 20).toString('hex'), 16);

decoded = decoded.toString('utf8').replace(/\0/g, '');

// user data format here is json
let decodedData =  decoded.substring(decoded.lastIndexOf('{'), decoded.lastIndexOf('}') + 1);
let userObj = JSON.parse(decodedData);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment