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
for i in range(1, len(self.delim) - 1):
# See if a piece of the delimeter is at the end of this block
piece = self.delim[:-i]
if bytes(b[-len(piece) :]) == piece:
piece = self.delim[:i]
if bytes(b[-i:]) == piece:
try:
# Peak the next bytes, to see if this is actually the
# delimeter
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):
rest = b""
# It is!
if (piece + rest) == self.delim:
# Receive the delimeter
self.pty.client.recv(i)
self.pty.client.recv(len(self.delim) - len(piece))
# Adjust result
n -= len(piece)
# Set EOF for next read