├── helloworld_ducky.txt ├── README.md ├── .gitattributes ├── helloworld_arduino.txt ├── .gitignore └── ducky2arduino.py /helloworld_ducky.txt: -------------------------------------------------------------------------------- 1 | DELAY 3000 2 | GUI r 3 | DELAY 500 4 | STRING notepad 5 | DELAY 500 6 | ENTER 7 | DELAY 750 8 | STRING Hello World!!! 9 | ENTER -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Simple DuckyScript (https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Duckyscript) to Arduino (https://kr0no.me/post/2016/10/usb-rubber-ducky-arduino) converter. 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /helloworld_arduino.txt: -------------------------------------------------------------------------------- 1 | #include "HID-Project.h" 2 | 3 | void setup() { 4 | Keyboard.begin(); 5 | delay(500); 6 | 7 | // Payload 8 | delay(3000); 9 | Keyboard.press(KEY_LEFT_GUI); 10 | Keyboard.press(KEY_R); 11 | Keyboard.releaseAll(); 12 | delay(500); 13 | Keyboard.print("notepad"); 14 | delay(500); 15 | Keyboard.write(KEY_ENTER); 16 | delay(750); 17 | Keyboard.print("Hello World!!!"); 18 | Keyboard.write(KEY_ENTER); 19 | } 20 | 21 | void loop() { } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /ducky2arduino.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | 5 | if len(sys.argv) < 2 or len(sys.argv) > 3: 6 | print('Usage: ds2arduino.py input.file output.file') 7 | sys.exit() 8 | 9 | input = sys.argv[1] 10 | output = sys.argv[2] 11 | 12 | try: 13 | input_file = open(input, "r") 14 | except: 15 | print('File ' +sys.argv[1]+ ' not found') 16 | sys.exit() 17 | output_file = open(output, "w") 18 | 19 | data = '#include "HID-Project.h"\n\nvoid setup() {\n Keyboard.begin();\n delay(500);\n\n // Payload\n ' 20 | 21 | for line in input_file: 22 | cmd = line.split(' ', 1) 23 | if cmd[0] == "REM": 24 | last_cmd = "// " + cmd[1].strip() + "\n " 25 | data += last_cmd 26 | elif cmd[0] == "DELAY": 27 | last_cmd = "delay(" + cmd[1].strip() + ");\n " 28 | data += last_cmd 29 | elif cmd[0] == "STRING": 30 | last_cmd = 'Keyboard.print("' + cmd[1].strip().replace('\"', '\\\"') + '");\n ' 31 | data += last_cmd 32 | elif cmd[0] == "GUI": 33 | last_cmd = "Keyboard.press(KEY_LEFT_GUI);\n Keyboard.press(KEY_" + cmd[1].strip().upper() + ");\n Keyboard.releaseAll();\n " 34 | data += last_cmd 35 | elif cmd[0] == "MENU" or cmd[0] == "APP": 36 | last_cmd = "Keyboard.press(KEY_LEFT_SHIFT);\n Keyboard.press(KEY_F10);\n Keyboard.releaseAll();\n " 37 | data += last_cmd 38 | elif cmd[0] == "ALT": 39 | last_cmd = "Keyboard.press(KEY_LEFT_ALT);\n Keyboard.press(KEY_" + cmd[1].strip().upper() + ");\n Keyboard.releaseAll();\n " 40 | data += last_cmd 41 | elif cmd[0] == "CONTROL" or cmd[0] == "CTRL": 42 | last_cmd = "Keyboard.press(KEY_LEFT_CTRL);\n Keyboard.press(KEY_" + cmd[1].strip().upper() + ");\n Keyboard.releaseAll();\n " 43 | data += last_cmd 44 | elif cmd[0].strip() == "ENTER": 45 | last_cmd = "Keyboard.write(KEY_ENTER);\n " 46 | data += last_cmd 47 | elif cmd[0].strip() == "UP" or cmd[0].strip() == "UPARROW": 48 | last_cmd = "Keyboard.write(KEY_UP); \n " 49 | data += last_cmd 50 | elif cmd[0].strip() == "DOWN" or cmd[0].strip() == "DOWNARROW": 51 | last_cmd = "Keyboard.write(KEY_DOWN); \n " 52 | data += last_cmd 53 | elif cmd[0].strip() == "LEFT" or cmd[0].strip() == "LEFTARROW": 54 | last_cmd = "Keyboard.write(KEY_LEFT); \n " 55 | data += last_cmd 56 | elif cmd[0].strip() == "RIGHT" or cmd[0].strip() == "RIGHTARROW": 57 | last_cmd = "Keyboard.write(KEY_RIGHT); \n " 58 | data += last_cmd 59 | elif cmd[0].strip() == "SPACE": 60 | last_cmd = "Keyboard.write(KEY_SPACE); \n " 61 | data += last_cmd 62 | elif cmd[0].strip() == "TAB": 63 | last_cmd = "Keyboard.write(KEY_TAB); \n " 64 | data += last_cmd 65 | elif cmd[0].strip() == "HOME": 66 | last_cmd = "Keyboard.write(KEY_HOME); \n " 67 | data += last_cmd 68 | elif cmd[0] == "REPEAT" or cmd[0] == "REPLAY": 69 | last_cmd = "for (int i=0; i<" + cmd[1] + "; i++) {\n " + last_cmd + "}\n " 70 | data += last_cmd 71 | 72 | data += '}\n\nvoid loop() { }\n' 73 | output_file.write(data) 74 | print('Payload saved to ' + sys.argv[2]) 75 | 76 | input_file.close() 77 | output_file.close() --------------------------------------------------------------------------------