Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import getpass
- import telnetlib
- HOST = "10.x.x.x"
- user = input("Enter your telnet username: ")
- password = getpass.getpass()
- tn = telnetlib.Telnet(HOST)
- tn.read_until(b"Username:")
- tn.write(user.encode('ascii') + b"\n")
- if password:
- tn.read_until(b"Password: ")
- tn.write(password.encode('ascii') + b"\n")
- tn.write(b"enable\n")
- tn.write(b"cisco\n")
- tn.write(b"conf t\n")
- for n in range (1,11):
- tn.write(b"int loopback" + str(n).encode('ascii') + b"\n")
- tn.write(b"ip address 172.16." + str(n).encode('ascii') + b".1 255.255.255.0" + b"\n")
- tn.write(b"description Loopback Number: " + str(n).encode('ascii') + b"\n")
- tn.write(b"end\n")
- tn.write(b"exit\n")
- print (tn.read_all().decode('ascii'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement