42 lines
1.2 KiB
Bash
42 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
# Lo script:
|
|
# - prende in input una porta <1025-65535>
|
|
# - crea un nuovo profilo Firefox (se non esiste) dedicato alla porta
|
|
# - imposta proxy SOCKS5 su 127.0.0.1:<porta>
|
|
# - lancia Firefox con quel profilo in background
|
|
|
|
if [ "$1" = "-h" -o "$1" = "--help" ]
|
|
then
|
|
echo "Utility per tunnel SOCKS5 su Firefox, prende in input una porta <1025-65535>"
|
|
exit 3
|
|
fi
|
|
if [ $# -ne 1 ]
|
|
then
|
|
echo "ERR - Expected: ffproxy <1025-65535>"
|
|
exit 2
|
|
fi
|
|
|
|
PORT=$1
|
|
PROFILE_DIR="$HOME/.mozilla/firefox/ffproxy/socks5-$PORT"
|
|
|
|
# Crea un nuovo profilo Firefox se non esiste
|
|
if [ ! -d "$PROFILE_DIR" ]; then
|
|
mkdir -p "$PROFILE_DIR"
|
|
firefox -no-remote -CreateProfile "socks5-$PORT" "$PROFILE_DIR"
|
|
|
|
# Modifica prefs.js con configurazione proxy
|
|
PREFS_FILE="$PROFILE_DIR/prefs.js"
|
|
echo 'user_pref("network.proxy.type", 1);' >> "$PREFS_FILE"
|
|
echo 'user_pref("network.proxy.socks", "127.0.0.1");' >> "$PREFS_FILE"
|
|
echo "user_pref(\"network.proxy.socks_port\", $PORT);" >> "$PREFS_FILE"
|
|
echo 'user_pref("network.proxy.socks_remote_dns", true);' >> "$PREFS_FILE"
|
|
fi
|
|
|
|
|
|
echo -e '\nfirefox -no-remote -P "socks5-'$PORT'"\n'
|
|
|
|
|
|
# Avvia Firefox con quel profilo
|
|
firefox -no-remote -P "socks5-$PORT" > /dev/null 2>&1 &
|