158 lines
4.5 KiB
Bash
Executable File
158 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
function istruzioni() {
|
|
echo -e "\n[Utility per tunnel SOCKS5 su Chromium]"
|
|
echo
|
|
echo "utilizzo: ffproxy <1025-65535> [-i] [-p]"
|
|
echo
|
|
echo "esempio:"
|
|
echo "Su una finestra del terminale: ssh user@server.mio -D 1234"
|
|
echo "Su un'altra finestra del terminale: ffproxy 1234"
|
|
echo "Argomenti"
|
|
echo "-i attiva incognito mode"
|
|
echo "-p uBlock Origin preinstallato"
|
|
echo -e "-h Mostra questo help\n"
|
|
|
|
}
|
|
|
|
function sed_extensions-preferences() {
|
|
# Aspetta 3 secondi (per far creare il file extension-preferences.json) e poi lo modifica
|
|
sleep 3
|
|
ls $PROFILE_DIR/extension-preferences.json
|
|
sed -i '$ s/}/,"uBlock0@raymondhill.net":{"permissions":["internal:privateBrowsingAllowed"],"origins":[]}}/' $PROFILE_DIR/extension-preferences.json
|
|
}
|
|
|
|
# Funzione scarica e installa ublock origin
|
|
function ublock() {
|
|
|
|
# Se la cartella del profilo socks-$PORT non esiste
|
|
if [ ! -d "/home/$USER/.mozilla/firefox/socks5-$PORT/extensions" ]; then
|
|
# Trova la versione attuale e crea la cartella con il nome della porta
|
|
VERS=$(curl -s "https://api.github.com/repos/gorhill/uBlock/releases/latest" | jq -r .tag_name )
|
|
LINK_VERS=$(curl -s https://api.github.com/repos/gorhill/uBlock/releases/latest | jq -r '.assets[] | select(.name | test("firefox")) | .browser_download_url')
|
|
mkdir -p /$PROFILE_DIR/extensions
|
|
cd /$PROFILE_DIR/extensions
|
|
|
|
# Scarica ublock Origin
|
|
wget -q $LINK_VERS
|
|
echo -e "\n Scarico il file: $LINK_VERS\n"
|
|
|
|
# # Compila il manifest.json
|
|
cat <<EOL > /$PROFILE_DIR/extension-settings.json
|
|
{
|
|
"version": 3,
|
|
"url_overrides": {},
|
|
"prefs": {
|
|
"websites.hyperlinkAuditingEnabled": {
|
|
"initialValue": {},
|
|
"precedenceList": [
|
|
{
|
|
"id": "uBlock0@raymondhill.net",
|
|
"installDate": 1755534027851,
|
|
"value": false,
|
|
"enabled": true
|
|
}
|
|
]
|
|
},
|
|
"network.networkPredictionEnabled": {
|
|
"initialValue": {},
|
|
"precedenceList": [
|
|
{
|
|
"id": "uBlock0@raymondhill.net",
|
|
"installDate": 1755534027851,
|
|
"value": false,
|
|
"enabled": true
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"tabHideNotification": {},
|
|
"homepageNotification": {},
|
|
"default_search": {},
|
|
"newTabNotification": {},
|
|
"commands": {}
|
|
}
|
|
EOL
|
|
|
|
fi
|
|
|
|
# da il nome giusto al file xpi
|
|
name=$(ls $PROFILE_DIR/extensions/uBlock*)
|
|
mv "$name" "$PROFILE_DIR/extensions/uBlock0@raymondhill.net.xpi"
|
|
}
|
|
|
|
|
|
# Mostra Help
|
|
if [ "$1" = "-h" -o "$1" = "--help" ]
|
|
then
|
|
istruzioni
|
|
exit 3
|
|
fi
|
|
|
|
# Variabili
|
|
PORT=$1
|
|
PROFILE_DIR="$HOME/.mozilla/firefox/socks5-$PORT"
|
|
LINK_VERS=""
|
|
VERS=""
|
|
incognito_option=""
|
|
plugin_option=""
|
|
dio="ciao"
|
|
|
|
# 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 'u/ser_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
|
|
|
|
|
|
# mette nella var il path sbagliato
|
|
schifo=$(awk '/socks5-'$PORT'/ && /Path/ {print; exit}' $HOME/.mozilla/firefox/profiles.ini)
|
|
# cancella la cartella con nome sbagliato
|
|
dio=$(echo $schifo | sed 's/Path=//g')
|
|
rm -rf "$HOME/.mozilla/firefox/$dio"
|
|
# sotituisce il testo sbagliato con quello giusto nel file profiles.ini
|
|
sed -i '/socks5-'$PORT'/ { /Path/ s/'$schifo'/Path=socks5-'$PORT'/; }' $HOME/.mozilla/firefox/profiles.ini
|
|
|
|
|
|
# Check argomenti
|
|
for arg in "$@"; do
|
|
case $arg in
|
|
-i)
|
|
incognito_option=" --private-window "
|
|
;;
|
|
-p)
|
|
ublock
|
|
;;
|
|
-ip)
|
|
incognito_option=" --private-window "
|
|
ublock
|
|
;;
|
|
-pi)
|
|
ublock
|
|
incognito_option=" --private-window "
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
# Mostra comando da avviare
|
|
echo -e '\nfirefox'$incognito_option'-no-remote -P "socks5-'$PORT'"\n'
|
|
|
|
# Avvia Firefox con quel profilo
|
|
firefox $incognito_option -no-remote -P "socks5-$PORT" > /dev/null 2>&1 &
|
|
|
|
|
|
# Aspetta 3 secondi (per far creare il file extension-preferences.json) e poi lo modifica
|
|
sed_extensions-preferences
|
|
|
|
|
|
#DEV RESET
|
|
#alias RESET="cd /home/$USER/.mozilla/firefox; rm -rf /home/$USER/.mozilla/firefox/*socks5-$PORT; firefox --ProfileManager" |