Saturday, April 13, 2019

Easy way to restrict proxy usage only to selected websites - using a PAC file

Sometimes when you doing CTFs/bug bounties/etc, you face the need to send the traffic to a certain site through a local proxy (or remote proxy for other cases) while keeping other websites access internet directly.

This is how you can do it through a PAC file.

Step 1: 

Start your local proxy (I have started a burpsuite proxy in localhost ( on port 8080 in this case).

Step 2: 

Create a PAC file

function FindProxyForURL(url, host) {
  host = host.toLowerCase();
  if (dnsDomainIs(host, ""))
    return "PROXY"; // (IP:port)

  return "DIRECT";

Step 3: 

Configure your browser to use this PAC file for proxy resolving. (Following example is for Firefox on Windows)

Step 4:

Now use your browser to access the specific website and see your proxy show the request/response only from that specific website.

Step 5: 

If you have done any change to list of web addresses later, You do not need to restart the browser, you can go back to Proxy settings and click "Reload" file in front of PAC file url.