Advertisement
Guest User

Untitled

a guest
Apr 16th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import getpass
  2. import telnetlib
  3.  
  4. HOST = "10.x.x.x"
  5. user = input("Enter your telnet username: ")
  6. password = getpass.getpass()
  7.  
  8. tn = telnetlib.Telnet(HOST)
  9.  
  10. tn.read_until(b"Username:")
  11. tn.write(user.encode('ascii') + b"\n")
  12. if password:
  13. tn.read_until(b"Password: ")
  14. tn.write(password.encode('ascii') + b"\n")
  15.  
  16. tn.write(b"enable\n")
  17. tn.write(b"cisco\n")
  18. tn.write(b"conf t\n")
  19.  
  20. for n in range (1,11):
  21. tn.write(b"int loopback" + str(n).encode('ascii') + b"\n")
  22. tn.write(b"ip address 172.16." + str(n).encode('ascii') + b".1 255.255.255.0" + b"\n")
  23. tn.write(b"description Loopback Number: " + str(n).encode('ascii') + b"\n")
  24. tn.write(b"end\n")
  25. tn.write(b"exit\n")
  26.  
  27. print (tn.read_all().decode('ascii'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement