1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-27 19:04:15 +01:00

Possibly fixed readinto for RemoteFilePipe

This commit is contained in:
Caleb Stewart 2020-05-09 17:25:09 -04:00
parent 3b7bf075d5
commit 86e6397702

View File

@ -63,20 +63,21 @@ class RemoteBinaryPipe(RawIOBase):
# Check for EOF split across blocks # Check for EOF split across blocks
for i in range(1, len(self.delim) - 1): for i in range(1, len(self.delim) - 1):
# See if a piece of the delimeter is at the end of this block # See if a piece of the delimeter is at the end of this block
piece = self.delim[:-i] piece = self.delim[:i]
if bytes(b[-len(piece) :]) == piece: if bytes(b[-i:]) == piece:
try: try:
# Peak the next bytes, to see if this is actually the # Peak the next bytes, to see if this is actually the
# delimeter # delimeter
rest = self.pty.client.recv( rest = self.pty.client.recv(
i, socket.MSG_PEEK | socket.MSG_DONTWAIT len(self.delim) - len(piece),
socket.MSG_PEEK | socket.MSG_DONTWAIT,
) )
except (socket.error, BlockingIOError): except (socket.error, BlockingIOError):
rest = b"" rest = b""
# It is! # It is!
if (piece + rest) == self.delim: if (piece + rest) == self.delim:
# Receive the delimeter # Receive the delimeter
self.pty.client.recv(i) self.pty.client.recv(len(self.delim) - len(piece))
# Adjust result # Adjust result
n -= len(piece) n -= len(piece)
# Set EOF for next read # Set EOF for next read