zoukankan      html  css  js  c++  java
  • NTLM验证过程

    中我们介绍Kerberos认证的整个流程。在允许的环境下,Kerberos是首选的认证方式。在这之前,Windows主要采用另一种认证协议 ——NTLM(NT Lan Manager)。NTLM使用在Windows NT和Windows 2000 Server(or later)工作组环境中(Kerberos用在域模式下)。在AD域环境中,如果需要认证Windows NT系统,也必须采用NTLM。较之Kerberos,基于NTLM的认证过程要简单很多。NTLM采用一种质询/应答(Challenge /Response)消息交换模式,右图反映了Windows2000下整个NTLM认证流程。

    步骤一

    用 户通过输入Windows帐号和密码登录客户端主机。在登录之前,客户端会缓存输入密码的哈希值,原始密码会被丢弃(“原始密码在任何情况下都不能被缓 存”,这是一条基本的安全准则)。成功登录客户端Windows的用户如果试图访问服务器资源,需要向对方发送一个请求。该请求中包含一个以明文表示的用 户名。

    image

    步骤二

    服务器接收到请求后,生成一个16位的随机数。这个随机数被称为Challenge或者Nonce。服务器在将该Challenge发送给客户端之前,该Challenge会先被保存起来。Challenge是以明文的形式发送的。

    image

    步骤三

    客户端在接收到服务器发回的Challenge后,用在步骤一中保存的密码哈希值对其加密,然后再将加密后的Challenge发送给服务器。

    image

    步骤四

    服务器接收到客户端发送回来的加密后的Challenge后,会向DC(Domain)发送针对客户端的验证请求。该请求主要包含以下三方面的内容:客户端用户名;客户端密码哈希值加密的Challenge和原始的Challenge。

    image

    步骤五、六

    DC根据用户名获取该帐号的密码哈希值,对原始的Challenge进行加密。如果加密后的Challenge和服务器发送的一致,则意味着用户拥有正确的密码,验证通过,否则验证失败。DC将验证结果发给服务器,并最终反馈给客户端。

    =======================================

    NTLM有Interactive和Noninteractive两种,Interactive就是用户登录类型的,只有client和DC两个参与者,而Noninteractive则是Client要去连接一个Server。Microsoft NTLM给出了NTLM的Noninteractive验证过程,有如下7步过程:

    1. (Interactive authentication only) A user accesses a client computer and provides a domain name, user name, and password. The client computes a cryptographic hash of the password and discards the actual password.
    2. The client sends the user name to the server (in plaintext).
    3. The server generates a 16-byte random number, called a challenge or nonce, and sends it to the client.
    4. The client encrypts this challenge with the hash of the user's password and returns the result to the server. This is called the response.
    5. The server sends the following three items to the domain controller:

      • User name
      • Challenge sent to the client
      • Response received from the client
    6. The domain controller uses the user name to retrieve the hash of the user's password from the Security Account Manager database. It uses this password hash to encrypt the challenge.
    7. The domain controller compares the encrypted challenge it computed (in step 6) to the response computed by the client (in step 4). If they are identical, authentication is successful.

    但是其中有些地方不够详细,我在本文中加以补充。NTLM是windows验证的一种,其过程如下图所示:

    下面来详细解析NTLM验证过程,仍然是七步过程:

    1. 用户登录时输入的user name、password和domain name,然后Client端计算password的hash值并保存在本地
    2. 客户端将user name的明文发送给DC
    3. DC生成一个16-byte的随机数,叫做challenge,传输给client
    4. client收到challenge以后,在复制一份拷贝,然后将其中一个challenge用password hash加密,这个叫做response,然后将challenge,response以及user name传送给server
    5. server端在收到client传送过来的三份内容以后将它们转发给DC
    6. DC在收到user name,response,challenge以后,根据user name在account database中找到其对应的password hash,然后用这个password hash加密challenge
    7. 最后一步是客户端将response跟加密后的challenge进行比较,如果相同则NTLM验证成功。

    Microsoft NTLM的 最后还提到了另外一点,就是让我们不要直接使用NTLM,而是使用negotiate。如果使用negotiate的话,那么windows会判断 kerberos是否可用,如果可用就优先使用kerberos,否则使用NTLM。kerberos的安全性要比NTLM要高。

    在sharepoint的中就有NTLM和negotiate的选择,默认选择的是NTLM,如果知道如何配置kerberos的话,建议使用negotiate模式。

  • 相关阅读:
    Windows:C:WindowsSystem32driversetchosts
    Quartz:Cron Expressions
    RabbitMQ:基本命令
    架构:一致性
    Javascript:自己写异步流程编程框架
    Python:Hello World级别的SimpleDb
    架构:互联网架构
    数据访问:三大范式
    数据访问:Implementing Efficient Transactions
    技术人生:special considerations that are very important
  • 原文地址:https://www.cnblogs.com/stephen-init/p/3497660.html
Copyright © 2011-2022 走看看