Search code examples
windowsproxycredentials

Get windows proxy username/password


I have an access to a preconfigured Windows XP 32-bit workstation. It's under firewall and to get outside it uses http proxy server. To get proxy settings I need host, port, username and password.

http: // username : password @ server : port

I'm able to find the proxy url and port (from PAC - automatic config file), but I don't know how to get username/password. Is there a way to read it somehow? At least username? I might get the admin rights.

Do you know any tool that can help?

I only found these MS docs about some methods to get proxy config connection, but I don't know how to determinate what's the provided credentials:

WinHttpGetIEProxyConfigForCurrentUser function

WINHTTP_CURRENT_USER_IE_PROXY_CONFIG structure

WinHttpGetProxyForUrl function

I've also found this lib, but it's rather for parsing PAC: http://code.google.com/p/pacparser/


Solution

  • Iterating on Fernando Sanchez's answer and Robert's comment, you need to authenticate via SSPI. In my case I've connected using NTLM using this link

    With using ntlm :

    curl.exe --proxy <proxy_name>:<proxy_port> --proxy-ntlm -U : https://www.google.com
    

    Also to partially answer your question the -U : means from curl man page :

    If you use a Windows SSPI-enabled curl binary and do either Negotiate or NTLM authentication then you can tell curl to select the user name and password from your environment by specifying a single colon with this option: "-U :".

    You can get the proxy name and port from the windows registry (regedit). Quote from Robert's comment:

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]

    It can be present either in a manual way using REG_SZ ProxyServer or using an autoconfiguration script using REG_SZ AutoConfigURL = https://<configuration_url>

    If the command above fails with Failure when receiving data from the peer maybe you have a release without NTLM, SSPI or OpenSSL. Try with the latest curl release