Skip to content

Commit

Permalink
telnet: capture also everything before the prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-sahlmann committed Jan 8, 2024
1 parent 7c3206f commit d63dceb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mb_netmgmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with mb-netmgmt. If not, see <https://www.gnu.org/licenses/

"""Network Management Protocols for Mountebank"""
__version__ = "0.0.79"
__version__ = "0.0.80"

import os
import subprocess
Expand Down
7 changes: 4 additions & 3 deletions mb_netmgmt/telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def handle(self):
self.command_prompt = b"#"
try:
self.telnet.send(self.password)
self.command_prompt = self.telnet.expect_prompt()[1][0].encode()
self.command_prompt = self.telnet.expect_prompt()[1].string.encode()
self.telnet.app_authenticated = True
except AttributeError:
pass
Expand Down Expand Up @@ -74,7 +74,7 @@ def handle_username_prompt(self):
t = Telnet(debug=4)
t.connect(to.hostname)
result = t.expect(t.get_username_prompt())
username_prompt = (t.response[:-1] + result[1][0]).encode()
username_prompt = (t.response[:-1] + result[1].string).encode()
self.telnet = t
self.wfile.write(username_prompt)

Expand All @@ -88,7 +88,8 @@ def handle_username(self):
try:
t = self.telnet
t.send(self.username)
password_prompt = t.expect(t.get_password_prompt())[1][0].encode()
result = t.expect(t.get_password_prompt())
password_prompt = result[1].string.encode()
except AttributeError:
password_prompt = b"Password: "
self.wfile.write(password_prompt)
Expand Down

0 comments on commit d63dceb

Please sign in to comment.