diff --git a/pwnlib/tubes/tube.py b/pwnlib/tubes/tube.py index 7aae4eb7c..247b10462 100644 --- a/pwnlib/tubes/tube.py +++ b/pwnlib/tubes/tube.py @@ -826,6 +826,29 @@ def recv_thread(): while t.is_alive(): t.join(timeout = 0.1) + def stream(self, line_mode=True): + """stream() + + Receive data until the tube exits, and print it to stdout. + + Similar to :func:`interactive`, except that no input is sent. + + Similar to ``print tube.recvall()`` except that data is printed + as it is received, rather than after all data is received. + + Arguments: + line_mode(bool): Whether to receive line-by-line or raw data. + """ + data = True + while data: + if line_mode: + data = self.recvline() + else: + data = self.recv() + + if data: + sys.stdout.write(data) + def clean(self, timeout = 0.05): """clean(timeout = 0.05)