Skip to content

Commit 1762fe5

Browse files
author
Brent Cook
committed
Land rapid7#8589, Fix 64-bit support for the winpmem extension
2 parents c3090a4 + d81d0ea commit 1762fe5

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/rex/post/meterpreter/extensions/winpmem/tlv.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Meterpreter
55
module Extensions
66
module Winpmem
77
TLV_TYPE_WINPMEM_ERROR_CODE = TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 1)
8-
TLV_TYPE_WINPMEM_MEMORY_SIZE = TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 2)
8+
TLV_TYPE_WINPMEM_MEMORY_SIZE = TLV_META_TYPE_QWORD | (TLV_EXTENSIONS + 2)
99
end
1010
end
1111
end

lib/rex/post/meterpreter/extensions/winpmem/winpmem.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def dump_ram
4343
channel_id = response.get_tlv_value(TLV_TYPE_CHANNEL_ID)
4444

4545
raise Exception, "We did not get a channel back!" if channel_id.nil?
46-
#Open the compressed Channel
47-
channel = Rex::Post::Meterpreter::Channels::Pool.new(client, channel_id, "winpmem", CHANNEL_FLAG_SYNCHRONOUS | CHANNEL_FLAG_COMPRESS)
46+
47+
# Open the compressed Channel
48+
channel = Rex::Post::Meterpreter::Channels::Pool.new(client, channel_id, "winpmem",
49+
CHANNEL_FLAG_SYNCHRONOUS | CHANNEL_FLAG_COMPRESS)
4850
return memory_size, response_code, channel
4951
end
5052
end

lib/rex/post/meterpreter/ui/console/command_dispatcher/winpmem.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ def cmd_dump_ram(*args)
6060
end
6161
print_good("Driver PMEM loaded successfully")
6262
#Arbitrary big buffer size, could be optimized
63-
buffer_size = 2**17
63+
buffer_size = 2 ** 17
6464
bytes_read = 0
6565
next_message_byte = memory_size / 10
66+
print_good("Dumping #{memory_size} bytes (press Ctrl-C to abort)")
6667
begin
6768
data = channel.read(buffer_size)
68-
until channel.eof
69+
until channel.eof || data.nil?
6970
fd.write(data)
7071
bytes_read += data.length
7172
data = channel.read(buffer_size)

0 commit comments

Comments
 (0)