Background
FoxyProxy is a good extenstion. But the lack of keyboard shortcuts is making it somewhat troublesome.
For example. I have 4 proxies, Socks, none, BurpSuite, and ZAP.
Socks is for you-know-what, none means no proxy, BurpSuite and ZAP are for webapp testing (TryHackMe, HackTheBox, and the like). I often use Burp and ZAP together, so switching proxy is kind of a hassle.
Fortunately, FoxyProxy has patterns. So I can create patterns to direct different URL to corresponding proxy.
So, I created a script, write IP and domain to /etc/hosts
file, then I can use URL and predefined pattern to switch proxy automatically.
Solution
This is the FoxyProxy set up for BurpSuite:
This is the pattern for BurpSuite:
Set up for ZAP:
Patterns for ZAP:
Now, enter xx.burp.thm
in browser, starts Burp proxy; xx.zap.thm
starts ZAP proxy.
Next, is to put IP and domain into hosts file.
This is the script:
#!/usr/bin/env bash
sudo sed -i '' -e :a -e '$d;N;2,3ba' -e 'P;D' /etc/hosts
# first argument is IP, second argument is subdomain name
echo -e "$1\t\t$2.none.thm" | sudo tee -a /etc/hosts
echo -e "$1\t\t$2.zap.thm" | sudo tee -a /etc/hosts
echo -e "$1\t\t$2.burp.thm" | sudo tee -a /etc/hosts
When run, provide it with the target IP and the subdomain name.
For example:
./script.sh 2.2.2.2 opr
The script is going to delete 3 lines from the bottom of hosts file, and append the following.
2.2.2.2 opr.none.thm
2.2.2.2 opr.zap.thm
2.2.2.2 opr.burp.thm
The script is for you to modify.
Now, you can enter URL to start different proxies automatically.
Notice
BurpSuite is weird, it cannot resolve hostname even defined in hosts file. So you have to add Hostname resolution
by yourself. Otherwise, it just fails to resolve the hostname.
The request just fails.
Set hostname resolution here.
Add hostname and corresponding IP address.
Everything's good to go.
Now, request for bp.none.thm
, starts none
proxy; request for bp.burp.thm
, starts Burp
proxy; request for bp.zap.thm
, starts ZAP
proxy, and request for all the other URLs, starts socks
or none
proxy.
I don't know why BurpSuite acts like that (the hostname resolve thing), need to dig into that later.
Happy hacking...