Jump to content
Usr6

Automatizare VPNBOOK

Recommended Posts

Posted

Ca orice serviciu gratuit si cel oferit de https://www.vpnbook.com/ are mici "imperfectiuni", in cazul de fata, unul din ele fiind necesitatea de a vizita site-ul in mod regulat pentru obtinerea datelor de login. Prin aceasta automatizare vom elimina acest mic dezavantaj. Se presupune ca este folosit open vpn

 

Modificarea fisierului config (Locatie: C:\Program Files\OpenVPN\config\)   - pentru utilizarea datelor de logare dintr-un fisier

- in fisierul ".ovpn" vom inlocui linia:

auth-user-pass

cu :

auth-user-pass "D:\\vpn_book.txt"

Automatizare:

#Python 2.7
import urllib2
import re

vpn = "http://www.vpnbook.com/"

response = urllib2.urlopen(vpn)
data = response.read()

u = re.search("Username: (\w+)<", data)
if u:
    utilizator = u.group(1)

p = re.search("Password: (\w+)<", data)
if p:
    parola = p.group(1)

with open("D:\\vpn_book.txt", "w") as login_file:
    login_file.write(utilizator +"\n" + parola)
    login_file.close()

La fiecare rulare a scriptului de mai sus datele de login din fisierul d:\\vpn_book.txt for fi improspatate

  • Like 1
  • Upvote 5
Posted (edited)

Varianta PowerShell pentru utilizatorii Windows care nu doresc sa instaleze MareleSharpe

$request = Invoke-WebRequest -Uri 'https://www.vpnbook.com/';
if( $request.StatusCode -ne 200 )
{
    Write-Error -Message $('Failed to access website. StatusCode ' + $request.StatusCode + ': ' + $request.StatusDescription + '.' );
    break;
}

if( $request.RawContent -inotmatch 'username:\s+([\w\d]+)' )
{
    Write-Error -Message 'Failed to find username.';
    break;
}
$username = $Matches[1];

if( $request.RawContent -inotmatch 'password:\s+([\w\d]+)' )
{
    Write-Error -Message 'Failed to find password.';
    break;
}
$password = $Matches[1];

Set-Content -Path "D:\vpn_book.txt" -Force -Value $($username + "`r`n" + $password) -NoNewline -Encoding ASCII

 

Edited by u0m3
Modificare script: fara newline dupa parola si ASCII encoding
  • Upvote 3

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...