Keystroke injection via USB

ATtiny 85 microcontroller

Environment setup on Kali and “Hello World”
  1. Download the Arduino IDE and install the dependecies
sudo apt-get install libusb-0.1-4
  1. Extract and install - https://www.arduino.cc/en/Guide/Linux

    ./install.sh
    ./arduino
    
  2. Go to Preferences > Additional Boards Manager URLs and paste “http://digistump.com/package_digistump_index.json"

  3. Go to Tools > Board > Board Manager and search for “Digistump AVR” and install the latest version.

  4. Hello world

    #include "DigiKeyboard.h"
    void setup() {
    //empty
    }
    void loop() {
    DigiKeyboard.sendKeyStroke(0);
    DigiKeyboard.delay(500);
    DigiKeyboard.print("Hello World");
    for(;;){ /*empty*/ }
    }
    
  5. Click on Upload button and plug the USB device

Change the product ID (PID) and the vendor ID (VID)
  1. Check the VID:PID

    lsusb
    
  2. Edit the configuration file (example 06ab:0107)

    nano /root/.arduino15/packages/digistump/hardware/avr/1.6.7/libraries/DigisparkKeyboard/usbconfig.h
    #define USB_CFG_VENDOR_ID 0xab, 0x06
    #define USB_CFG_DEVICE_ID 0x07, 0x01
    

Rubber Ducky

  1. Setup

    cd /opt
    git clone https://github.com/hak5darren/USB-Rubber-Ducky
    cd USB-Rubber-Ducky/
    
  2. Hello World

    REM Hello World
    DELAY 1000
    STRING Hello world
    
  3. Loading the script

    java -jar duckencoder.jar  -i /path/to/hello_world.duckyscript -o /media/root/A87B-A154/inject.bin
    
  4. Unplug the device

    umount /media/root/A87B-A154