Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import getpass
- import telnetlib
- from time import sleep
- class Account:
- def __init__(self, login, password, host):
- self.login = login
- self.password = password
- self.host = host
- def __repr__(self):
- return "Account (%s:%s @ %s)" % (self.login, self.password, self.host)
- def connect(user,password,host):
- tn = telnetlib.Telnet(host)
- tn.read_until(b': ')
- tn.write(user.encode('ascii')+b'\n')
- if password:
- tn.read_until(b': ')
- tn.write(password.encode('ascii')+b'\n')
- else:
- tn.read_until(b': ')
- tn.write(b'\n')
- tn.set_debuglevel(10000)
- sleep(1)
- tn.write('ls'.encode('ascii')+b'\n')
- return tn.read_all().decode('ascii')
- address = input("Enter ip-address: ")
- user = input("Enter your login: ")
- password = getpass.getpass()
- acc = Account(user, password, address)
- print(acc)
- connect(acc.login, acc.password, acc.host)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement