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/priv/fs.rb
Views: 11791
# -*- coding: binary -*-12module Rex3module Post4module Meterpreter5module Extensions6module Priv78###9#10# This class provides an interface to modifying the file system to avoid11# detection, such as by modifying extended file system attributes.12#13###14class Fs1516#17# Initializes the file system subsystem of the privilege escalation18# extension.19#20def initialize(client)21self.client = client22end2324#25# Returns a hash of the Modified, Accessed, Created, and Entry Modified26# values for the specified file path.27#28def get_file_mace(file_path)29request = Packet.create_request(COMMAND_ID_PRIV_FS_GET_FILE_MACE)3031request.add_tlv(TLV_TYPE_FS_FILE_PATH, file_path)3233response = client.send_request(request)3435# Return the hash of times associated with the MACE values36begin37return {38'Modified' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_MODIFIED)),39'Accessed' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_ACCESSED)),40'Created' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_CREATED)),41'Entry Modified' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_EMODIFIED))42}43rescue RangeError44raise RangeError, 'Invalid MACE values'45end46end4748#49# Sets the Modified, Accessed, Created, and Entry Modified attributes of50# the specified file path. If a nil is supplied for a value, it will not51# be modified. Otherwise, the times should be instances of the Time class.52#53def set_file_mace(file_path, modified = nil, accessed = nil, created = nil,54entry_modified = nil)55request = Packet.create_request(COMMAND_ID_PRIV_FS_SET_FILE_MACE)5657request.add_tlv(TLV_TYPE_FS_FILE_PATH, file_path)58request.add_tlv(TLV_TYPE_FS_FILE_MODIFIED, modified.to_i) if (modified)59request.add_tlv(TLV_TYPE_FS_FILE_ACCESSED, accessed.to_i) if (accessed)60request.add_tlv(TLV_TYPE_FS_FILE_CREATED, created.to_i) if (created)61request.add_tlv(TLV_TYPE_FS_FILE_EMODIFIED, entry_modified.to_i) if (entry_modified)6263client.send_request(request)6465true66end6768#69# Sets the MACE attributes of the specified target_file_path to the MACE70# attributes of the source_file_path.71#72def set_file_mace_from_file(target_file_path, source_file_path)73request = Packet.create_request(COMMAND_ID_PRIV_FS_SET_FILE_MACE_FROM_FILE)7475request.add_tlv(TLV_TYPE_FS_FILE_PATH, target_file_path)76request.add_tlv(TLV_TYPE_FS_SRC_FILE_PATH, source_file_path)7778client.send_request(request)7980true81end8283#84# Sets the MACE values to the minimum threshold that will cause them to not85# be displayed by most all products for a file.86#87def blank_file_mace(file_path)88request = Packet.create_request(COMMAND_ID_PRIV_FS_BLANK_FILE_MACE)8990request.add_tlv(TLV_TYPE_FS_FILE_PATH, file_path)9192client.send_request(request)9394true95end9697#98# Recursively set the MACE values to the minimum threshold for the supplied99# directory.100#101def blank_directory_mace(dir_path)102request = Packet.create_request(COMMAND_ID_PRIV_FS_BLANK_DIRECTORY_MACE)103104request.add_tlv(TLV_TYPE_FS_FILE_PATH, dir_path)105106client.send_request(request)107108true109end110111protected112113attr_accessor :client # :nodoc:114115end116117end; end; end; end; end118119120