ntlm-parser
Advanced tools
Comparing version
{ | ||
"name": "ntlm-parser", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "", | ||
@@ -32,3 +32,2 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"base64-arraybuffer": "^0.2.0", | ||
"commander": "^6.2.0", | ||
@@ -35,0 +34,0 @@ "debug": "^4.2.0" |
@@ -15,3 +15,3 @@ "use strict"; | ||
const ParserFactory_1 = require("./parser/ParserFactory"); | ||
const base64_arraybuffer_1 = require("base64-arraybuffer"); | ||
const misc_1 = require("./misc"); | ||
function ntlmParse(str, opts) { | ||
@@ -23,3 +23,3 @@ const defaultOptions = { encoding: 'base64' }; | ||
} | ||
const buffer = base64_arraybuffer_1.decode(str); | ||
const buffer = misc_1.decode(str); | ||
const parser = ParserFactory_1.ParserFactory.instantiateFromContent(buffer); | ||
@@ -26,0 +26,0 @@ const object = parser.parse(); |
import { Flag } from './ntlm/interfaces'; | ||
export declare function toHex(buffer: ArrayBuffer): string; | ||
export declare function getFlags(flags: Flag[], value: number): string; | ||
export declare function decode(base64: string): ArrayBuffer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getFlags = exports.toHex = void 0; | ||
exports.decode = exports.getFlags = exports.toHex = void 0; | ||
// const debug = dbg('ntlm-parser'); | ||
@@ -17,2 +17,7 @@ function toHex(buffer) { | ||
exports.getFlags = getFlags; | ||
function decode(base64) { | ||
const b = Buffer.from(base64, 'base64'); | ||
return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength); | ||
} | ||
exports.decode = decode; | ||
//# sourceMappingURL=misc.js.map |
@@ -43,8 +43,18 @@ "use strict"; | ||
const length = dataView.getUint16(offset + 2, true); | ||
const content = Buffer.from(buffer.slice(secBuf.offset + offset + 4, secBuf.offset + offset + 4 + length)).toString('ucs2'); | ||
result.push({ | ||
const item = { | ||
type, | ||
length, | ||
content, | ||
}); | ||
content: '', | ||
}; | ||
if (type <= 5) { | ||
item.content = Buffer.from(buffer.slice(secBuf.offset + offset + 4, secBuf.offset + offset + 4 + length)).toString('ucs2'); | ||
} | ||
if (type === 7) { | ||
// filetime. | ||
const low = dataView.getUint32(offset + 4, true); | ||
const high = dataView.getUint32(offset + 8, true); | ||
const date = fileTimeToDate(high * 2 ** 32 + low); | ||
item.content = date.toISOString(); | ||
} | ||
result.push(item); | ||
offset += 2 + 2 + length; | ||
@@ -55,2 +65,5 @@ } | ||
exports.getTargetInfo = getTargetInfo; | ||
function fileTimeToDate(fileTime) { | ||
return new Date(fileTime / 10000 - 11644473600000); | ||
} | ||
function getLmResponseData(buffer, secBuf) { | ||
@@ -57,0 +70,0 @@ const buf = buffer.slice(secBuf.offset, secBuf.offset + secBuf.length); |
@@ -10,2 +10,30 @@ "use strict"; | ||
describe('NTLM TYpe 2 Unit Test', () => { | ||
it('should NTLMT2 bas64', () => { | ||
const base64 = 'TlRMTVNTUAACAAAABgAGADgAAAA1goniaaCGDXCRRNUAAAAAAAAAAIIAggA+AAAACgC6RwAAAA9KAEwARwACAAYASgBMAEcAAQAQAEMASABPAFUAQwBIAE8AVQAEABIAagBsAGcALgBsAG8AYwBhAGwAAwAkAGMAaABvAHUAYwBoAG8AdQAuAGoAbABnAC4AbABvAGMAYQBsAAUAEgBqAGwAZwAuAGwAbwBjAGEAbAAHAAgAQH6UJ9691gEAAAAA'; | ||
const props = index_1.ntlmParse(base64); | ||
assert_1.default.deepStrictEqual(props, { | ||
messageType: 'CHALLENGE_MESSAGE (type 2)', | ||
targetNameSecBuf: { length: 6, allocated: 6, offset: 56 }, | ||
flags: 'UNICODE NTLMSSP_REQUEST_TARGET SIGN SEAL NTLM ALWAYS_SIGN NTLMSSP_TARGET_TYPE_DOMAIN EXTENDED_SESSIONSECURITY TARGET_INFO VERSION 128 KEY_EXCH 56', | ||
challenge: '69a0860d709144d5', | ||
targetNameData: 'JLG', | ||
context: '0000000000000000', | ||
targetInfoSecBuf: { length: 130, allocated: 130, offset: 62 }, | ||
targetInfoData: [ | ||
{ type: 2, length: 6, content: 'JLG' }, | ||
{ type: 1, length: 16, content: 'CHOUCHOU' }, | ||
{ type: 4, length: 18, content: 'jlg.local' }, | ||
{ type: 3, length: 36, content: 'chouchou.jlg.local' }, | ||
{ type: 5, length: 18, content: 'jlg.local' }, | ||
{ type: 7, length: 8, content: '2020-11-18T19:08:09.844Z' }, | ||
{ type: 0, length: 0, content: '' }, | ||
], | ||
osVersionStructure: { | ||
majorVersion: 10, | ||
minorVersion: 0, | ||
buildNumber: 18362, | ||
unknown: 15, | ||
}, | ||
}); | ||
}); | ||
it('should NTLMT2_hex', () => { | ||
@@ -12,0 +40,0 @@ const hex = '4e544c4d53535000020000000c000c003000000001028100' + |
@@ -23,3 +23,2 @@ "use strict"; | ||
const props = index_1.ntlmParse(base64); | ||
console.log('props: ', props); | ||
assert_1.default.deepStrictEqual(props, { | ||
@@ -69,3 +68,2 @@ messageType: 'NEGOTIATE_MESSAGE (type 3)', | ||
const props = index_1.ntlmParse(base64); | ||
console.log('props: ', props); | ||
assert_1.default.deepStrictEqual(props, { | ||
@@ -72,0 +70,0 @@ messageType: 'NEGOTIATE_MESSAGE (type 3)', |
@@ -5,2 +5,4 @@ # Changelog | ||
### [1.0.7](https://github.com/jlguenego/ntlm-parser/compare/v1.0.6...v1.0.7) (2020-11-19) | ||
### [1.0.6](https://github.com/jlguenego/ntlm-parser/compare/v1.0.5...v1.0.6) (2020-11-18) | ||
@@ -7,0 +9,0 @@ |
{ | ||
"name": "ntlm-parser", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "", | ||
@@ -32,3 +32,2 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"base64-arraybuffer": "^0.2.0", | ||
"commander": "^6.2.0", | ||
@@ -35,0 +34,0 @@ "debug": "^4.2.0" |
import {ParserFactory} from './parser/ParserFactory'; | ||
import {decode} from 'base64-arraybuffer'; | ||
import {NTLMMessage, NtlmParseOptions} from './ntlm/interfaces'; | ||
import {decode} from './misc'; | ||
@@ -5,0 +5,0 @@ export function ntlmParse( |
@@ -17,1 +17,6 @@ // import dbg from 'debug'; | ||
} | ||
export function decode(base64: string): ArrayBuffer { | ||
const b = Buffer.from(base64, 'base64'); | ||
return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength); | ||
} |
@@ -8,2 +8,3 @@ import { | ||
TargetInfo, | ||
TargetInfoSubBlock, | ||
} from './interfaces'; | ||
@@ -60,13 +61,23 @@ | ||
const length = dataView.getUint16(offset + 2, true); | ||
const content = Buffer.from( | ||
buffer.slice( | ||
secBuf.offset + offset + 4, | ||
secBuf.offset + offset + 4 + length | ||
) | ||
).toString('ucs2'); | ||
result.push({ | ||
const item: TargetInfoSubBlock = { | ||
type, | ||
length, | ||
content, | ||
}); | ||
content: '', | ||
}; | ||
if (type <= 5) { | ||
item.content = Buffer.from( | ||
buffer.slice( | ||
secBuf.offset + offset + 4, | ||
secBuf.offset + offset + 4 + length | ||
) | ||
).toString('ucs2'); | ||
} | ||
if (type === 7) { | ||
// filetime. | ||
const low = dataView.getUint32(offset + 4, true); | ||
const high = dataView.getUint32(offset + 8, true); | ||
const date = fileTimeToDate(high * 2 ** 32 + low); | ||
item.content = date.toISOString(); | ||
} | ||
result.push(item); | ||
offset += 2 + 2 + length; | ||
@@ -77,2 +88,6 @@ } | ||
function fileTimeToDate(fileTime: number) { | ||
return new Date(fileTime / 10000 - 11644473600000); | ||
} | ||
export function getLmResponseData( | ||
@@ -79,0 +94,0 @@ buffer: ArrayBuffer, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
72889
8.75%2
-33.33%69
4.55%1241
6.89%- Removed
- Removed