Comparing version 1.8.7 to 1.8.8
10
ntlm.js
@@ -72,2 +72,5 @@ /** | ||
function createType1Message(options){ | ||
if(!options.domain) options.domain = ''; | ||
if(!options.workstation) options.workstation = ''; | ||
var domain = escape(options.domain.toUpperCase()); | ||
@@ -119,3 +122,3 @@ var workstation = escape(options.workstation.toUpperCase()); | ||
if(!match || !match[1]) { | ||
callback(new Error("Couldn't find NTLM in the message type2 comming from the server")); | ||
callback(new Error("Couldn't find NTLM in the message type2 coming from the server")); | ||
return null; | ||
@@ -155,2 +158,7 @@ } | ||
function createType3Message(msg2, options){ | ||
if(!options.domain) options.domain = ''; | ||
if(!options.workstation) options.workstation = ''; | ||
if(!options.username) options.username = ''; | ||
if(!options.password) options.password = ''; | ||
var nonce = msg2.serverChallenge; | ||
@@ -157,0 +165,0 @@ var username = options.username; |
{ | ||
"name": "httpntlm", | ||
"description": "httpntlm is a Node.js library to do HTTP NTLM authentication", | ||
"version": "1.8.7", | ||
"version": "1.8.8", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "des.js": "^1.0.1", |
@@ -193,3 +193,3 @@ # httpntlm | ||
* [python-ntlm](https://code.google.com/p/python-ntlm/) | ||
* [NTLM Authentication Scheme for HTTP](http://www.innovation.ch/personal/ronald/ntlm.html) | ||
* [NTLM Authentication Scheme for HTTP](https://web.archive.org/web/20200724074947/https://www.innovation.ch/personal/ronald/ntlm.html) | ||
* [LM hash on Wikipedia](http://en.wikipedia.org/wiki/LM_hash) | ||
@@ -196,0 +196,0 @@ |
62
test.js
@@ -84,5 +84,20 @@ var rewire = require("rewire"); | ||
function test_createType1Message_emptyoptions() { | ||
console.log('> testing createType1Message (empty options)'); | ||
const createType1Message = ntlm.__get__("createType1Message"); | ||
var options = {}; | ||
var realResponse = createType1Message(options); | ||
// console.log('type1 message (empty options):', realResponse); | ||
var expectedResponse = "NTLM TlRMTVNTUAABAAAAB6IIogAAAAAoAAAAAAAAACgAAAAFASgKAAAADw=="; | ||
return realResponse == expectedResponse; | ||
} | ||
function test_parseType2Message() { | ||
@@ -229,2 +244,47 @@ console.log('> testing parseType2Message'); | ||
function test_createType3Message_emptyoptions() { | ||
console.log('> testing createType3Message'); | ||
const createType3Message = ntlm.__get__("createType3Message"); | ||
var mathMock = { | ||
random: function () { | ||
return 0.8092; | ||
}, | ||
floor: Math.floor | ||
}; | ||
ntlm.__set__("Math", mathMock); | ||
var dateMock = { | ||
now: function () { | ||
return 1679346960095; | ||
} | ||
}; | ||
ntlm.__set__("Date", dateMock); | ||
var type2Message = { | ||
signature: Buffer.from([0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00]), | ||
type: 2, | ||
targetNameLen: 30, | ||
targetNameMaxLen: 30, | ||
targetNameOffset: 56, | ||
targetName: Buffer.from([0x44, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00, 0x2d, 0x00, 0x4a, 0x00, 0x53, 0x00, 0x34, 0x00, 0x55, 0x00, 0x4a, 0x00, 0x54, 0x00, 0x44, 0x00]), | ||
negotiateFlags: -1567981051, | ||
serverChallenge: Buffer.from([0x05, 0xeb, 0xf2, 0xc2, 0xf2, 0x72, 0x92, 0x30]), | ||
reserved: Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), | ||
targetInfoLen: 152, | ||
targetInfoMaxLen: 152, | ||
targetInfoOffset: 86, | ||
targetInfo: Buffer.from([0x02, 0x00, 0x1e, 0x00, 0x44, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00, 0x2d, 0x00, 0x4a, 0x00, 0x53, 0x00, 0x34, 0x00, 0x55, 0x00, 0x4a, 0x00, 0x54, 0x00, 0x44, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x44, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00, 0x2d, 0x00, 0x4a, 0x00, 0x53, 0x00, 0x34, 0x00, 0x55, 0x00, 0x4a, 0x00, 0x54, 0x00, 0x44, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x44, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00, 0x2d, 0x00, 0x4a, 0x00, 0x53, 0x00, 0x34, 0x00, 0x55, 0x00, 0x4a, 0x00, 0x54, 0x00, 0x44, 0x00, 0x03, 0x00, 0x1e, 0x00, 0x44, 0x00, 0x45, 0x00, 0x53, 0x00, 0x4b, 0x00, 0x54, 0x00, 0x4f, 0x00, 0x50, 0x00, 0x2d, 0x00, 0x4a, 0x00, 0x53, 0x00, 0x34, 0x00, 0x55, 0x00, 0x4a, 0x00, 0x54, 0x00, 0x44, 0x00, 0x07, 0x00, 0x08, 0x00, 0x39, 0xa0, 0xbb, 0x30, 0x87, 0x9f, 0xd5, 0x01, 0x00, 0x00, 0x00, 0x00]) | ||
}; | ||
var options = {}; | ||
var realResponse = createType3Message(type2Message, options); | ||
// console.log('type3 message:', realResponse); | ||
var expectedResponse = "NTLM TlRMTVNTUAADAAAAGAAYAEgAAADIAMgAYAAAAAAAAABIAAAAAAAAAEgAAAAAAAAASAAAAAAAAAAoAQAABYKIogUBKAoAAAAPwARIPPqPB18BtDy2SiF1us/Pz8/Pz8/P52yYCH+rc7F7jUeUnayiPQEBAAAAAAAA8OZaK3Fb2QHPz8/Pz8/PzwAAAAACAB4ARABFAFMASwBUAE8AUAAtAEoAUwA0AFUASgBUAEQAAQAeAEQARQBTAEsAVABPAFAALQBKAFMANABVAEoAVABEAAQAHgBEAEUAUwBLAFQATwBQAC0ASgBTADQAVQBKAFQARAADAB4ARABFAFMASwBUAE8AUAAtAEoAUwA0AFUASgBUAEQABwAIADmguzCHn9UBAAAAAAAAAAA="; | ||
return realResponse == expectedResponse; | ||
} | ||
function test_insertZerosEvery7Bits() { | ||
@@ -382,5 +442,7 @@ console.log('> testing insertZerosEvery7Bits'); | ||
console.log(test_createType1Message_noworkstation()); | ||
console.log(test_createType1Message_emptyoptions()); | ||
console.log(test_parseType2Message()); | ||
console.log(test_createType3Message()); | ||
console.log(test_createType3Message_negotiateflagszero()); | ||
console.log(test_createType3Message_emptyoptions()); | ||
console.log(test_create_LM_hashed_password_v1()); | ||
@@ -387,0 +449,0 @@ console.log(test_create_LM_hashed_password_v1_longpassword()); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53119
862