Bash script to automate a VPN from vpnbook com

0 votes

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)

May 27, 2022 in Linux Administration by Rahul
• 3,380 points
1,664 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
0 answers

How to send control+c from a bash script?

I'm starting a number of screens in ...READ MORE

Jun 16, 2022 in Linux Administration by Rahul
• 3,380 points
764 views
0 votes
0 answers

How to detect the OS from a Bash script?

I would like to keep my .bashrc and .bash_login files in ...READ MORE

Jun 21, 2022 in Linux Administration by Korak
• 5,820 points
553 views
0 votes
0 answers

How to detect the OS from a Bash script?

I would like to keep my .bashrc ...READ MORE

Jun 22, 2022 in Linux Administration by Korak
• 5,820 points
590 views
0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31, 2019 in Linux Administration by Omkar
• 69,220 points
1,146 views
0 votes
1 answer

How to find the first field from a file in Bash Shell?

Hi@akhtar, You can extract text from a file. ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,460 points
1,086 views
0 votes
1 answer

Why do you need to put #!/bin/bash at the beginning of a script file?

It's a show so the *nix shell ...READ MORE

answered Jun 20, 2022 in Linux Administration by Rahul
• 3,380 points
1,159 views
0 votes
0 answers

How can I get the directory where a Bash script is located from within the script itself?

How do I get the path of ...READ MORE

Jun 21, 2022 in Linux Administration by Korak
• 5,820 points
460 views
0 votes
1 answer

setting a variable output from a bash command

You can use $(command), which in my ...READ MORE

answered Feb 15, 2019 in Linux Administration by DareDev
• 6,890 points
2,542 views
0 votes
2 answers

how to loop through the content of a file using bash

#!/bin/bash for i in  `cat peptides.txt` do echo $i done READ MORE

answered Sep 5, 2020 in Linux Administration by Prakash K. Aithal
2,998 views
0 votes
1 answer

To run a shell script on a Unix console or Mac terminal

To run a non-executable sh script, use: sh myscript To run ...READ MORE

answered May 16, 2019 in Linux Administration by Upasana
• 8,620 points
853 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP