如何使用 NTLM 身份验证测试 HTTP 客户端?
我有一些充当 HTTP 客户端的代码,它支持基本身份验证以及 NTLM 身份验证。我可以通过需要用户名/密码来访问 Apache 服务器上的 .htaccess
中的文件来轻松测试基本身份验证是否有效。但是,如果不安装 IIS,如何测试 NTLM 身份验证呢?是否有任何公共 HTTP 服务器接受 NTLM 身份验证?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一直在寻找同样的问题(“如何设置 ntlm 代理虚拟服务器”)并找到了这个。这是我的解决方案,介绍如何在不使用 Microsoft IIS 服务器的情况下为代理服务器设置转发 NTLM 身份验证。相反,我们将使用 Apache httpd.exe
我使用了 ApacheHaus 的 Windows 32 位 (VC14) 版本二进制文件
现在再次编辑conf/httpd.conf配置文件,并进行以下更改:
启用代理服务器。请注意,您可能会打开一个开放的代理服务器到互联网...
或者,如果您只想保护一个目录,您可以从 mod_authn_ntml 配置示例中复制代码:
要捕获本地环回流量并调试发生了什么,您需要安装 Wireshark 2.4.4,然后安装特殊的 npcap-0.97.exe 环回捕获驱动程序。这样您就可以嗅探浏览器和本地网络服务器之间的流量
如果您想对代理服务器使用 NTLM 身份验证,您需要遵循 mod_ntlmn_auth GitHub 页面的建议,并在注册表中设置标志 DisableLoopbackCheck(请参阅 https://support.microsoft.com/en-us/kb/896861 ),否则所有本地身份验证请求都会失败.
将您的浏览器设置为使用您的本地 IP 地址作为代理服务器。如果一切正常,浏览器将在后台发送您的凭据。
要查看发生了什么,您现在可以检查 Wireshark 日志,并且 Apache 日志/access.log 还会向您显示用于身份验证的域\用户。
希望这可以帮助人们测试他们的代理脚本,因为我遇到的很多代理软件都无法正确处理 NTLM 代理,这在商业环境中很重要。
I was looking for the same question ("how to set-up a ntlm proxy dummy server") and found this. So here is my solution, on how to set up a forwarding NTLM authentication for a proxy server, without using IIS server from Microsoft. Instead we will use Apache httpd.exe
I used the windows 32bit (VC14) version binaries from ApacheHaus
Now edit the conf/httpd.conf configure file again, and make these changes:
Enable the proxy server. Be warned, you may open an open proxy server to the internet...
Or, if you just want to secure just one directory, you can copy the code from the mod_authn_ntml config example:
To capture the local loopback traffic and to debug what's going on, you need to install Wireshark 2.4.4 and then the special npcap-0.97.exe loopback-capture driver. With this you can sniff the traffic between your browser and your local web-server
If you want to use the NTLM authentication for the proxy server, you will need to follow the advice from mod_ntlmn_auth GitHub page and set the flag DisableLoopbackCheck in the registry (see https://support.microsoft.com/en-us/kb/896861 ), otherwise all local authentication requests will silently fail.
Set up your browser to use your local IP address as a proxy server. If everything works, the browser will send your credentials in the background.
To see what's going on, you can now check your Wireshark logs, and the also the Apache logs/access.log shows you the Domain\User that was used for authentication.
Hope that helps someone out there to test their proxy scripts, because a lot of proxy software I encounter can't handle NTLM proxies correctly, which is important in a business environment.
您可能已经意识到,由于 NTLM 是一种专有身份验证协议(没有 Microsoft 提供的任何官方公共文档),因此您必须针对在 Windows 上运行的实际 IIS 服务器进行测试,或者您可以尝试使用从文档中收集的详细信息来模拟身份验证方案,例如:
您不会找到很多公共 HTTP 服务器(如果有的话) )在互联网上您可以对其进行测试。 NTLM 身份验证通常部署供企业使用,例如针对 Active Directory 进行身份验证,并且通常锁定在公司 VPN 后面。
我会硬着头皮在虚拟机中启动一个 Windows 实例(Microsoft 让您下载大量 Windows 2008 的 120 天试用版等)并对其进行测试。
As you have probably already realised, because NTLM is a proprietary authentication protocol (that doesn't have any official public documentation provided by Microsoft), you're going to have to either test against an actual IIS server running on Windows, or you could try and mock the authentication scheme using details gleaned from documentation such as this:
You won't find many public HTTP servers (if any) on the internet that you'll be able to test against. NTLM authentication is generally deployed for corporate use such as authenticating against Active Directory and are most often locked behind company VPN's.
I'd bite the bullet and fire up an instance of Windows (Microsoft let you download plenty of 120 day trials of Windows 2008 etc) in a Virtual Machine and test against that.