Skip to content

Commit 85b59c8

Browse files
committed
fix buggy handling of partial ingress packet data
If we have more data, and the packet parser needs more data, connect the two together rather than bailing. This fixes reverse_tcp_ssl along with probably a lot of other higher-latency corner cases.
1 parent 2682e6e commit 85b59c8

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

lib/msf/base/sessions/meterpreter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ def bootstrap(datastore = {}, handler = nil)
147147
guid = [SecureRandom.uuid.gsub(/-/, '')].pack('H*')
148148
session.core.set_session_guid(guid)
149149
session.session_guid = guid
150-
# TODO: New statgeless session, do some account in the DB so we can track it later.
150+
# TODO: New stageless session, do some account in the DB so we can track it later.
151151
else
152-
# TODO: This session was either staged or previously known, and so we shold do some accounting here!
152+
# TODO: This session was either staged or previously known, and so we should do some accounting here!
153153
end
154154

155155
unless datastore['AutoLoadStdapi'] == false

lib/rex/post/meterpreter/packet_parser.rb

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,20 @@ def reset
3030
# Reads data from the wire and parse as much of the packet as possible.
3131
#
3232
def recv(sock)
33-
bytes_left = self.packet.raw_bytes_required
34-
35-
if bytes_left > 0
36-
raw = sock.read(bytes_left)
37-
if raw
33+
if self.packet.raw_bytes_required
34+
while (raw = sock.read(self.packet.raw_bytes_required))
3835
self.packet.add_raw(raw)
39-
else
40-
raise EOFError
36+
break if self.packet.raw_bytes_required == 0
4137
end
4238
end
4339

44-
if self.packet.raw_bytes_required == 0
45-
packet = self.packet
46-
reset
47-
return packet
40+
if self.packet.raw_bytes_required > 0
41+
return nil
4842
end
4943

50-
nil
44+
packet = self.packet
45+
reset
46+
packet
5147
end
5248

5349
protected

0 commit comments

Comments
 (0)