13aal
13aal

Reputation: 1674

How to access a proxy without username and password?

I want to automate a time keeping web client, using nokogiri and mechanize. I need to connect via a proxy server, however the catch is, I don't know the username and password of said proxy server. I would like to grab the cached credentials for this proxy that are stored on the computer..

For example, in c# you can use:

string proxyUri = proxy.GetProxy(requests.RequestUri).ToString();
requests.UseDefaultCredentials = true;
requests.Proxy = new WebProxy(proxyUri, false);
requests.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

This will grab the credentials that are already logged and use them to access the proxy, does Ruby have anything of the sort? I know that you can use proxies in ruby, and it's fairly simple, however I am unable to get any of the information for the proxy (username password). This proxy is not allowing me to connect to the web. Is there a way I can get the cached credentials (username, password) and access the proxy? Or, if not possible is there a way around it?

Upvotes: 6

Views: 5648

Answers (1)

LSerni
LSerni

Reputation: 57408

You might try and retrieve them directly from the registry. The settings ought to be in

HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
    ProxyEnable      REG_DWORD
    ProxyServer      REG_SZ
    ProxyUser        REG_SZ
    ProxyPass        REG_SZ

but depending on how your utility is run, it might have troubles accessing the appropriate hive.

Or, maybe... where one utility isn't enough... use two.

Upvotes: 3

Related Questions