public
Last active

Minimal fake NTLM authentication nodejs

  • Download Gist
ntlm_fake.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
var http = require('http');
 
http.createServer(function (req, res) {
console.log("req:", req.headers);
auth = req.headers['authorization'];
if (auth && auth.substr(0, 4) === "NTLM") {
if (auth.length > 200) {
res.end("Done");
return;
}
authString = 'NTLM TlRMTVNTUAACAAAADAAMADAAAAABAoEAASNFZ4mrze8AAAAAAAAAAGIAYgA8AAAARABPAE0AQQBJAE4AAgAMAEQATwBNAEEASQBOAAEADABTAEUAUgBWAEUAUgAEABQAZABvAG0AYQBpAG4ALgBjAG8AbQADACIAcwBlAHIAdgBlAHIALgBkAG8AbQBhAGkAbgAuAGMAbwBtAAAAAAA=';
} else {
authString = 'NTLM';
}
res.writeHead(401, {'WWW-Authenticate': authString});
res.end();
}).listen(8080);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.