forked from Node-SMB/marsaud-smb2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from itjstagame/support_ntlmv2
Add support for NTLM v2
- Loading branch information
Showing
5 changed files
with
14,946 additions
and
14,820 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Wrapper to allow diff ntlm packages but still accept and return Buffer as node-smb2 expects. | ||
httpntlm expects strings, but supports ntlm v2 and will negotiate between either | ||
*/ | ||
var ntlm = require('httpntlm').ntlm; | ||
|
||
function parsehttpntlmMsg(msg) { | ||
var match = msg.match(/NTLM (.+)?/); | ||
if(!match || !match[1]) { | ||
return null; | ||
} | ||
|
||
return Buffer.from(match[1], 'base64'); | ||
} | ||
|
||
var proto = {} | ||
|
||
proto.createType1 = function(domain, workstation) { | ||
var options = { | ||
domain: domain, | ||
workstation: workstation | ||
}; | ||
var msg = ntlm.createType1Message(options); | ||
return parsehttpntlmMsg(msg); | ||
}; | ||
|
||
proto.parseType2 = function(rawbuf) { | ||
var rsp = rawbuf.toString('base64'); | ||
rsp = 'NTLM ' + rsp; | ||
var msg = ntlm.parseType2Message(rsp,console.log); | ||
return msg; | ||
}; | ||
|
||
proto.createType3 = function(challengeNonce, options) { | ||
if(!options.workstation) { | ||
options.workstation = options.ip; | ||
} | ||
|
||
/* options to httpntlm | ||
if(!options.domain) options.domain = ''; | ||
if(!options.workstation) options.workstation = ''; | ||
if(!options.username) options.username = ''; | ||
if(!options.password) options.password = ''; | ||
*/ | ||
var msg = ntlm.createType3Message(challengeNonce, options); | ||
return parsehttpntlmMsg(msg); | ||
}; | ||
|
||
module.exports = proto; |
Oops, something went wrong.