Skip to content

Commit d399093

Browse files
author
RageLtMan
committed
Add Framework side of stdapi.fs.file.mv
Add the appropriate methods to Rex side of the FS extension and the commensurate command dispatcher. Requires rapid7/meterpreter#6 from the meterpreter repo as well as compiling fresh DLL for ext_server_stdapi.
1 parent 87f8451 commit d399093

File tree

2 files changed

+39
-0
lines changed
  • lib/rex/post/meterpreter
    • extensions/stdapi/fs
    • ui/console/command_dispatcher/stdapi

2 files changed

+39
-0
lines changed

lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,25 @@ class << self
204204
alias delete rm
205205
end
206206

207+
#
208+
# Performs a rename from oldname to newname
209+
#
210+
def File.mv(oldname, newname)
211+
request = Packet.create_request('stdapi_fs_file_move')
212+
213+
request.add_tlv(TLV_TYPE_FILE_NAME, client.unicode_filter_decode( oldname ))
214+
request.add_tlv(TLV_TYPE_FILE_PATH, client.unicode_filter_decode( newname ))
215+
216+
response = client.send_request(request)
217+
218+
return response
219+
end
220+
221+
class << self
222+
alias move mv
223+
alias rename mv
224+
end
225+
207226
#
208227
# Upload one or more files to the remote remote directory supplied in
209228
# +destination+.

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def commands
4949
"mkdir" => "Make directory",
5050
"pwd" => "Print working directory",
5151
"rm" => "Delete the specified file",
52+
"mv" => "Move source to destination",
5253
"rmdir" => "Remove directory",
5354
"search" => "Search for files",
5455
"upload" => "Upload a file or directory",
@@ -69,6 +70,7 @@ def commands
6970
"pwd" => [ "stdapi_fs_getwd" ],
7071
"rmdir" => [ "stdapi_fs_delete_dir" ],
7172
"rm" => [ "stdapi_fs_delete_file" ],
73+
"mv" => [ "stdapi_fs_file_move" ],
7274
"search" => [ "stdapi_fs_search" ],
7375
"upload" => [ ],
7476
}
@@ -221,6 +223,24 @@ def cmd_rm(*args)
221223

222224
alias :cmd_del :cmd_rm
223225

226+
#
227+
# Move source to destination
228+
#
229+
def cmd_mv(*args)
230+
if (args.length < 2)
231+
print_line("Usage: mv oldfile newfile")
232+
return true
233+
end
234+
235+
client.fs.file.mv(args[0],args[1])
236+
237+
return true
238+
end
239+
240+
alias :cmd_move :cmd_mv
241+
alias :cmd_rename :cmd_mv
242+
243+
224244
def cmd_download_help
225245
print_line "Usage: download [options] src1 src2 src3 ... destination"
226246
print_line

0 commit comments

Comments
 (0)