add meterpreter chmod command

GSoC/Meterpreter_Web_Console
Tim W 2018-09-01 23:44:20 +08:00
parent 8474c331fc
commit c4ebf7b4f3
No known key found for this signature in database
GPG Key ID: 217FBA50ABBAABEF
3 changed files with 32 additions and 0 deletions

View File

@ -247,6 +247,20 @@ class File < Rex::Post::Meterpreter::Extensions::Stdapi::Fs::IO
alias copy cp
end
#
# Performs a chmod on the remote file
#
def File.chmod(name, mode)
request = Packet.create_request('stdapi_fs_chmod')
request.add_tlv(TLV_TYPE_FILE_PATH, client.unicode_filter_decode( name ))
request.add_tlv(TLV_TYPE_FILE_MODE_T, mode)
response = client.send_request(request)
return response
end
#
# Upload one or more files to the remote remote directory supplied in
# +destination+.

View File

@ -46,6 +46,8 @@ TLV_TYPE_SEARCH_RECURSE = TLV_META_TYPE_BOOL | 1230
TLV_TYPE_SEARCH_GLOB = TLV_META_TYPE_STRING | 1231
TLV_TYPE_SEARCH_ROOT = TLV_META_TYPE_STRING | 1232
TLV_TYPE_SEARCH_RESULTS = TLV_META_TYPE_GROUP | 1233
TLV_TYPE_FILE_MODE_T = TLV_META_TYPE_UINT | 1234
##
#
# Net

View File

@ -89,6 +89,7 @@ class Console::CommandDispatcher::Stdapi::Fs
'rm' => 'Delete the specified file',
'mv' => 'Move source to destination',
'cp' => 'Copy source to destination',
'chmod' => 'Change the permissions of a file',
'rmdir' => 'Remove directory',
'search' => 'Search for files',
'upload' => 'Upload a file or directory',
@ -115,6 +116,7 @@ class Console::CommandDispatcher::Stdapi::Fs
'rm' => ['stdapi_fs_delete_file'],
'mv' => ['stdapi_fs_file_move'],
'cp' => ['stdapi_fs_file_copy'],
'chmod' => ['stdapi_fs_chmod'],
'search' => ['stdapi_fs_search'],
'upload' => [],
'show_mount' => ['stdapi_fs_mount_show'],
@ -398,6 +400,20 @@ class Console::CommandDispatcher::Stdapi::Fs
alias :cmd_copy :cmd_cp
alias :cmd_cp_tabs :cmd_cat_tabs
#
# Change the permissions on a remote file
#
def cmd_chmod(*args)
if (args.length != 2)
print_line("Usage: chmod permission file")
return true
end
file_path = args[1]
file_path = client.fs.file.expand_path(file_path) if file_path =~ PATH_EXPAND_REGEX
client.fs.file.chmod(file_path, args[0].to_i(8))
return true
end
def cmd_download_help
print_line("Usage: download [options] src1 src2 src3 ... destination")
print_line