Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. from telnetlib import Telnet
  2.  
  3. HOST = "10.0.2.15"
  4. user = "admin"
  5. password = "admin"
  6. cmd = "RB"
  7.  
  8. tn = Telnet(HOST)
  9. tn.read_until(b"User: ", 10)
  10. print("Login request")
  11. tn.write(user.encode('ascii') + b"\n")
  12. tn.read_until(b"Password: ", 10)
  13. print("Password request")
  14. tn.write(password.encode('ascii') + b"\n")
  15. tn.read_until(b"User Logged In", 10)
  16. print("Login succesful")
  17. tn.read_until(b"User Logged In", 10)
  18. tn.write(cmd.encode('ascii') + b"\n")
  19. out = tn.read_until(b'1', 10)
  20. print(out.decode('ascii'))
  21. size = tn.read_until(b'\r\n', 10)
  22. print(size.decode('ascii'))
  23. size = tn.read_until(b'\r\n', 10)
  24. print(size.decode('ascii'))
  25. while (out != b''):
  26. print(out.decode('ascii'), end="")
  27. out = tn.read_until(b'\r\n', 10)
  28. #print(out.decode('ascii'))
  29. print("Reading done")
  30. tn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement