otfmoscow

otfmoscow

Newbie
Статус
Offline
Joined
3/16/21
Messages
1
Reaction score
2
Good afternoon everyone, today I’ll tell you and show you how to make your own VPN tool in Linux.


This tool is written in Bash, parses the VPN Gate list, and then connects to random configs.

Let's get started....=)

Step 1

Download openvpn on linux

Bash:
sudo apt install openvpn

Step 2

Create a file autovpn.sh and copy this code into it:
Bash:
Code:
#!/bin/bash

# autovpn3, coded by MiAl,
# you can leave a bug report on the page: https://miloserdov.org/?p=5858

# you can change these parameters:
country='' # empty for any or JP, KR, US, TH, etc.
useSavedVPNlist=0 # set to 1 if you don't want to download VPN list every time you restart this script, otherwise set to 0
useFirstServer=0 # set the value to 0 to choose a random VPN server, otherwise set to 1 (maybe the first one has higher score)
vpnList='/tmp/vpns.tmp'
proxy=0 # replace with 1 if you want to connect to VPN server through a proxy
proxyIP=''
proxyPort=8080
proxyType='socks' # socks or http

# don't change this:
counter=0
VPNproxyString=''
cURLproxyString=''

if [ $proxy -eq 1 ];then
echo 'We will use a proxy'
if [ -z "$proxyIP" ]; then
echo "To use a proxy, you must specify the proxy's IP address and port (hardcoded in the source code)."
exit
else
if [ "$proxyType" == "socks" ];then
VPNproxyString=" --socks-proxy $proxyIP $proxyPort "
cURLproxyString=" --proxy socks5h://$proxyIP:$proxyPort "
elif [ "$proxyType" == "http" ];then
VPNproxyString=" --http-proxy $proxyIP $proxyPort "
cURLproxyString=" --proxy http://$proxyIP:$proxyPort "
else
echo 'Unsupported proxy type.'
exit
fi
fi
fi

if [ $useSavedVPNlist -eq 0 ];then
echo 'Getting the VPN list'
curl -s $cURLproxyString https://www.vpngate.net/api/iphone/ > $vpnList
elif [ ! -s $vpnList ];then
echo 'Getting the VPN list'
curl -s $cURLproxyString https://www.vpngate.net/api/iphone/ > $vpnList
else
echo 'Using existing VPN list'
fi

while read -r line ; do
array[$counter]="$line"
counter=$counter+1
done < <(grep -E ",$country" $vpnList)

CreateVPNConfig () {
if [ -z "${array[0]}" ]; then
echo 'No VPN servers found from the selected country.'
exit
fi

size=${#array[@]}

if [ $useFirstServer -eq 1 ]; then
index=0
echo ${array[$index]} | awk -F "," '{ print $15 }' | base64 -d > /tmp/openvpn3
else
index=$(($RANDOM % $size))
echo ${array[$index]} | awk -F "," '{ print $15 }' | base64 -d > /tmp/openvpn3
fi

echo 'Choosing a VPN server:'
echo "Found VPN servers: $((size+1))"
echo "Selected: $index"
echo "Country: `echo ${array[$index]} | awk -F "," '{ print $6 }'`"
}

while true
do
CreateVPNConfig
echo 'Trying to start OpenVPN client'
sudo openvpn --config /tmp/openvpn3 $VPNproxyString
read -p "Try another VPN server? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit
done

Step 3

Assign the file permissions to run:

Bash:
Code:
chmod +x autovpn.sh


Step 4

Run with sudo:


Bash:
sudo ./autovpn.sh





The script will collect information about the vpn and launch openvpn.
You can read more at kali tools

P.S. If it doesn’t load, you can press Ctrl + C, the console will ask you to select another vpn or finish the job.
 

Griffin18

Griffin18

Local
Статус
Offline
Joined
9/29/21
Messages
26
Reaction score
0
Thank you for such a nice thing.
What else are you doing on Linux?
 
Top