Jump to content

[Version 1] Basic Ducky Code


Recommended Posts

This is what I got done after about an hour of playing. I'm using the Arduino to code it and as a note, you want to put some sort of delay before it starts mashing keys. I figure a 10 second initialization for a "virgin" PC is enough time so I coded a 10 second delay with blink response. Then after that it very quickly opens ipconfig, netstat, tasklist, systeminfo, and a cmd shell with a unique title.

Could be used for a quick stats from a forensic standpoint if you need volatile information such as connection states or tasklist. I have made scripts to do so remotely for my forensic class running from a remote PC so that's why I was just messing around and made this.

/*Programmed By: Mr-Protocol
4-29-2010
Blinks 10 Times (10 second timer)
LED On while working
Opens ipconfig, netstat, tasklist, systeminfo, cmd (with a title change)
LED Off when done
Does NOT loop continuously
*/
int ledPin = 11; //LED is on pin 11
int isDone = 0;
int startdelay = 0;

void setup()
{
  pinMode(ledPin, OUTPUT);
  //Does 10 Sec delay with 10 blinks of LED
    do
    {
     digitalWrite(ledPin,HIGH);
     delay(500);
     digitalWrite(ledPin,LOW);
     delay(500);
     startdelay++;
     }
    while (startdelay < 10);
}

void loop()
{  
  if(isDone < 1)
    {
     CmdCommand("ipconfig");
     delay(250);
     CmdCommand("netstat");
     delay(250);
     CmdCommand("tasklist");
     delay(250);
     CmdCommand("systeminfo");
     delay(250);
     CmdCommand("title I @m h4x0r");
     delay(250);
     Keyboard.print("cls");
     PressAndRelease(KEY_ENTER,1);
     isDone=1;
     pinMode(ledPin,LOW);
    }
}

void CmdCommand(char *Cmd_Command)
{
 CommandAtRunBar("cmd.exe");
 delay(100);
 Keyboard.print(Cmd_Command);
 PressAndRelease(KEY_ENTER,1);
}

void CommandAtRunBar(char  *SomeCommand)
{
digitalWrite(ledPin, HIGH);
Keyboard.set_modifier(128);
Keyboard.set_key1(KEY_R);
Keyboard.send_now();
delay(10);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(10);
Keyboard.print(SomeCommand);
PressAndRelease(KEY_ENTER,1);
}

void PressAndRelease(int KeyCode,int KeyCount)
{
int KeyCounter=0;
for (KeyCounter=0; KeyCounter!=KeyCount; KeyCounter++)
  {
  Keyboard.set_key1(KeyCode);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  }
}

CommandAtRunBar & PressAndRelease from Irongeek's Code. Why Reinvent the wheel? (Added a delay and lowered initial delay)

Thanks for the Ducky Dev Kit (DDK?) Darren.

Edited by Mr-Protocol
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...