NTLM proxy without password?

天大地大妈咪最大 提交于 2019-11-28 03:15:58
Nick Fortescue

In the absence of an answer from someone else here is what I have discovered, I hope it is useful for someone else.

Executive Summary:

  1. Download SSPI enabled curl from http://curl.haxx.se/latest.cgi?curl=win32-ssl changing to Windows, zip, SSL-enabled, SSPI-enabled (7.19.5).
  2. Install Windows Open-SSL from http://www.slproweb.com/products/Win32OpenSSL.html and make a donation to support his bandwidth cost.
  3. Install the Visual C++ 2008 redistributables if you need them.
  4. Use curl to fetch the page: curl.exe -U : --proxy-ntlm --proxy myproxy.com:8080 http://www.google.com

More detailed explanation

The magic phrase for authentication using the Windows login mechanism is SSPI. This gives a good google search phrase. I still haven't found a good way of using SSPI for HTTP proxy authentication in java or wget though.

However, curl (the download tool) does support SSPI but only in certain builds. Unfortunately the default cygwin build is not one of them. You can find out if your build of curl supports SSPI by getting the verbose version information:

curl -v -V

If SSPI is supported it will be mentioned in the features line.

To get a windows version that supported SSPI I had to go to http://curl.haxx.se/latest.cgi?curl=win32-ssl and then change the download choice to Windows, zip, SSL-enabled, SSPI-enabled (7.19.5). By the time you read this the version number may have changed.

This then silently failed from the command line. When I ran from windows explorer I got a message about a missing libeay32.dll. One way of getting this from windows is from the only link at openssl.org to a windows version. The producer of this requests a donation to cover bandwidth costs. Another way would be to build your own from source.

And after all that curl worked with the following command line:

curl.exe -U : --proxy-ntlm --proxy myproxy.com:8080 http://www.google.com

The -U : configures no password, the other commandline options set up the proxy. You'll probably have to change your proxy and port settings.

This would all be much easier if only cygwin's curl release supported SSPI. I'm going to go put in a request for that now.

Please note my edit contains an inaccurate assumption about -U and -u. I have submitted a correction, but in the interim note:

curl -U = Authentication to a proxy
curl -u = Authentication to a server

Therefore, the first command should be:

curl.exe -U : --proxy-ntlm --proxy myproxy.com:8080 http://www.google.com

and the second one, in the example for transparent NTLM:

curl -v -u : --ntlm [the redirection URL from Location: header]  

Sorry about that!

Might be a bit late but wanted to mention this nonetheless. The original question is generically asking about NTLM proxy auth without passwords on Windows where user has already logged in. No doubt curl can do this but I wanted to give another option.

NTLMAps and Cntlm are proxies that do the NTLM auth as an intermediary proxy. However, they both require the user/pass since they are mostly targeted towards Linux users. I historically used these tools on Windows but was annoyed by the same requirement of having to provide the credentials to them.

As a result, I've authored Px for Windows which is an HTTP proxy like the above two, but uses SSPI to manage the required authentication with the corporate proxy. All you need to configure is the proxy server and port. It helps for existing applications that cannot talk through NTLM proxies such as pip and npm for example.

For developing your own apps, the code should also help figure out how to do this within Python and perhaps languages which have access to SSPI.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!