NTLM 认证的过程, Client 需发送或接受三种讯息: Negotiation, Challenge, Authentication, 其过程如下:
1. Client 发送 Negotiation 给 Server, 告知 Server 通讯的信息, 内容含有 NTLM 的表头及 NTLM 标志位, 我们称为 Type 1 Message.
2. Server 在收到 Negotiation 后会随机产生一组长度为 8 bytes 的 NONCE, 并伴随者 Negotiation 所含内容及 Data Block 返回 Client, 这讯息称之为 Type 2 Message.
3. Client 在收到 Challenge 后会以 PASSWORD 当作 KEY 并对 NONCE 进行加密产生两组回应段 - LMRESP 及 NTRESP, 并伴随者 DOMAIN, USER 讯息, 当作身份认证讯息发送给 Server. 这个身份认证的讯息,我们称之为 Type 3 Message.
不管是 Type 1 或 Type 2 或是 Type 3 都是 "NTLM" + Base64 String, 所以如果要还原它们的话, 要先做解码的动作, 在 Perl 上很容易实现这个 Parsing 的动作, 以下为 Perl 的实现代码: decode.pl
#!/usr/bin/perl -w
use MIME::Base64;
$string = shift;
print decode_base64($string);
在 Linux 终端下执行 decode.pl <input-string> | hexdump -C, <input-string> 是需要解析的 BASE64 字串.
接着我们实际来看看真实的 Type 1 Message 及其解析出来的内容: