Skip to content

Commit

Permalink
Merge d257d2b into 4ddb702
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Oct 27, 2022
2 parents 4ddb702 + d257d2b commit 396034d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -70,11 +70,13 @@ The table below shows which release corresponds to each branch, and what date th
- [#2092][2092] shellcraft: dup() is now called dupio() consistently across all supported arches
- [#2093][2093] setresuid() in shellcraft uses current euid by default
- [#2125][2125] Allow tube.recvregex to return capture groups
- [#2129][2129] Handle `context.newline` correctly when typing in `tube.interactive()`

[2062]: https://github.com/Gallopsled/pwntools/pull/2062
[2092]: https://github.com/Gallopsled/pwntools/pull/2092
[2093]: https://github.com/Gallopsled/pwntools/pull/2093
[2125]: https://github.com/Gallopsled/pwntools/pull/2125
[2129]: https://github.com/Gallopsled/pwntools/pull/2129

## 4.9.0 (`beta`)

Expand Down
15 changes: 13 additions & 2 deletions pwnlib/tubes/tube.py
Expand Up @@ -4,6 +4,7 @@

import abc
import logging
import os
import re
import six
import string
Expand Down Expand Up @@ -852,7 +853,7 @@ def interactive(self, prompt = term.text.bold_red('$') + ' '):
is much more usable, since we are using :mod:`pwnlib.term` to print a
floating prompt.
Thus it only works in while in :data:`pwnlib.term.term_mode`.
Thus it only works while in :data:`pwnlib.term.term_mode`.
"""

self.info('Switching to interactive mode')
Expand All @@ -879,11 +880,21 @@ def recv_thread():

try:
while not go.isSet():
os_linesep = os.linesep.encode()
if term.term_mode:
data = term.readline.readline(prompt = prompt, float = True)
else:
stdin = getattr(sys.stdin, 'buffer', sys.stdin)
data = stdin.read(1)
data = b''
if sys.stdin.isatty():
while not data.endswith(os_linesep):
new_byte = stdin.read(1)
if not new_byte:
break
data += new_byte
else:
data = stdin.read(1)
data = data.replace(os_linesep, self.newline)

if data:
try:
Expand Down

0 comments on commit 396034d

Please sign in to comment.