Skip to content

Commit

Permalink
Add tube.stream()
Browse files Browse the repository at this point in the history
  • Loading branch information
zachriggle committed Oct 5, 2016
1 parent c8a8738 commit b198ec8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pwnlib/tubes/tube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b198ec8

Please sign in to comment.