Fixes 416. Adds the rm/del commands to meterpreter, fixes build problems triggered by the POSIX code merge
git-svn-id: file:///home/svn/framework3/trunk@7291 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
276a3f8052
commit
5234fe8ff8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
#include "../precomp.h"
|
#include "precomp.h"
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../precomp.h"
|
#include "precomp.h"
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
/***************************
|
/***************************
|
||||||
|
@ -265,6 +265,37 @@ DWORD request_fs_stat(Remote *remote, Packet *packet)
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes the supplied file from disk
|
||||||
|
*
|
||||||
|
* TLVs:
|
||||||
|
*
|
||||||
|
* req: TLV_TYPE_FILE_PATH - The file that is to be removed.
|
||||||
|
*/
|
||||||
|
DWORD request_fs_delete_file(Remote *remote, Packet *packet)
|
||||||
|
{
|
||||||
|
Packet *response = packet_create_response(packet);
|
||||||
|
LPCSTR path;
|
||||||
|
DWORD result = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
path = packet_get_tlv_value_string(packet, TLV_TYPE_FILE_PATH);
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
result = ERROR_INVALID_PARAMETER;
|
||||||
|
#ifdef __WIN32__
|
||||||
|
else if (!DeleteFile(path))
|
||||||
|
#else
|
||||||
|
else if (!unlink(path))
|
||||||
|
#endif
|
||||||
|
result = GetLastError();
|
||||||
|
|
||||||
|
packet_add_tlv_uint(response, TLV_TYPE_RESULT, result);
|
||||||
|
|
||||||
|
packet_transmit(remote, response, NULL);
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Expands a file path and returns the expanded path to the requestor
|
* Expands a file path and returns the expanded path to the requestor
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,6 +11,7 @@ DWORD request_fs_getwd(Remote *remote, Packet *packet);
|
||||||
DWORD request_fs_chdir(Remote *remote, Packet *packet);
|
DWORD request_fs_chdir(Remote *remote, Packet *packet);
|
||||||
DWORD request_fs_mkdir(Remote *remote, Packet *packet);
|
DWORD request_fs_mkdir(Remote *remote, Packet *packet);
|
||||||
DWORD request_fs_delete_dir(Remote *remote, Packet *packet);
|
DWORD request_fs_delete_dir(Remote *remote, Packet *packet);
|
||||||
|
DWORD request_fs_delete_file(Remote *remote, Packet *packet);
|
||||||
DWORD request_fs_stat(Remote *remote, Packet *packet);
|
DWORD request_fs_stat(Remote *remote, Packet *packet);
|
||||||
DWORD request_fs_file_expand_path(Remote *remote, Packet *packet);
|
DWORD request_fs_file_expand_path(Remote *remote, Packet *packet);
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,19 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// sf: Compatability fix for a broken sdk? We get errors in Iphlpapi.h using the latest Windows SDK if we dont do this.
|
// sf: Compatability fix for a broken sdk? We get errors in Iphlpapi.h using the latest Windows SDK if we dont do this.
|
||||||
#define _WIN32_WINNT _WIN32_WINNT_WIN2K
|
#define _WIN32_WINNT _WIN32_WINNT_WIN2K
|
||||||
|
#include "../stdapi.h"
|
||||||
#include <Tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
|
#include "resource/resource.h"
|
||||||
#include "resource/resource.h"
|
|
||||||
#else
|
#else
|
||||||
|
#include "../stdapi.h"
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../stdapi.h"
|
|
||||||
#include "fs/fs.h"
|
#include "fs/fs.h"
|
||||||
#include "sys/sys.h"
|
#include "sys/sys.h"
|
||||||
#include "net/net.h"
|
#include "net/net.h"
|
||||||
|
|
|
@ -47,6 +47,10 @@ Command customCommands[] =
|
||||||
{ request_fs_delete_dir, { 0 }, 0 },
|
{ request_fs_delete_dir, { 0 }, 0 },
|
||||||
{ EMPTY_DISPATCH_HANDLER },
|
{ EMPTY_DISPATCH_HANDLER },
|
||||||
},
|
},
|
||||||
|
{ "stdapi_fs_delete_file",
|
||||||
|
{ request_fs_delete_file, { 0 }, 0 },
|
||||||
|
{ EMPTY_DISPATCH_HANDLER },
|
||||||
|
},
|
||||||
{ "stdapi_fs_stat",
|
{ "stdapi_fs_stat",
|
||||||
{ request_fs_stat, { 0 }, 0 },
|
{ request_fs_stat, { 0 }, 0 },
|
||||||
{ EMPTY_DISPATCH_HANDLER },
|
{ EMPTY_DISPATCH_HANDLER },
|
||||||
|
|
|
@ -65,7 +65,27 @@ Separator = "\\"
|
||||||
def File.stat(name)
|
def File.stat(name)
|
||||||
return client.fs.filestat.new(name)
|
return client.fs.filestat.new(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Performs a delete on the specified file.
|
||||||
|
#
|
||||||
|
def File.rm(name)
|
||||||
|
request = Packet.create_request('stdapi_fs_delete_file')
|
||||||
|
|
||||||
|
request.add_tlv(TLV_TYPE_FILE_PATH,name)
|
||||||
|
|
||||||
|
response = client.send_request(request)
|
||||||
|
|
||||||
|
return response
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Performs a delete on the specified file.
|
||||||
|
#
|
||||||
|
def File.unlink(name)
|
||||||
|
return File.rm(name)
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Upload one or more files to the remote computer the remote
|
# Upload one or more files to the remote computer the remote
|
||||||
# directory supplied in destination.
|
# directory supplied in destination.
|
||||||
|
|
|
@ -45,7 +45,9 @@ class Console::CommandDispatcher::Stdapi::Fs
|
||||||
"upload" => "Upload a file or directory",
|
"upload" => "Upload a file or directory",
|
||||||
"lcd" => "Change local working directory",
|
"lcd" => "Change local working directory",
|
||||||
"getlwd" => "Print local working directory",
|
"getlwd" => "Print local working directory",
|
||||||
"lpwd" => "Print local working directory"
|
"lpwd" => "Print local working directory",
|
||||||
|
"rm" => "Delete the specified file",
|
||||||
|
"del" => "Delete the specified file"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -104,6 +106,22 @@ class Console::CommandDispatcher::Stdapi::Fs
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Delete the specified file.
|
||||||
|
#
|
||||||
|
def cmd_rm(*args)
|
||||||
|
if (args.length == 0)
|
||||||
|
print_line("Usage: rm file")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
client.fs.file.rm(args[0])
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
alias :cmd_del :cmd_rm
|
||||||
|
|
||||||
#
|
#
|
||||||
# Downloads a file or directory from the remote machine to the local
|
# Downloads a file or directory from the remote machine to the local
|
||||||
# machine.
|
# machine.
|
||||||
|
|
Loading…
Reference in New Issue