Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion qiling/extensions/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,26 @@ class SimpleBufferedStream(io.BytesIO):
"""

def __init__(self):
super.__init__()
super.__init__()

class InteractiveInStream(io.BytesIO):
def read(self, size: int) -> bytes:
'''
Read from the BytesIO buffer. If theres no data left in the buffer, get additional user input

Args:
size (int): The amount of bytes to read from the buffer
Returns:
bytes: The data read from the buffer
'''

#get the amount of bytes left in the buffer
bytes_left = self.getbuffer().nbytes - self.tell()

#if theres no bytes left in the buffer, get user input
if bytes_left == 0:
user_data = input().encode()+ b'\x0a'
self.write(user_data)
self.seek(-len(user_data), io.SEEK_CUR)

return super().read(size)