PacDbg + Custom Proxy Browser + Set Proxy Cmd Line Tool

My collection of proxy utils published to github. The C# .NET 4.0 source code and latest versions of these utilities is published on GitHub here:

https://github.com/chentiangemalc/ProxyUtils

To just download the pre-compiled .NET 4.0 executables (may not be latest versions):

https://skydrive.live.com/redir?resid=D1BB3113E6943B7F!3551&authkey=!AKu4VpNZzDXU51k (860 KB ZIP file)

Warning: These are quick hacked together projects and the source code is a bit of a mess and they are not fully tested. Ideally I would have fully cleaned up/tested before publishing, but considering my average work day is around 15 hrs…they were never going to get published if I waited for that… You are welcome to test & fix to your hearts content :)

PacDbg

In the past few months I’ve come across some really crazy use of Pac Files (i.e. containing the detailed network design for a large international company) In my spare time I put together a simple utility to debug pac files.

Open PacDbg and it will load your current PacFile and you can test URLs against it, and find the line of Pac file responsible for result. Also find parsing/runtime errors:

image

Note: It currently does not support the Windows 7 and later IPv6 PAC extensions, they need to be added.

Oops that didn’t work, and we get an error message giving us a clue. Fixed up:

image

Custom Proxy Browser

Uses Windows APIs to set proxy per-process, allowing this browser to use a WebBrowser controlling, and over-riding system proxy settings.

The proxy is set to either nothing or a specific proxy server via the .config file – set proxy to proxyname:port if you wanted a proxy setting. Currently it is set to use no proxy. You can further configure it via the .config file.

image

Set Proxy Command Line Tool

A command line tool to set the proxy server, also demonstrates setting proxy settings in C#

Command line options:

/proxy:[enable|disable] – Enable/Disable Proxy
/address:proxy:port – Specify Proxy Address
/pac:url – Specify PAC File URL
/autodetect:[enable|disable] – enable/disable auto detect
/exceptions:[exception list]
/connection:[connection name] – specify a dial up connection name to set proxy for
/bypasslocal – Bypass proxy for local connections.

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in .NET, C#, Command Line, Internet Explorer and tagged . Bookmark the permalink.

10 Responses to PacDbg + Custom Proxy Browser + Set Proxy Cmd Line Tool

  1. Laurence Dale says:

    Hi Malcolm,

    Great article and utility however I’m having problems with some standard PAC file syntax shown here. Can you comment on whether you can aprse this code in an updated version of the tool?

    Many thanks, Laurence

    var privateIP = /^(0|10|127|192\.168|172\.1[6789]|172\.2[0-9]|172\.3[01]|169\.254|192\.88\.99)\.[0-9.]+$/;
    var resolved_ip = dnsResolve(host);

    if (isPlainHostName(host) || isInNet(resolved_ip, “192.0.2.0”,”255.255.255.0″) || privateIP.test(host))
    return “DIRECT”;

  2. Ronsen says:

    Greetings Malcom,
    first of all great work, makes my life much more easier now! Your Custom Proxy Browser is almost perferct for my needs ;) the only thing what is missing, is the option to deny some keyboard-shortcut function like STRG+L where users have can enter a specific URL…
    Is that time-eating/hard to implement?
    Cheers Ron

  3. Ronsen says:

    Malcolm… I mean CTRL+L ;)

  4. Ronsen says:

    If I’m using SetProxy with /exceptions:*.domain.com (wildcard!) it’s seem not working..if I open the browser after running the command (IE11 in my case) and check the settings and press OK for saving again…it’s working. It looks like the IE is writing in the registry the “DefaultConnectionSettings” (BINARY) value new/again. Is there a way to fix this?

    • i’ve seen this before, i thought i fixed it, but i will check this scenario. i also have written code for writing to this registry key somewhere ….which normally i wouldn’t reccomend, but might add it back in if it’s necessary

  5. Ronsen says:

    Sweet! You are right, I wouldn’t recommend writing to the registry key directly either, because we did that in the past (and still right now) and discoverd some problems/issues when the key “ProxyOverride” and “DefaultConnectionSettings” are inconsistent…somtines Windows will reset the completly and the Proxy settings are gone. It would be also very nive to have an advanced function to just add/remove proxy exeptions (without reseting everything). Sometimes users have their own exeptions and I just want to add some…

  6. Ronsen says:

    Malcolm any news on this topic?

  7. AnthonyP69 says:

    Malcom,

    Would you be able to add some code to help deal with the issue Laurence raised? I too have the same issue with my PAC files.

    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s