diff --git a/qiling/extensions/pipe.py b/qiling/extensions/pipe.py index f88c27135..f69d1e326 100644 --- a/qiling/extensions/pipe.py +++ b/qiling/extensions/pipe.py @@ -86,4 +86,26 @@ class SimpleBufferedStream(io.BytesIO): """ def __init__(self): - super.__init__() \ No newline at end of file + 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) \ No newline at end of file