From 468bf4696faf00ea2196c55b01f19eb00e3da87e Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 22 Nov 2016 16:24:09 +0800 Subject: [PATCH] stdapi_fs_file_copy --- .../meterpreter/extensions/stdapi/fs/file.rb | 18 ++++++++++++++++++ .../ui/console/command_dispatcher/stdapi/fs.rb | 2 ++ 2 files changed, 20 insertions(+) diff --git a/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb b/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb index 9ad0e65be4..4c5da6f5e3 100644 --- a/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +++ b/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb @@ -226,6 +226,24 @@ class File < Rex::Post::Meterpreter::Extensions::Stdapi::Fs::IO alias rename mv end + # + # Performs a copy from oldname to newname + # + def File.cp(oldname, newname) + request = Packet.create_request('stdapi_fs_file_copy') + + 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 copy cp + end + # # Upload one or more files to the remote remote directory supplied in # +destination+. diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb index 9e1ef52bc1..b76dda80cf 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb @@ -71,6 +71,7 @@ class Console::CommandDispatcher::Stdapi::Fs 'pwd' => 'Print working directory', 'rm' => 'Delete the specified file', 'mv' => 'Move source to destination', + 'cp' => 'Copy source to destination', 'rmdir' => 'Remove directory', 'search' => 'Search for files', 'upload' => 'Upload a file or directory', @@ -95,6 +96,7 @@ class Console::CommandDispatcher::Stdapi::Fs 'rmdir' => ['stdapi_fs_delete_dir'], 'rm' => ['stdapi_fs_delete_file'], 'mv' => ['stdapi_fs_file_move'], + 'cp' => ['stdapi_fs_file_copy'], 'search' => ['stdapi_fs_search'], 'upload' => [], 'show_mount' => ['stdapi_fs_mount_show'],