Python Forum
Login to NordVPN on Linux with python script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Login to NordVPN on Linux with python script
#1
Hello! I am fairly new to both python and Linux so forgive me if my code is bad or this is in the wrong Forum.
My Problem:
I am on a Kali Linux Virtual Machine. I have a list of NordVPN accounts with password in the form email:password. Since NordVPN connections only work when under six people are using the account at once and the accounts are public and are being shared, I would like to write a script that:
  1. Tries to login with the Email and Password (Goes to the next one if the password is wrong)
  2. Tries to connect to a server in a specific country. If the connection fails or takes too long, it goes to the next account.
  3. If the connection was a success, stop the program and print the used Email with password.

I am not 100% sure how to do this. I have written a script that looks like this:

import subprocess
import time
def checkConnection():
	cmd = ['nordvpn', 'c']
	proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

	o, e = proc.communicate()

	if "Connected" in o.decode('ascii'):
		return True
	else:
		return False

def tryConnection():
	cmd = ['nordvpn', 'c']
	proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	time.sleep(2)
	if checkConnection() == True:
		print("Sucessfull Connection with:\n" + email +" " +password)
	else:
		print("Failed")
		cmd = ['nordvpn', 'logout']
		proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			
		print("Logged out")
	
def loginWithPassword(email, password):
	cmd = ['nordvpn', 'login', '-u', email, '-p', password]
	proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	print(proc)
	o, e = proc.communicate()

	if "is not correct" in o.decode('ascii'):
		print("Wrong password")
	else:
		tryConnection()

f = open("list.txt", "r")
for line in f:
	username = line.split(":")[0]	
	password = line.split(":")[1]
	print("--------------------------\nUsername "+username+", Password "+password)
	
	loginWithPassword(username, password)
But the connection just fails for every login. It could be a possibility that I have just set up NordVPN wrong, but I can manually login via the terminal.

Thanks for your help!
Reply


Messages In This Thread
Login to NordVPN on Linux with python script - by AGreenPig - Feb-07-2021, 11:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is possible to run the python command to call python script on linux? cuten222 6 738 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,297 Jun-29-2023, 11:57 AM
Last Post: gologica
  [SOLVED] [Linux] Script in cron stops after first run in loop Winfried 2 937 Nov-16-2022, 07:58 PM
Last Post: Winfried
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,351 May-24-2022, 07:02 AM
Last Post: netanelst
  How to use a variable in linux command in python code? ilknurg 2 1,614 Mar-14-2022, 07:21 AM
Last Post: ndc85430
  Python syntax in Linux St0rmcr0w 2 52,071 Jul-29-2021, 01:40 PM
Last Post: snippsat
  Error when running script on startup in Linux NoahTheNerd 0 1,978 Mar-07-2021, 04:54 PM
Last Post: NoahTheNerd
  in a login interface when i try login with a user supposed to say test123 but nothing NullAdmin 3 2,293 Feb-20-2021, 04:43 AM
Last Post: bowlofred
  how to run linux command with multi pipes by python !! evilcode1 2 6,388 Jan-25-2021, 11:19 AM
Last Post: DeaD_EyE
  where to get portable Python for Linux (Fedora)? python001 5 6,341 Nov-01-2020, 05:23 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020