-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmitmproxy.sh
More file actions
executable file
·39 lines (31 loc) · 1.08 KB
/
mitmproxy.sh
File metadata and controls
executable file
·39 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Check if mitmproxy is installed
if ! command -v mitmproxy &> /dev/null; then
echo "mitmproxy is not installed. Install it with brew then rerun this script."
exit 1
fi
# the tail command will skip the first line because it's an informational message
interfaces="$(networksetup -listallnetworkservices | tail -n +2)"
# Function to clean up proxy settings
cleanup() {
echo -e "\nCleaning up proxy settings..."
for interface in $interfaces; do
echo "Disabling proxy on $interface"
networksetup -setwebproxystate "$interface" off
networksetup -setsecurewebproxystate "$interface" off
done
exit 0
}
# Set up trap for Ctrl+C
trap cleanup SIGINT
IFS=$'\n' # split on newlines in the for loops
for interface in $interfaces; do
echo "Setting proxy on $interface"
networksetup -setwebproxy "$interface" localhost 8080
networksetup -setwebproxystate "$interface" on
networksetup -setsecurewebproxy "$interface" localhost 8080
networksetup -setsecurewebproxystate "$interface" on
done
mitmproxy
# Run cleanup even after normal exit
cleanup