MCPcopy
hub / github.com/knownsec/pocsuite3 / telnet_login

Function telnet_login

pocsuite3/pocs/telnet_burst.py:83–105  ·  view source on GitHub ↗
(host, port, username, password)

Source from the content-addressed store, hash-verified

81
82
83def telnet_login(host, port, username, password):
84 ret = False
85 key = [b'>', b'Login', b'login']
86 tn = None
87 try:
88 for wrap in [b'\n', b'\r\n']:
89 tn = telnetlib.Telnet()
90 tn.open(host, port, timeout=6)
91 tn.read_until(b'login: ', timeout=3)
92 tn.write(username.encode() + wrap)
93 if password:
94 tn.read_until(b'password: ', timeout=3)
95 tn.write(password.encode() + wrap)
96 tmp = tn.expect(key, timeout=3)
97 if b'>' in tmp[2]:
98 ret = True
99 break
100 except Exception:
101 pass
102 finally:
103 if tn:
104 tn.close()
105 return ret
106
107
108def task_init(host, port):

Callers 1

task_threadFunction · 0.85

Calls 3

openMethod · 0.80
closeMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected