Land #9134, fix buggy handling of partial ingress packet data

bug/bundler_fix 4.16.14
bwatters-r7 2017-11-01 20:06:23 -05:00
commit c2a979dd3c
No known key found for this signature in database
GPG Key ID: ECC0F0A52E65F268
2 changed files with 16 additions and 15 deletions

View File

@ -147,9 +147,9 @@ class Meterpreter < Rex::Post::Meterpreter::Client
guid = [SecureRandom.uuid.gsub(/-/, '')].pack('H*')
session.core.set_session_guid(guid)
session.session_guid = guid
# TODO: New statgeless session, do some account in the DB so we can track it later.
# TODO: New stageless session, do some account in the DB so we can track it later.
else
# TODO: This session was either staged or previously known, and so we shold do some accounting here!
# TODO: This session was either staged or previously known, and so we should do some accounting here!
end
unless datastore['AutoLoadStdapi'] == false

View File

@ -27,27 +27,28 @@ class PacketParser
end
#
# Reads data from the wire and parse as much of the packet as possible.
# Reads data from the socket and parses as much of the packet as possible.
#
def recv(sock)
bytes_left = self.packet.raw_bytes_required
if bytes_left > 0
raw = sock.read(bytes_left)
if raw
raw = nil
if self.packet.raw_bytes_required > 0
while (raw = sock.read(self.packet.raw_bytes_required))
self.packet.add_raw(raw)
else
raise EOFError
break if self.packet.raw_bytes_required == 0
end
end
if self.packet.raw_bytes_required == 0
packet = self.packet
reset
return packet
if self.packet.raw_bytes_required > 0
if raw == nil
raise EOFError
else
return nil
end
end
nil
packet = self.packet
reset
packet
end
protected