mirror of
https://github.com/rapid7/metasploit-payloads
synced 2024-11-20 14:39:22 +01:00
add mouse api for windows
This commit is contained in:
parent
35d908b6bf
commit
16213667b7
@ -144,6 +144,7 @@ Command customCommands[] =
|
||||
COMMAND_REQ("stdapi_ui_desktop_set", request_ui_desktop_set),
|
||||
COMMAND_REQ("stdapi_ui_desktop_screenshot", request_ui_desktop_screenshot),
|
||||
COMMAND_REQ("stdapi_ui_send_keys", request_ui_send_keys),
|
||||
COMMAND_REQ("stdapi_ui_send_mouse", request_ui_send_mouse),
|
||||
|
||||
// Event Log
|
||||
COMMAND_REQ("stdapi_sys_eventlog_open", request_sys_eventlog_open),
|
||||
|
@ -34,3 +34,79 @@ DWORD request_ui_enable_mouse(Remote *remote, Packet *request)
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send keystrokes
|
||||
*/
|
||||
|
||||
DWORD request_ui_send_mouse(Remote *remote, Packet *request)
|
||||
{
|
||||
Packet *response = packet_create_response(request);
|
||||
DWORD result = ERROR_SUCCESS;
|
||||
|
||||
DWORD action = packet_get_tlv_value_uint(request, TLV_TYPE_MOUSE_ACTION);
|
||||
DWORD x = packet_get_tlv_value_uint(request, TLV_TYPE_MOUSE_X);
|
||||
DWORD y = packet_get_tlv_value_uint(request, TLV_TYPE_MOUSE_Y);
|
||||
|
||||
INPUT input = {0};
|
||||
input.type = INPUT_MOUSE;
|
||||
input.mi.mouseData = 0;
|
||||
if (action == 0)
|
||||
{
|
||||
input.mi.dwFlags = MOUSEEVENTF_MOVE;
|
||||
}
|
||||
else if (action == 1)
|
||||
{
|
||||
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
|
||||
}
|
||||
else if (action == 2)
|
||||
{
|
||||
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
|
||||
}
|
||||
else if (action == 3)
|
||||
{
|
||||
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
|
||||
}
|
||||
else if (action == 4)
|
||||
{
|
||||
input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
|
||||
}
|
||||
else if (action == 5)
|
||||
{
|
||||
input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
|
||||
}
|
||||
else if (action == 6)
|
||||
{
|
||||
input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
|
||||
}
|
||||
if (x != -1 || y != -1)
|
||||
{
|
||||
double width = GetSystemMetrics(SM_CXSCREEN)-1;
|
||||
double height = GetSystemMetrics(SM_CYSCREEN)-1;
|
||||
double dx = x*(65535.0f / width);
|
||||
double dy = y*(65535.0f / height);
|
||||
input.mi.dx = (LONG)dx;
|
||||
input.mi.dy = (LONG)dy;
|
||||
input.mi.dwFlags |= MOUSEEVENTF_ABSOLUTE;
|
||||
}
|
||||
SendInput(1, &input, sizeof(INPUT));
|
||||
if (action == 1)
|
||||
{
|
||||
input.mi.dwFlags &= ~(MOUSEEVENTF_LEFTDOWN);
|
||||
input.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
|
||||
SendInput(1, &input, sizeof(INPUT));
|
||||
}
|
||||
else if (action == 4)
|
||||
{
|
||||
input.mi.dwFlags &= ~(MOUSEEVENTF_RIGHTDOWN);
|
||||
input.mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
|
||||
SendInput(1, &input, sizeof(INPUT));
|
||||
}
|
||||
|
||||
// Transmit the response
|
||||
packet_transmit_response(result, remote, response);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@ DWORD request_ui_get_keys(Remote *remote, Packet *request);
|
||||
DWORD request_ui_get_keys_utf8(Remote *remote, Packet *request);
|
||||
|
||||
DWORD request_ui_send_keys(Remote *remote, Packet *request);
|
||||
DWORD request_ui_send_mouse(Remote *remote, Packet *request);
|
||||
|
||||
DWORD request_ui_desktop_enum( Remote * remote, Packet * request );
|
||||
DWORD request_ui_desktop_get( Remote * remote, Packet * request );
|
||||
|
@ -188,6 +188,9 @@
|
||||
|
||||
#define TLV_TYPE_KEYSCAN_TRACK_ACTIVE_WINDOW MAKE_CUSTOM_TLV( TLV_META_TYPE_BOOL, TLV_TYPE_EXTENSION_STDAPI, 3013 )
|
||||
#define TLV_TYPE_KEYS_SEND MAKE_CUSTOM_TLV( TLV_META_TYPE_STRING, TLV_TYPE_EXTENSION_STDAPI, 3014 )
|
||||
#define TLV_TYPE_MOUSE_ACTION MAKE_CUSTOM_TLV( TLV_META_TYPE_UINT, TLV_TYPE_EXTENSION_STDAPI, 3015 )
|
||||
#define TLV_TYPE_MOUSE_X MAKE_CUSTOM_TLV( TLV_META_TYPE_UINT, TLV_TYPE_EXTENSION_STDAPI, 3016 )
|
||||
#define TLV_TYPE_MOUSE_Y MAKE_CUSTOM_TLV( TLV_META_TYPE_UINT, TLV_TYPE_EXTENSION_STDAPI, 3017 )
|
||||
|
||||
// Event Log
|
||||
#define TLV_TYPE_EVENT_SOURCENAME MAKE_CUSTOM_TLV( TLV_META_TYPE_STRING, TLV_TYPE_EXTENSION_STDAPI, 4000 )
|
||||
|
Loading…
Reference in New Issue
Block a user