Skip to content

Commit

Permalink
Landing rapid7#1579, meterpreter mv
Browse files Browse the repository at this point in the history
See rapid7/meterpreter/#6
  • Loading branch information
egypt committed Apr 5, 2013
2 parents ab0535b + d399093 commit 0671406
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,25 @@ class << self
alias delete rm
end

#
# Performs a rename from oldname to newname
#
def File.mv(oldname, newname)
request = Packet.create_request('stdapi_fs_file_move')

request.add_tlv(TLV_TYPE_FILE_NAME, client.unicode_filter_decode( oldname ))
request.add_tlv(TLV_TYPE_FILE_PATH, client.unicode_filter_decode( newname ))

response = client.send_request(request)

return response
end

class << self
alias move mv
alias rename mv
end

#
# Upload one or more files to the remote remote directory supplied in
# +destination+.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def commands
"mkdir" => "Make directory",
"pwd" => "Print working directory",
"rm" => "Delete the specified file",
"mv" => "Move source to destination",
"rmdir" => "Remove directory",
"search" => "Search for files",
"upload" => "Upload a file or directory",
Expand All @@ -69,6 +70,7 @@ def commands
"pwd" => [ "stdapi_fs_getwd" ],
"rmdir" => [ "stdapi_fs_delete_dir" ],
"rm" => [ "stdapi_fs_delete_file" ],
"mv" => [ "stdapi_fs_file_move" ],
"search" => [ "stdapi_fs_search" ],
"upload" => [ ],
}
Expand Down Expand Up @@ -221,6 +223,24 @@ def cmd_rm(*args)

alias :cmd_del :cmd_rm

#
# Move source to destination
#
def cmd_mv(*args)
if (args.length < 2)
print_line("Usage: mv oldfile newfile")
return true
end

client.fs.file.mv(args[0],args[1])

return true
end

alias :cmd_move :cmd_mv
alias :cmd_rename :cmd_mv


def cmd_download_help
print_line "Usage: download [options] src1 src2 src3 ... destination"
print_line
Expand Down

0 comments on commit 0671406

Please sign in to comment.