Remembering Full Metal Jacket, I asked myself why I didn't ever give a my OWN order to Linux! And tonight I give an answer to myself!
Tonight I'm managing a Kali Linux virtual machine to work with Tor and Privoxy. Since always typing sudo /etc/init.d/tor start, sudo /etc/init.d/privoxy start, and relative stop is so annoyed, now we make a new own command for Linux OS, made like a simple script to manage the start and stop of tor and privoxy. Let's suppose that tor and privoxy are installed and configured as I described in THIS post,
LET'S START TO GIVE AN OWN ORDER TO LINUX
First, we need to create a bash script called anonymous by a text editor, for example:
- sudo gedit anonymous
The content of the script will be:
#!/bin/bash
#anonymous command lets you to connect using Tor and Privoxy. Ensure you are installed them. Ensure to configure the privoxy conf file.
function setproxy
{
HTTP_PROXY_HOST=127.0.0.1
HTTP_PROXY_PORT=8118
HTTPS_PROXY_HOST=127.0.0.1
HTTPS_PROXY_PORT=8118
FTP_PROXY_HOST=127.0.0.1
FTP_PROXY_PORT=8118
SOCKS_PROXY_HOST=127.0.0.1
SOCKS_PROXY_PORT=8118
gsettings set org.gnome.system.proxy mode manual
gsettings set org.gnome.system.proxy.http host "$HTTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.http port "$HTTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.https host "$HTTPS_PROXY_HOST"
gsettings set org.gnome.system.proxy.https port "$HTTPS_PROXY_PORT"
gsettings set org.gnome.system.proxy.ftp host "$FTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.ftp port "$FTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.socks host "$SOCKS_PROXY_HOST"
gsettings set org.gnome.system.proxy.socks port "$SOCKS_PROXY_PORT"
}
function noproxy
{
HTTP_PROXY_HOST=""
HTTP_PROXY_PORT="0"
HTTPS_PROXY_HOST=""
HTTPS_PROXY_PORT="0"
FTP_PROXY_HOST=""
FTP_PROXY_PORT="0"
SOCKS_PROXY_HOST=""
SOCKS_PROXY_PORT="0"
gsettings set org.gnome.system.proxy mode none
gsettings set org.gnome.system.proxy.http host "$HTTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.http port "$HTTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.https host "$HTTPS_PROXY_HOST"
gsettings set org.gnome.system.proxy.https port "$HTTPS_PROXY_PORT"
gsettings set org.gnome.system.proxy.ftp host "$FTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.ftp port "$FTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.socks host "$SOCKS_PROXY_HOST"
gsettings set org.gnome.system.proxy.socks port "$SOCKS_PROXY_PORT"
}
function anon
{
flag="$(gsettings get org.gnome.system.proxy mode)"
if [ "$flag" == "'manual'" ]
then
echo ""
echo "Would you make yourself anonymous or would you stop anonymizing?"
while [ "$choice" != "start" ] && [ "$choice" != "stop" ] && [ "$choice" != "exit" ]; do
echo "Type:"
echo "start --> Go Anonymous"
echo "stop --> Stop Anonymizing"
echo "exit --> Return to main menu"
read -p "Choose: " choice
echo ""
case $choice in
"start") echo "Go anonymizing..."; sudo /etc/init.d/tor start; sudo /etc/init.d/privoxy start; echo "You are Anonymous!";;
"stop") sudo /etc/init.d/tor stop; sudo /etc/init.d/privoxy stop; echo "Stop anonymizing!"; echo "Returning to No Proxy mode"; noproxy;;
"exit") echo "Return to menu...";;
*) echo "Wrong choice!";;
esac
echo ""
done
else
echo "You can't start tor and privoxy because the system is not in proxy mode. Please, return to main menu and set proxy mode"
fi
}
function verifyIP
{
gnome-terminal -x bash -c "echo -n Waiting for IP address:; wget http://ipecho.net/plain -O - -q; echo; echo; echo Press a key to close the window; read -n1"
}
function checkstatus
{
echo "Tor Status: "
sudo /etc/init.d/tor status
echo ""
echo "Privoxy Status: "
sudo /etc/init.d/privoxy status
echo ""
echo "System Network Status: $(gsettings get org.gnome.system.proxy mode) mode"
HTTP_H=$(gsettings get org.gnome.system.proxy.http host)
HTTP_P=$(gsettings get org.gnome.system.proxy.http port)
echo "HTTP --> ${HTTP_H//\'}:$HTTP_P"
HTTPS_H=$(gsettings get org.gnome.system.proxy.https host)
HTTPS_P=$(gsettings get org.gnome.system.proxy.https port)
echo "HTTPS --> ${HTTPS_H//\'}:$HTTPS_P"
FTP_H=$(gsettings get org.gnome.system.proxy.ftp host)
FTP_P=$(gsettings get org.gnome.system.proxy.ftp port)
echo "FTP --> ${FTP_H//\'}:$FTP_P"
SOCKS_H=$(gsettings get org.gnome.system.proxy.socks host)
SOCKS_P=$(gsettings get org.gnome.system.proxy.socks port)
echo -n "SOCKS --> ${SOCKS_H//\'}:$SOCKS_P"
echo ""
}
choice=0
while [ "$choice" != "6" ]; do
choice=""
echo "Menu:"
echo "1- Set HTTP, HTTPS, FTP and SOCKS Proxy for Tor and Privoxy at system-wide"
echo "2- Set No Proxy connection (in this mode Tor and Privoxy don't work)"
echo "3- Anonymizing"
echo "4- Verify your IP"
echo "5- Check the current status of the system"
echo "6- Exit"
read -p "Choose: " choice
echo ""
case $choice in
"1") setproxy; echo "Proxy mode set!";;
"2") noproxy; echo "You result with your real IP";;
"3") anon ;;
"4") verifyIP;;
"5") checkstatus;;
"6") echo "Exiting...";;
*) echo "Wrong choice!";;
esac
echo ""
done
Anyway, now it is a simple stupid file! We need to let it to transform in a Super Saiyan Linux Command, so we avoid to type source anonymous in the working directory to execute the program. So, to make it a TRUE command, we need to move this file in /usr/bin directory:
- sudo chmod +x anonymous
- sudo mv anonymous /usr/bin/
Now, in any directory, try to type anonymous command and you will see that it is a SUPER SAIYAN command! We can execute it in any directory like other Linux commands!
For tonight, I leave you with this image (since in Italian cinema will be released the last film of Dragon Ball Z: Fukkatsu no F *-*)
The philosophy is: if your hair always changes colour, you will be
STRONGER
Nessun commento:
Posta un commento