Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telnetlib import Telnet
- HOST = "10.0.2.15"
- user = "admin"
- password = "admin"
- cmd = "RB"
- tn = Telnet(HOST)
- tn.read_until(b"User: ", 10)
- print("Login request")
- tn.write(user.encode('ascii') + b"\n")
- tn.read_until(b"Password: ", 10)
- print("Password request")
- tn.write(password.encode('ascii') + b"\n")
- tn.read_until(b"User Logged In", 10)
- print("Login succesful")
- tn.read_until(b"User Logged In", 10)
- tn.write(cmd.encode('ascii') + b"\n")
- out = tn.read_until(b'1', 10)
- print(out.decode('ascii'))
- size = tn.read_until(b'\r\n', 10)
- print(size.decode('ascii'))
- size = tn.read_until(b'\r\n', 10)
- print(size.decode('ascii'))
- while (out != b''):
- print(out.decode('ascii'), end="")
- out = tn.read_until(b'\r\n', 10)
- #print(out.decode('ascii'))
- print("Reading done")
- tn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement