fix(ssh): preserve ANSI escape codes in interactive mode (closes #2703)#2747
Open
Gustavo-Blois wants to merge 3 commits into
Open
fix(ssh): preserve ANSI escape codes in interactive mode (closes #2703)#2747Gustavo-Blois wants to merge 3 commits into
Gustavo-Blois wants to merge 3 commits into
Conversation
Member
|
I think this is correct. Do you remember why you added the |
Member
|
This is done so that in interactive setting you can see the raw bytes and nothing can hide (ike crazy escapes with invalid or malicious payloads). In the non-interactive setting, you want original bytes preserved always. So I can see where this if comes from. If you want raw, you can pipe the exploit to cat, or set PWNLIB_NOTERM=1 in environment or run python exploit.py NOTERM |
Member
|
Hmhm, but this is different to the interactive() prompt in other tubes like local processes or raw sockets. We just evaluate the escape codes there by default. How is the ssh setting different here? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
ssh.interactive(), ANSI escape codes are displayed literally(e.g.,
\x1b[31m) instead of being interpreted as colors.In
ssh_channel.interactive(), the condition to use the binary stdout bufferwas inverted:
term_mode=True(terminal mode), it usessys.stdoutterm_mode=False, it usessys.stdout.buffersys.stdoutescapes ANSI escape codes, preventing the terminal frominterpreting them correctly. This change always uses
sys.stdout.bufferto preserve the escape sequences.
Fixes #2703