def connect_purevpn(): if PUREVPN == 1: load_result = False rasdial.disconnect() division = round(float(TOTAL_CHANNEL) / len(USER_PASS)) print('Current VPN: ' + str(rasdial.get_current_vpn())) counter_connect = 0 while load_result is False and counter_connect < 4: if counter_connect >= 2: send_email_alert() counter_connect += 1 rasdial.disconnect() sleep(1) if USER_CONFIG == 'VUNPA' and NUMBER_MACHINE <= TOTAL_CHANNEL and ADS_BOTTOM == 1 and NUMBER_MACHINE <= 15: server = get_random_vpn(PURE_VPN_NAME) if NUMBER_MACHINE <= division: value = 1 elif division < NUMBER_MACHINE <= TOTAL_CHANNEL - (TOTAL_CHANNEL / len(USER_PASS)): value = 2 else: value = 3 user = USER_PASS.get(value)[0] password = USER_PASS.get(value)[1] elif USER_CONFIG == 'VUNPA' and NUMBER_MACHINE >= 20: division = NUMBER_MACHINE % 20 if division == 0: value = 1 elif division == 1: value = 2 elif division == 2: value = 3 else: value = random.randint(1, 3) server = get_random_vpn(PURE_VPN_NAME) user = USER_PASS.get(value)[0] password = USER_PASS.get(value)[1] elif USER_CONFIG != 'VUNPA' or (USER_CONFIG == 'VUNPA' and ADS_BOTTOM == 1) or ADS_BOTTOM == 0: server = get_random_vpn(PIA_VPN_NAME) user = '******' password = '******' # server = 'HMA' # user = '******' # password = '******' rasdial.connect(server, user, password) # connect to a vpn sleep(1) if check_ping_is_ok() is True: # if check_country_is_ok() is True: if set_zone() is True: load_result = True
def connect_openvpn(): CONFIG_IP = tuple(open('ressources/params_PIA/list_PIA.txt', 'r')) load_result = False while load_result is False: if sys.platform == 'win32': try: print('Try to Disconnect OpenVPN') rasdial.disconnect() # Disconnect params_PureVPN first check_output("taskkill /im openvpn.exe /F", shell=True) except: pass check_output('ipconfig /release', shell=True) check_output('ipconfig /renew', shell=True) print('Connect OpenVPN') if sys.platform == 'win32': cmd = '"C:/Program Files/OpenVPN/bin/openvpn.exe"' else: cmd = '/etc/openvpn/openvpn' value = random.randint(0, len(CONFIG_IP) - 1) print('Random Server: ' + CONFIG_IP[value].strip()) if 'privateinternetaccess' in CONFIG_IP[value].strip(): parameters = ' --client --dev tun --tun-mtu 1500 --proto udp --remote ' \ + CONFIG_IP[value].strip() + \ ' --port 1198 --resolv-retry infinite --nobind --persist-key --persist-tun' \ ' --cipher aes-128-cbc --auth sha1 --tls-client --remote-cert-tls server' \ ' --auth-user-pass ressources/params_PIA/data/auth.txt --comp-lzo --verb 1 --reneg-sec 0' \ ' --crl-verify ressources/params_PIA/data/crl.rsa.2048.pem' \ ' --auth-nocache' \ ' --block-outside-dns' \ ' --ca ressources/params_PIA/data/ca.rsa.2048.crt' cmd += parameters try: subprocess.Popen(cmd) print('Please wait to connect to OpenVPN...') countdown(8) except: pass print('Check PING...') hostname = 'bing.com' try: response = os.system("ping -n 1 " + hostname) if response == 0: load_result = True except: connect_openvpn()
def connect_openvpn(): load_result = False counter_connect = 0 while load_result is False and counter_connect < 4: if counter_connect >= 2: send_email_alert() counter_connect += 1 if sys.platform == 'win32': try: print('Try to Disconnect OpenVPN') rasdial.disconnect() # Disconnect params_PureVPN first check_output("taskkill /im openvpn.exe /F", shell=True) except: pass check_output('ipconfig /release', shell=True) check_output('ipconfig /renew', shell=True) print('Connect OpenVPN') if sys.platform == 'win32': cmd = '"C:/Program Files/OpenVPN/bin/openvpn.exe"' else: cmd = '/etc/openvpn/openvpn' value = random.randint(0, len(CONFIG_IP) - 1) print('Random Server: ' + CONFIG_IP[value].strip()) if 'privateinternetaccess' in CONFIG_IP[value].strip(): parameters = ' --client --dev tun --proto udp --remote ' \ + CONFIG_IP[value].strip() + \ ' --port 1198 --resolv-retry infinite --nobind --persist-key --persist-tun' \ ' --cipher aes-128-cbc --auth sha1 --tls-client --remote-cert-tls server' \ ' --auth-user-pass ressources/params_PIA/data/auth.txt ' \ '--comp-lzo --verb 1 --reneg-sec 0' \ ' --crl-verify ressources/params_PIA/data/crl.rsa.2048.pem' \ ' --auth-nocache' \ ' --ca ressources/params_PIA/data/ca.rsa.2048.crt' \ # ' --block-outside-dns' cmd += parameters try: subprocess.Popen(cmd) print('Please wait to connect to OpenVPN...') countdown(8) except: pass if check_ping_is_ok() is True: if set_zone() is True: load_result = True
def connect_purevpn(): if PUREVPN == 1: if USER_CONFIG == 'VUNPA': load_result = False rasdial.disconnect() print('Current VPN: ' + str(rasdial.get_current_vpn())) while load_result is False: rasdial.disconnect() sleep(1) server = get_random_vpn() user = get_params('USER_PUREVPN') password = get_params('PASSWORD_PUREVPN') rasdial.connect(server, user, password) # connect to a vpn sleep(1) if check_ping_is_ok() is True: if check_country_is_ok() is True: if set_zone() is True: load_result = True
def connect_openvpn_purevpn(): if OPENVPN == 1: load_result = False while load_result is False: try: print('Try to Disconnect OpenVPN') rasdial.disconnect() # Disconnect params_PureVPN first subprocess.check_output("taskkill /im openvpn.exe /F", shell=True) except: pass print('Connect OpenVPN') cmd = '"C:/Program Files/OpenVPN/bin/openvpn.exe"' value = random.randint(0, len(CONFIG_IP_PURE) - 1) print('Random Server: ' + CONFIG_IP_PURE[value].strip()) if 'pointtoserver' in CONFIG_IP_PURE[value].strip(): parameters = ' --client --dev tun --remote ' + CONFIG_IP_PURE[value].strip() + ' --port 53' + \ ' --proto udp --nobind --persist-key --persist-tun ' \ '--tls-auth ressources/params_PureVPN/Wdc.key 1 --ca ressources/params_PureVPN/ca.crt' + \ ' --cipher AES-256-CBC --comp-lzo --verb 1 --mute 20 --float --route-method exe' + \ ' --route-delay 2 --auth-user-pass ressources/params_PureVPN/auth.txt ' + \ '--auth-retry interact' + \ ' --explicit-exit-notify 2 --ifconfig-nowarn --auth-nocache ' cmd += parameters try: subprocess.Popen(cmd) print('Please wait to connect to OpenVPN...') countdown(8) except: pass if check_ping_is_ok() is True: if check_country_is_ok() is True: if set_zone() is True: load_result = True
def connect_openvpn(): if OPENVPN == 1 or ADS_BOTTOM == 0: # if NUMBER_MACHINE > TOTAL_CHANNEL or ADS_BOTTOM == 0 or PUREVPN == 0: load_result = False counter_connect = 0 while load_result is False and counter_connect < 4: if counter_connect >= 2: send_email_alert() counter_connect += 1 if sys.platform == 'win32': try: print('Try to Disconnect OpenVPN') rasdial.disconnect() # Disconnect params_PureVPN first subprocess.check_output("taskkill /im openvpn.exe /F", shell=True) except: pass subprocess.check_output('ipconfig /release', shell=True) subprocess.check_output('ipconfig /renew', shell=True) print('Connect OpenVPN') if sys.platform == 'win32': cmd = '"C:/Program Files/OpenVPN/bin/openvpn.exe"' else: cmd = '/etc/openvpn/openvpn' if ADS_BOTTOM == 0: USE_IP = CONFIG_IP_VIEW else: USE_IP = CONFIG_IP value = random.randint(0, len(USE_IP) - 1) print('Random Server: ' + USE_IP[value].strip()) if 'privateinternetaccess' in USE_IP[value].strip(): parameters = ' --client --dev tun --proto udp --remote ' \ + USE_IP[value].strip() + \ ' --port 1198 --resolv-retry infinite --nobind --persist-key --persist-tun' \ ' --cipher aes-128-cbc --auth sha1 --tls-client --remote-cert-tls server' \ ' --auth-user-pass ressources/params_PIA/data/auth.txt ' \ '--comp-lzo --verb 1 --reneg-sec 0' \ ' --crl-verify ressources/params_PIA/data/crl.rsa.2048.pem' \ ' --auth-nocache' \ ' --ca ressources/params_PIA/data/ca.rsa.2048.crt' \ # ' --block-outside-dns' else: parameters = ' --tls-client --client --dev tun --link-mtu 1500' \ ' --remote ' + USE_IP[value].strip() + \ ' --proto udp --port 1197' \ ' --lport 53 --persist-key --persist-tun --ca ressources/params_PIA/data/ca.crt ' \ '--comp-lzo --mute 3' \ ' --auth-user-pass ressources/params_PIA/data/auth.txt' \ ' --reneg-sec 0 --route-method exe --route-delay 2' \ ' --verb 3 --log c:/log.txt --status c:/stat.db 1 --auth-nocache' \ ' --crl-verify ressources/params_PIA/data/crl.pem ' \ '--remote-cert-tls server --block-outside-dns' \ ' --cipher aes-256-cbc --auth sha256' cmd += parameters try: subprocess.Popen(cmd) print('Please wait to connect to OpenVPN...') countdown(8) except: pass if check_ping_is_ok() is True: # if check_country_is_ok() is True: if set_zone() is True: load_result = True