├── DIP Switches Example Code.ino ├── Duckduino-microSD └── Duckduino-microSD.ino └── README.md /DIP Switches Example Code.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Seytonic 3 | * https://twitter.com/seytonic 4 | * https://www.youtube.com/seytonic 5 | * GIT: 6 | * https://github.com/Seytonic/Duckduino-microSD 7 | */ 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include "Keyboard.h" 14 | 15 | File myFile; 16 | boolean first = true; 17 | 18 | void setup() { 19 | String dip = ""; // Name of the file that will be opened 20 | 21 | // Sets the given pins as switches for the dip switches 22 | pinMode(6, INPUT_PULLUP); 23 | pinMode(7, INPUT_PULLUP); 24 | pinMode(8, INPUT_PULLUP); 25 | pinMode(9, INPUT_PULLUP); 26 | 27 | // Switches are checked, dip string is contructed 28 | if (digitalRead(6) == LOW){dip += "1";} else {dip += "0";} 29 | if (digitalRead(7) == LOW){dip += "1";} else {dip += "0";} 30 | if (digitalRead(8) == LOW){dip += "1";} else {dip += "0";} 31 | if (digitalRead(9) == LOW){dip += "1";} else {dip += "0";} 32 | 33 | dip += ".txt"; 34 | 35 | 36 | if (!SD.begin(4)) { 37 | return; 38 | } 39 | 40 | // Desired file is opened 41 | myFile = SD.open(dip); 42 | if (myFile) { 43 | Keyboard.begin(); 44 | 45 | String line = ""; 46 | while (myFile.available()) { 47 | char m = myFile.read(); 48 | if (m == '\n'){ 49 | Line(line); 50 | line = ""; 51 | } 52 | else if((int) m != 13) 53 | { 54 | line += m; 55 | } 56 | } 57 | Line(line); 58 | 59 | myFile.close(); 60 | } else { 61 | } 62 | 63 | Keyboard.end(); 64 | } 65 | 66 | void Line(String l) 67 | { 68 | int space_1 = l.indexOf(" "); 69 | if (space_1 == -1) 70 | { 71 | Press(l); 72 | } 73 | else if (l.substring(0,space_1) == "STRING") 74 | { 75 | Keyboard.print(l.substring(space_1 + 1)); 76 | } 77 | else if (l.substring(0,space_1) == "DELAY") 78 | { 79 | int delaytime = l.substring(space_1 + 1).toInt(); 80 | delay(delaytime); 81 | } 82 | else if(l.substring(0,space_1) == "REM"){} 83 | else 84 | { 85 | String remain = l; 86 | 87 | while(remain.length() > 0) 88 | { 89 | int latest_space = remain.indexOf(" "); 90 | if (latest_space == -1) 91 | { 92 | Press(remain); 93 | remain = ""; 94 | } 95 | else 96 | { 97 | Press(remain.substring(0, latest_space)); 98 | remain = remain.substring(latest_space + 1); 99 | } 100 | delay(5); 101 | } 102 | } 103 | 104 | Keyboard.releaseAll(); 105 | } 106 | 107 | 108 | void Press(String b) 109 | { 110 | if(b.length() == 1) 111 | { 112 | char c = b[0]; 113 | Keyboard.press(c); 114 | } 115 | else if (b.equals("ENTER")) 116 | { 117 | Keyboard.press(KEY_RETURN); 118 | } 119 | else if (b.equals("CTRL")) 120 | { 121 | Keyboard.press(KEY_LEFT_CTRL); 122 | } 123 | else if (b.equals("SHIFT")) 124 | { 125 | Keyboard.press(KEY_LEFT_SHIFT); 126 | } 127 | else if (b.equals("ALT")) 128 | { 129 | Keyboard.press(KEY_LEFT_ALT); 130 | } 131 | else if (b.equals("GUI")) 132 | { 133 | Keyboard.press(KEY_LEFT_GUI); 134 | } 135 | else if (b.equals("UP") || b.equals("UPARROW")) 136 | { 137 | Keyboard.press(KEY_UP_ARROW); 138 | } 139 | else if (b.equals("DOWN") || b.equals("DOWNARROW")) 140 | { 141 | Keyboard.press(KEY_DOWN_ARROW); 142 | } 143 | else if (b.equals("LEFT") || b.equals("LEFTARROW")) 144 | { 145 | Keyboard.press(KEY_LEFT_ARROW); 146 | } 147 | else if (b.equals("RIGHT") || b.equals("RIGHTARROW")) 148 | { 149 | Keyboard.press(KEY_RIGHT_ARROW); 150 | } 151 | else if (b.equals("DELETE")) 152 | { 153 | Keyboard.press(KEY_DELETE); 154 | } 155 | else if (b.equals("PAGEUP")) 156 | { 157 | Keyboard.press(KEY_PAGE_UP); 158 | } 159 | else if (b.equals("PAGEDOWN")) 160 | { 161 | Keyboard.press(KEY_PAGE_DOWN); 162 | } 163 | else if (b.equals("HOME")) 164 | { 165 | Keyboard.press(KEY_HOME); 166 | } 167 | else if (b.equals("ESC")) 168 | { 169 | Keyboard.press(KEY_ESC); 170 | } 171 | else if (b.equals("INSERT")) 172 | { 173 | Keyboard.press(KEY_INSERT); 174 | } 175 | else if (b.equals("TAB")) 176 | { 177 | Keyboard.press(KEY_TAB); 178 | } 179 | else if (b.equals("END")) 180 | { 181 | Keyboard.press(KEY_END); 182 | } 183 | else if (b.equals("CAPSLOCK")) 184 | { 185 | Keyboard.press(KEY_CAPS_LOCK); 186 | } 187 | else if (b.equals("F1")) 188 | { 189 | Keyboard.press(KEY_F1); 190 | } 191 | else if (b.equals("F2")) 192 | { 193 | Keyboard.press(KEY_F2); 194 | } 195 | else if (b.equals("F3")) 196 | { 197 | Keyboard.press(KEY_F3); 198 | } 199 | else if (b.equals("F4")) 200 | { 201 | Keyboard.press(KEY_F4); 202 | } 203 | else if (b.equals("F5")) 204 | { 205 | Keyboard.press(KEY_F5); 206 | } 207 | else if (b.equals("F6")) 208 | { 209 | Keyboard.press(KEY_F6); 210 | } 211 | else if (b.equals("F7")) 212 | { 213 | Keyboard.press(KEY_F7); 214 | } 215 | else if (b.equals("F8")) 216 | { 217 | Keyboard.press(KEY_F8); 218 | } 219 | else if (b.equals("F9")) 220 | { 221 | Keyboard.press(KEY_F9); 222 | } 223 | else if (b.equals("F10")) 224 | { 225 | Keyboard.press(KEY_F10); 226 | } 227 | else if (b.equals("F11")) 228 | { 229 | Keyboard.press(KEY_F11); 230 | } 231 | else if (b.equals("F12")) 232 | { 233 | Keyboard.press(KEY_F12); 234 | } 235 | } 236 | 237 | void loop() { 238 | // nothing happens after setup 239 | } 240 | -------------------------------------------------------------------------------- /Duckduino-microSD/Duckduino-microSD.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Seytonic 3 | * https://twitter.com/seytonic 4 | * https://www.youtube.com/seytonic 5 | * GIT: 6 | * https://github.com/Seytonic/Duckduino-microSD 7 | */ 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include "Keyboard.h" 14 | 15 | File myFile; 16 | boolean first = true; 17 | String DEFAULT_FILE_NAME = "script.txt"; 18 | 19 | void setup() { 20 | 21 | if (!SD.begin(4)) { 22 | return; 23 | } 24 | 25 | myFile = SD.open(DEFAULT_FILE_NAME); 26 | if (myFile) { 27 | Keyboard.begin(); 28 | 29 | String line = ""; 30 | while (myFile.available()) { 31 | char m = myFile.read(); 32 | if (m == '\n'){ 33 | Line(line); 34 | line = ""; 35 | } 36 | else if((int) m != 13) 37 | { 38 | line += m; 39 | } 40 | } 41 | Line(line); 42 | 43 | myFile.close(); 44 | } else { 45 | } 46 | 47 | Keyboard.end(); 48 | } 49 | 50 | void Line(String l) 51 | { 52 | int space_1 = l.indexOf(" "); 53 | if (space_1 == -1) 54 | { 55 | Press(l); 56 | } 57 | else if (l.substring(0,space_1) == "STRING") 58 | { 59 | Keyboard.print(l.substring(space_1 + 1)); 60 | } 61 | else if (l.substring(0,space_1) == "DELAY") 62 | { 63 | int delaytime = l.substring(space_1 + 1).toInt(); 64 | delay(delaytime); 65 | } 66 | else if(l.substring(0,space_1) == "REM"){} 67 | else 68 | { 69 | String remain = l; 70 | 71 | while(remain.length() > 0) 72 | { 73 | int latest_space = remain.indexOf(" "); 74 | if (latest_space == -1) 75 | { 76 | Press(remain); 77 | remain = ""; 78 | } 79 | else 80 | { 81 | Press(remain.substring(0, latest_space)); 82 | remain = remain.substring(latest_space + 1); 83 | } 84 | delay(5); 85 | } 86 | } 87 | 88 | Keyboard.releaseAll(); 89 | } 90 | 91 | 92 | void Press(String b) 93 | { 94 | if(b.length() == 1) 95 | { 96 | char c = b[0]; 97 | Keyboard.press(c); 98 | } 99 | else if (b.equals("ENTER")) 100 | { 101 | Keyboard.press(KEY_RETURN); 102 | } 103 | else if (b.equals("CTRL")) 104 | { 105 | Keyboard.press(KEY_LEFT_CTRL); 106 | } 107 | else if (b.equals("SHIFT")) 108 | { 109 | Keyboard.press(KEY_LEFT_SHIFT); 110 | } 111 | else if (b.equals("ALT")) 112 | { 113 | Keyboard.press(KEY_LEFT_ALT); 114 | } 115 | else if (b.equals("GUI")) 116 | { 117 | Keyboard.press(KEY_LEFT_GUI); 118 | } 119 | else if (b.equals("UP") || b.equals("UPARROW")) 120 | { 121 | Keyboard.press(KEY_UP_ARROW); 122 | } 123 | else if (b.equals("DOWN") || b.equals("DOWNARROW")) 124 | { 125 | Keyboard.press(KEY_DOWN_ARROW); 126 | } 127 | else if (b.equals("LEFT") || b.equals("LEFTARROW")) 128 | { 129 | Keyboard.press(KEY_LEFT_ARROW); 130 | } 131 | else if (b.equals("RIGHT") || b.equals("RIGHTARROW")) 132 | { 133 | Keyboard.press(KEY_RIGHT_ARROW); 134 | } 135 | else if (b.equals("DELETE")) 136 | { 137 | Keyboard.press(KEY_DELETE); 138 | } 139 | else if (b.equals("PAGEUP")) 140 | { 141 | Keyboard.press(KEY_PAGE_UP); 142 | } 143 | else if (b.equals("PAGEDOWN")) 144 | { 145 | Keyboard.press(KEY_PAGE_DOWN); 146 | } 147 | else if (b.equals("HOME")) 148 | { 149 | Keyboard.press(KEY_HOME); 150 | } 151 | else if (b.equals("ESC")) 152 | { 153 | Keyboard.press(KEY_ESC); 154 | } 155 | else if (b.equals("INSERT")) 156 | { 157 | Keyboard.press(KEY_INSERT); 158 | } 159 | else if (b.equals("TAB")) 160 | { 161 | Keyboard.press(KEY_TAB); 162 | } 163 | else if (b.equals("END")) 164 | { 165 | Keyboard.press(KEY_END); 166 | } 167 | else if (b.equals("CAPSLOCK")) 168 | { 169 | Keyboard.press(KEY_CAPS_LOCK); 170 | } 171 | else if (b.equals("F1")) 172 | { 173 | Keyboard.press(KEY_F1); 174 | } 175 | else if (b.equals("F2")) 176 | { 177 | Keyboard.press(KEY_F2); 178 | } 179 | else if (b.equals("F3")) 180 | { 181 | Keyboard.press(KEY_F3); 182 | } 183 | else if (b.equals("F4")) 184 | { 185 | Keyboard.press(KEY_F4); 186 | } 187 | else if (b.equals("F5")) 188 | { 189 | Keyboard.press(KEY_F5); 190 | } 191 | else if (b.equals("F6")) 192 | { 193 | Keyboard.press(KEY_F6); 194 | } 195 | else if (b.equals("F7")) 196 | { 197 | Keyboard.press(KEY_F7); 198 | } 199 | else if (b.equals("F8")) 200 | { 201 | Keyboard.press(KEY_F8); 202 | } 203 | else if (b.equals("F9")) 204 | { 205 | Keyboard.press(KEY_F9); 206 | } 207 | else if (b.equals("F10")) 208 | { 209 | Keyboard.press(KEY_F10); 210 | } 211 | else if (b.equals("F11")) 212 | { 213 | Keyboard.press(KEY_F11); 214 | } 215 | else if (b.equals("F12")) 216 | { 217 | Keyboard.press(KEY_F12); 218 | } 219 | else if (b.equals("SPACE")) 220 | { 221 | Keyboard.press(' '); 222 | } 223 | } 224 | 225 | void loop() { 226 | // nothing happens after setup 227 | } 228 | 229 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Duckduino-microSD 2 | Interpreter that runs on an arduino, decodes and executes ducky script on a microSD card. 3 | 4 | ## Benefits Over Alternatives 5 | Once the arduino has been programmed, you need only deal with ducky scripts on a microSD card. No reprogramming the arduino to change scripts! 6 | 7 | ## Setup 8 | 9 | [![video link](http://imgur.com/2a1fe002-68fa-4046-b3a8-83e6fa2a22fc)](https://www.youtube.com/watch?v=ksvo1WDYQ7s) 10 | 11 | The instructions are for an arduino pro micro, it should work on any arduino using an atmega32u4 chip such as the leonardo. 12 | Simply upload Duckduino-microSD to your arduino, forma your microSD to FAT32 and save your script on the microSD card titled script.txt 13 | Lastly, connect a microsd breakout board using the pins below 14 | ``` 15 | Arduino ||| microSD module 16 | 17 | VCC ---> VCC 18 | 19 | D15 ---> SCK 20 | 21 | D14 ---> MISO 22 | 23 | D16 ---> MOSI 24 | 25 | GND ---> GND 26 | 27 | D4 ---> CS 28 | ``` 29 | 30 | ## Keep in mind... 31 | Long lines of strings may crash the arduino due to taking up too much RAM, if you have a line "STRING ..." over 300 characters then split it into separate lines of strings, this won't affect how your script runs, it just reduces how much of your script is held in memory at any one time. 32 | 33 | I have seen some ducky scripts that put hyphens (-) in between keys to be pressed simultaneously eg."CTRL-ALT DELETE". Note that when using duckduino-microSD you must not use hyphens and instead just use spaces eg."CTRL ALT DELETE" 34 | 35 | The following duckyscript features are not yet implemented: DEFAULT_DELAY, REPLAY. This project uses arduino's inbuilt keyboard.h library, any keys not implemented in that will not work with this. eg: PRINTSCREEN. 36 | 37 | This has only been tested on the following microSD module, I'm sure others will work, though no guarantees. 38 | --------------------------------------------------------------------------------