#!/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: # - 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/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 # PORCODIO VERS=$(curl -s "https://api.github.com/repos/gorhill/uBlock/releases/latest" | jq -r .tag_name | sed 's/..$//') mkdir -p $PROFILE_DIR/extensions cd /$PROFILE_DIR/extensions # Scarica ublock Origin wget -q https://github.com/gorhill/uBlock/releases/download/$VERS.1b7/uBlock0_$VERS.1b7.firefox.signed.xpi # Compila il manifest.json cat < $PROFILE_DIR/extensions/manifest.json { "manifest_version": 2, "name": "uBlock Origin", "version": "$VERS.1b7", "applications": { "gecko": { "id": "uBlock0@raymondhill.net" } } } EOL echo -e '\nfirefox -no-remote -P "socks5-'$PORT'"\n' # Avvia Firefox con quel profilo firefox -no-remote -P "socks5-$PORT" > /dev/null 2>&1 &