Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import telnetlib
  2. import getpass
  3. import time
  4.  
  5. print ("This is telnet service")
  6. HOST = input("Enter your target device IP address: ")
  7. user = input("Enter your device account username: ")
  8. password = getpass.getpass()
  9.  
  10. tn = telnetlib.Telnet(HOST)
  11.  
  12. tn.read_until(b"Username: ")
  13. tn.write(user.encode('ascii') +b"n")
  14.  
  15. if password:
  16. tn.read_until(b"Password: ")
  17. tn.write(password.encode('ascii')+b"n")
  18.  
  19. tn.write(b"terminal length 0n")
  20. tn.write(b"show interface statusn")
  21. time.sleep(3)
  22.  
  23. output = tn.read_all().decode('ascii')
  24. print (output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement