2

I wrote a bash script that reads a username and password from www.vpnbook.com/freevpn and then cleverly automates the vpn. Following is a code segment. I want the Stack Community to hide my xterm -e -hold ./Overflow.sh I have tried nohup and applying & which is not working at all. I want the xterm window to become invisible to the user. The user shouldn't know what's happening and even if he closes the terminal windows the task should not end.

Following is my code: (Contributed to my beloved Stack Community)

 Overflow.sh
    #!/usr/bin/expect -f
    spawn openvpn vpnbook-ca1-udp25000.ovpn
    #spawn ssh aspen
    set password [lindex $argv 1]
    expect "Enter Auth Username: "
    send "vpnbook\r"
    expect "Enter Auth Password: "
    send "he2qv5h\r";
    interact

Web-Scraper.sh
#!/bin/bash
clear
echo "Copyright of KatworX© Tech. Developed by Arjun Singh Kathait and Debugged by the ☆Stack Overflow Community☆"
echo

# Creating a Spinner Animation.
spinner()
{
    local pid=$!
    local delay=0.75
    local spinstr='|/-\'
    while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
        local temp=${spinstr#?}
        printf " [%c]  " "$spinstr"
        local spinstr=$temp${spinstr%"$temp"}
        sleep $delay
        printf "\b\b\b\b\b\b"
    done
    printf "    \b\b\b\b"
}

    ProgMeter() 
    {
    function ProgressBar 
        {
        let _progress=(${1}*100/${2}*100)/100
        let _done=(${_progress}*4)/10
        let _left=40-$_done

        # Building the String length of the Progress Meter 
        _fill=$(printf "%${_done}s")
        _empty=$(printf "%${_left}s")

        # 1.2.1 Output example:
        # 1.2.1.1 Progress : [████████████████████████████████████████] 100%
        printf "\rProcessing Dump : [${_fill// /█}${_empty// /-}] ${_progress}%%"
        }

    # Variables
    _start=1

    # This accounts as the "totalState" variable for the ProgressBar function
    _end=100

    # Proof of concept
    for number in $(seq ${_start} ${_end})
        do
            sleep 0.1
            ProgressBar ${number} ${_end}
        done
    echo -e "\n" 
    echo -e "Succesfully Altered the IP."
    echo
    }



#echo -e "Fetching Network Information"
sleep 5 & spinner
python StackReader.py

echo
w3m https://www.vpnbook.com/freevpn -dump > Log.txt & ProgMeter
sleep 2



#   `Password Extracter
i=0
while read -r line; do
    # changed ++i == 15 to 3
    ((++i == 44)) || continue
    arr=($line)
    #changed arr[n]
    Pass="${arr[2]}"
    echo $Pass
    break

done < /root/Desktop/Pit-Wolf/Log.txt
#   End of Password Extracter`



#VPNBook is a Virtual Private Network provider that uses an 3ncrypted connection to alternate the user's original IP address. Although it is still unknown who is behind this service and how it receives it's funding, it is still free to use and it was reviewed in a special article of the PC Magazine, where its said that the service "HAS CERTAIN FUNCTIONALITY FLAWS, BUT IS GOOD FOR A FREE VPN SERVICE". It was also reviewed by "BestVPN portal".


echo -ne '\007'
chmod +x Overflow.sh
xterm -hold -e ./Overflow.sh

Also,Is there a way to pass the value of $Pass to Overflow.sh??? Also note, I have 4 files downloaded from the website in the same folder.

Any help would be appreciated by my bothers and sisters in the stack community.(apart from moderators)

ASK Arjun
  • 111
  • 1
  • 18

1 Answers1

0

Try using:

./Overflow.sh &`

Hope that fixes the issue.

Ramesh
  • 102
  • 10