Usr6 Posted August 27, 2017 Report Posted August 27, 2017 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 1 5 Quote
u0m3 Posted August 27, 2017 Report Posted August 27, 2017 (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 August 28, 2017 by u0m3 Modificare script: fara newline dupa parola si ASCII encoding 3 Quote