Close
0%
0%

HAK5 USB RubberDucky Emulator

A simple java program that reads and executes ducky scripts (from the popular hak5 rubber ducky)

Similar projects worth following
So I purchased a usb rubber ducky from hak5, see link below,
https://hakshop.myshopify.com/products/usb-rubber-ducky-exfiltrator

I have been having great fun making scripts and launching them on a victim pc that I own personally (I use the ducky for personal fun and education only, not to do any real harm).
After a while one aspect of the ducky started to annoy me, their was no way of testing scripts before going to the bother of compiling them and putting them on the ducky's sd card. If your like me, you will make a lot of mistakes while making your script and will be constantly changing it and updating it on the ducky and testing it again.
Well in the end I found it annoying the amount of steps needed to test scripts so I decided to make a simple ducky emulator, a mini java program that can read and execute ducky scripts, I believe this could be handy for those like me who want to see quick results and also for those who dont have a ducky yet and want to try it out.

WHO IS THIS INTENDED FOR?

1) people like me who want a quick way to test ducky scripts before actually putting them on the rubber ducky (every time I pull it out of its case I feel like I'm going to break it or something).

2) those who don't yet own a ducky but would still like to test their own script ideas and share them with the community. (and hopefully this will also encourage them to want to buy a rubber ducky).

__________________________________________________________

see the github linked for the source

  • FUTURE AIMS

    TAIBHSE DESIGNS08/06/2015 at 16:47 0 comments

    ok so this project has been resurrected, the following is a list of things I would like to do / add to this project

    1) Cross platform support (windows, mac, linux)

    2) Allow command line arguments so i can run a script without a UI using java -jar DuckyEmulator.jar script.duck

    3) Turn this from an emulator into maybe a notepad like app for making scripts, allow editing and saving of scripts

    4) if 3 works out, add the ability to click a button to compile the scripts into .bin files for the duck

    5) a one click solution that immediately moves compiled .bin files to the ducky's sd card

    6) back to 3 and 4, have line numbering and word highlighting

    7) maybe have error checks in real time, highlight incorrect scripts or give suggestions (this is a far out ambition)

    8) insane idea, export script jars, as in export a jar file version that when clicked runs the embedded script, rather than needed a ducky (this could be nefarious but I'm thinking ducky scripting for automated backup and restore stuff, I swear purely innocent...)

    9) add support for multiple languages and keyboard layouts as current layout is default irish keyboard (whoops)


    I'll update this with more ideas if i remember to, or if anyone else has any suggestions I like

  • Resurrected

    TAIBHSE DESIGNS08/06/2015 at 14:24 0 comments

    OK so I've gotten a few messages with issues with this program, so I've decided to go back and revisit this project, its been a while and I've improved my java programming since making this project. So to start, I'd like to get this compatible across all platforms but I do not have a mac available to test this on, linux I can try in a virtual machine. Lastly this program uses the java robot class to type so I need a way to allow uses to adjust it for different keyboard layouts, help with this would be appreciated. The project and its source has been fully released on github for anyone to view and share opinions on and play around with. This is surprisingly my first time ever using github and I'm still learning.

  • Complete - For Now

    TAIBHSE DESIGNS06/09/2014 at 21:26 0 comments

     OK so things are working well for now and there is not much more I want to do with this project until I can get feed back or further testing,  the code is released for anyone who would like to make changes of their own.  For now I will be working on completing other projects.

  • Beta is Released

    TAIBHSE DESIGNS05/23/2014 at 19:56 0 comments

     ok a quick update to let anyone interested know that in the details section i have added a dropbox link to a zip file containing a working jar of the ducky simulator as well as the netbeans project folder incase anyone wants to make their own improvements.  this is a beta so far,  it works fine for me and its run a few scripts successfully so far, any issues anybody finds please comment and let me know.

  • Updated UI

    TAIBHSE DESIGNS05/19/2014 at 01:30 0 comments

    ok this is a quick update,  I have fixed up the GUI a little,  decided to set it to take the look and feel of whatever os it is currently running on. I have also tidied up the code a little too, I hope to release the first version to the public before the week is up,  I'll probably just release it as a zip folder containing an executable jar file and the netbeans project folder, I've never used git hub before so I'll considering looking into how to use it (obviously a newb here).  anyways here a pic with the native windows 8.1 look and feel.

    I will try and test this on a spare laptop soon and see how it works with alternative keyboards (still looking for a better solution than the java robot class), I will also try and start testing inside linux and see how it looks and works.

  • Exams - interrupters of progress

    TAIBHSE DESIGNS05/18/2014 at 13:52 0 comments

    ok so with University exams going on I've lost time needed to work on this project, but when they are done I'll continue working on it and hopefully have a first release out soon.

      so far I have most of the work done, its able to read ducky scripts, identify commands and then execute them as needed. so far all seems good apart from extremely messy and probably inneficient code (I'll fix later) and a minor bug where for the string command I can get it to type out every character except for quotations (probably just missed putting it in).

      for now its working fine on windows 8.1 64 bit on a Toshiba laptop with an i.e. layout keyboard.  the simulator uses the Java robot class for now in order to type strings and simulate pressing buttons like the ducky,  I'm not too sure yet how well this will work out for other computers and keyboard layouts. I will have to look into a better solution than the robot class, any suggestions here would be much appreciated.

    side note:

      I have added a GUI to this project and i will be improving it after everything works,  part of the GUI allows showing the ducky code in a text field, I am half considering dividing this project into two parts, 1) a GUI that will work as if like a ducky script IDE and 2) a script launcher, the part that simulates being a ducky and executes the script.  I'm sure most people already have their own favourite editors for making ducky scripts so unless there's interest in the first part of this idea I may leave it for now and just concentrate on making a working ducky simulator.

  • Ducky vs my exams

    TAIBHSE DESIGNS05/14/2014 at 19:03 0 comments

    OK so I have 2 days to the start of my college exams (instead of studying I'm building this)...............

      OK besides the GUI looking like garbage I'm happy enough so far with how its working,  I just have to finish adding the ability for it to read and run a few more commands, then I'll be releasing what I will call an alpha version (I'm just gonna go through the entire alphabet until I'm finished or out of letters).

      just a note though,  while it seems to work on my laptop here fine (64 bit windows 8.1 on a Toshiba laptop with an i.e. keyboard) I don't know how well it will run on other laptops, OS's and keyboard layouts.

    this simulator is being made entirely in Java and mainly using the robot class to achieve key commands.

    also note I am the furthest thing from an expert in Java, by the time i do release the source, please be gentle, I'm well aware I've probably committed plenty of coding no no's in it.

View all 7 project logs

Enjoy this project?

Share

Discussions

Serious wrote 09/27/2019 at 15:25 point

How do you do this amaizing ASCII arts? For example, this duck on a preview photo?

  Are you sure? yes | no

Nicholas wrote 11/18/2018 at 19:33 point

How I can install this project?

  Are you sure? yes | no

cookiecoder15 wrote 06/27/2017 at 11:04 point

Sorry to ask this question but I'm on Mac OSX, how do I download and run this software?

  Are you sure? yes | no

saltyviper wrote 11/08/2016 at 16:06 point

I'm taking a look at your source code and i cant find the case in the KeyBoard.java for double quotes. Keep in mind i only have a basic understanding of java.

EDIT: Found it! I was trying to search for """ but i forgot about the escape i should have been searching for "\""

  Are you sure? yes | no

SG wrote 06/20/2015 at 20:43 point

cant execute file here on ubuntu. Please help! (Yes I did set it to executable in permissinons and I do hav JDK ru ntime installed)

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 06/21/2015 at 22:28 point

This was created on a windows pc, some of the code might be windows dependent and crash under linux or even mac,  its likely the GUI thats having issues, I replied to your pm so we can try to sort it there and see whats causing the issue.

  Are you sure? yes | no

Matto wrote 08/06/2015 at 12:48 point

Hey! It looks very good, but I tested on a mac and it's not working.

When I try to run it from the terminal, this is the error I get:

./DuckyEmulator.jar: line 1: PK: command not found

./DuckyEmulator.jar: line 2:???D: command not found

./DuckyEmulator.jar: line 3:???D: command not found

./DuckyEmulator.jar: line 3: ?H???META-INF/MANIFEST.MFManifest-Version:: No such file or directory

./DuckyEmulator.jar: line 4: Ant-Version:: command not found

./DuckyEmulator.jar: line 5: syntax error near unexpected token `('

'/DuckyEmulator.jar: line 5: `Created-By: 1.7.0_21-b11 (Oracle Corporation)

Hope it helps! Can't wait to use it :)

Thanks

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 13:13 point

can you tell me what command your using to try and run it?  java -jar DuckyEmulator.jar should work so long as the terminal has been navigated to the folder containing the jar file, none of the errors appear to be with the program itself but rather how its being launched.  I havent tested this program on anything other than a windows machine either but none of the coding should be locked to a particular os.

  Are you sure? yes | no

Matto wrote 08/06/2015 at 14:53 point

Oh, you are right! I was executing it without the «-jar» parameter. My bad :p

Now I'm getting this error:

java -jar DuckyEmulator.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: duckyemulator/DuckyEmulator : Unsupported major.minor version 52.0
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

Seems to be a complaint about the Java version, but I'm up to date (at least in Mac). I have «Java 8 Update 51». Maybe I have to wait until the Update 52 is released for Mac?

Thanks again

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 15:58 point

Ya I made this on an old laptop running java version 8, this was nearly a year ago so im sure you should have the full update?  I've checked the version i currently have and recoded it to java version 7, those should be the files in the github, if you wish, i can compile and upload a java 7 version to dropbox for you to try and see if it still produces errors?

  Are you sure? yes | no

Matto wrote 08/06/2015 at 16:00 point

Wow, if you could do that I'd really appreciate it :)

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 16:07 point

no problem, give it about an hour, within that I should have it up, internets bogged down downloading windows 10 to fix a nuked windows 10  :P

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 16:14 point

ok worked alot faster than expected,  tested in netbeans and it runs test scripts fine,  tested the jar and it works in windows 8.1 64bit fine  

this is the download link for the jar,  let me know if it works or throws any other errors, would be nice to have it work cross platform

https://www.dropbox.com/s/vnlp6lgzoi58e79/DuckyEmulator.jar?dl=0

  Are you sure? yes | no

Matto wrote 08/06/2015 at 16:20 point

That was fast!

Unluckily this is what I get:

java -jar DuckyEmulator.jar 
Exception in thread "main" java.lang.UnsupportedOperationException: Toolkit.setLockingKeyState
  at java.awt.Toolkit.setLockingKeyState(Toolkit.java:1446)
  at duckyemulator.DuckyEmulator.locks(DuckyEmulator.java:101)
  at duckyemulator.DuckyEmulator.main(DuckyEmulator.java:88)

Thanks for your effort. I don't want to bother you. 

Let me know if I can help you somehow.

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 16:39 point

its fine its not a bother so no worries, that error appears to be a method i use to ensure caps lock, nums locks and scroll lock are all off before the program runs, I tried that so the script always has a known keyboard script,  a simple try catch to report the error should resolve that , but it appears thats an operation the mac doesnt support so thats interesting, I've fixed it in this version so a try catch catches it and just reports the error but the program should still continue running, hopefully it works, unless anything else is incompatible,  

https://www.dropbox.com/s/vnlp6lgzoi58e79/DuckyEmulator.jar?dl=0

  Are you sure? yes | no

Matto wrote 08/06/2015 at 17:05 point

Nice! The UI is woking now and giving this message in the terminal:

Falied to turn off num lock, caps lock and scroll lock....attempting to continue program...

Just as you expected. So far so good.

Then, I try to run a very simple script:

DELAY 2000
STRING Hello wold!

The 2 second delay gives me time to switch the window to a text editor, but all it does is write a «!» symbol (the last character) and nothing else.

The terminal output looks good though:

DefDelay 0
delaying for 2000 milliseconds
DELAY COMPLETE
DefDelay 0
Hello wold!
Running Script Complete.............

Te most weird part is that after executing the script my keyboard acts funny, and some of the letters have to be pressed twice to write anywhere. After a couple of minutes everything goes back to normal.

Something I find strange is that «DefDelay 0»

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 17:09 point

ok that is very, I dont know why it would effect your keyboard, I think I vaguely remember the same issues with early versions of this on windows, by any chance is it the same keys in which the script should have typed,  try making a script to open a note editor for you and then type, 

  Are you sure? yes | no

Matto wrote 08/06/2015 at 17:22 point

At first I tried a script that opens an editor, but it did not work so then I went to the simple script.

I hadn't noticed, but yes, it happens with the same keys the script should have typed :)

I tried adding a «DEFAULTDELAY 100» so it makes everything a slower, and it works better. The problem seems to be that after writing the first «l», it won't write the next, so the shown message now is this:

«Helo wrd!»

The default delay was definitely one of the problems, but now it's the missing keyboard strokes.

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 17:31 point

hmmmm this is really interesting, ok the missing letter are pattern based, try getting it to type this string  "aaa bbb ccc ddd eee fff ggg hhh iii "  if im right, it should only print one of each letter, maybe some twos and likely lose the spaces,  its definately to do with timing, some keypresses arent released in time for the next one to get registered, and when the script ends, the same keys havent been released by the robot class, causing you to have to press the keys a few times to fix it,  adding a micro delay between key presses and releases might fix this, I can adjust the code to read a file to get the number to delay by, that way it can be tweaked,  

  Are you sure? yes | no

Matto wrote 08/06/2015 at 17:36 point

That's right:

By running this: 

DEFAULTDELAY 50
DELAY 2000
STRING aaa bbb ccc ddd eee fff ggg hhh iii

the output is «a b cd ef g h i»

(notice I'm using DEFAULTDELAY, otherwise everything happens way too fast)

  Are you sure? yes | no

Matto wrote 08/06/2015 at 17:39 point

Oh, don't mind me. I removed the DEFAULTDELAY and the results are the same :P

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 17:47 point

OK that definitely gives me the answer I need then, its the java robots class, key releases arent happening fast enough, so an extra delay is needed, the default delay helps but isnt coded to delay keys within a string, dont think the ducky is either, it must use its own internal delay,  Ive added a delay after each character within a string, 15 milliseconds to see if that helps, if not, then a delay needs to be added between a key press and key release in code.  Thanks for all the help by the way,  its helping make alot of progress on this.

this should hopefully work, or atleast show some better performance

https://www.dropbox.com/s/vnlp6lgzoi58e79/DuckyEmulator.jar?dl=0

  Are you sure? yes | no

Matto wrote 08/06/2015 at 18:03 point

Thanks to you for the support!

I'm sad to say that the output is exactly the same as before... Maybe we where wrong about the delay and it's more related to that robot library :(

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 18:06 point

hmmmm odd, everything pointed to the code running faster than the keyboard could keep up with,  I only added a delay to the loop printing characters, maybe it has to be added in between each key press and release command, i can try that with a few characters, so we can run a test, if it succeeds, then its just a case of updating everything,  :P  

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 18:10 point

actually i think i just found another possible cause, try using the string  "<<< >>> @@@"

  Are you sure? yes | no

Matto wrote 08/06/2015 at 18:13 point

This is the output:

;;;  ¨¨¨

Have in mind that I'm using a Spanish keyboard, so that might be causing the characters to look different. Anyway, there is one of the symbols missing. The other two repeat ok.

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 18:16 point

ok thats interesting, the language setting for the keyboard likely will have a major effect on the program, is there any way you can set the keyboard to english to try the script? Also the program could be extended possibly to account for language but I'd need others to be able to help with that.

  Are you sure? yes | no

Matto wrote 08/06/2015 at 18:23 point

ok, I switched the layout to en_US and now the output is:

<<<  """

A little better, but not that much. Also tried with en_GB with the same results.

I'm almost sure that " is for @ (they're both in the number 2 key in my keyboard. " by pressing shift + 2, and @ by pressing alt + 2). Still missing the > symbol.

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 18:25 point

ahhh yes thats the correct output, i have an irish keyboard so " is above 2 and @ is above '    I guess without realising it, the default operation for this program is the irish keyboard, which is just english with some characters switched, 

  Are you sure? yes | no

Matto wrote 08/06/2015 at 18:28 point

Cool. I tested with an Irish layout (just in case) and the output is the same.

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 18:30 point

same as in <<< >>> @@@ ? or still different?

  Are you sure? yes | no

Matto wrote 08/06/2015 at 18:34 point

Sorry. The output is <<<  """ (same as with the en_US and the en_GB layouts).

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 08/06/2015 at 18:42 point

ok thats really unexpected, 

  Are you sure? yes | no

pierrep wrote 05/24/2014 at 08:57 point
Nice work for the Beta version. I'll get my hands on it as soon as I will be able to do. And I'll tell you if there's any bug! Thank's!

  Are you sure? yes | no

TAIBHSE DESIGNS wrote 05/24/2014 at 18:08 point
thank you very much, that would be much appreciated.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates