Hack with a 1.99$ cheap BadUSB --- Digispark(ATTINY85)

Hack with a 1.99$ cheap BadUSB --- Digispark(ATTINY85)

BadUSB disguises itself as a human interface device(HID) such as keyboards or mice and covertly executes malicious commands or opens virus payloads on the target computer. We made a cheap BadUSB which costs less than 2$.


About BadUSB

What is BadUSB? In short, BadUSB disguises itself as a human interface device(HID) such as keyboards or mice and covertly executes malicious commands or opens virus payloads on the target computer. One of the terrible things is which takes control over the system using low-level debugging on a certain type of BIOSes.

Possible BadUSB Devices

  • Keyboard;
  • Network card;
  • Mouse;
  • USB charging cables
  • USB sticks
  • Anything can be inserted which can be miniaturized into a USB stick form factor.

What we need…

  • Digispark(ATTINY85) Default - 16.5mhz
  • Arduino IDE

Why use Digispark?

digispark

Digispark: The micro-sized, affordable, Arduino enabled, USB development board!

  • Cheap, very cheap(1~2$)
  • Tiny enough
    • Item Weight: 3.53 ounces
    • The size of a coin
  • Easy to program, support Arduino

The Digispark is an ATtiny85 based microcontroller development board similar to the Arduino line, only cheaper, smaller, and a bit less powerful. With a whole host of shields to extend its functionality and the ability to use the familiar Arduino IDE the Digispark is a great way to jump into electronics, or perfect for when an Arduino is too big or too much.

Step 1: Configure bootloader(Windows)

The bootloader is the code that is pre-programmed on your Digispark and allows it to act as a USB device so that it can be programmed by the Arduino IDE.

You can download bootloader for Windows here(Github):

https://github.com/digistump/DigistumpArduino/releases/download/1.6.7/Digistump.Drivers.zip

driver

Double-click either DPinst64.exe on a 64-bit Windows computer, or DPinst.exe on a 32-bit Windows computer to install the Digispark drivers.

Step 2: Setup Arduino

Go to https://www.arduino.cc/en/Main/Software download installer. If you are using Linux, there are some more steps:

Install Arduino in Linux

Download the Linux 64 bits file for 64-bit Linux Intel systems or the Linux 32 bits file for Linux 32-bit Intel systems. Unzip the downloaded file, and extract the folder found in the zipped file to a convenient location. To run the Arduino IDE application, open the extracted folder and double-click the Arduino executable file. To install, run command sh install.sh.

Add Linux User Name to the Dialout Group

In order to be able to program any board from the Arduino IDE, the Linux user must be added to the dialout group.

$ sudo adduser $USER dialout

Enter your Linux password when prompted.

You will need to log out and then log back in, or reboot, for the changes to take effect.

Add udev Rules to the System

To be able to program the Digispark board from the Arduino IDE in Linux, udev rules must be added to the system. This is done by creating a file in /etc/udev/rules.d/ that contains the rules.

Create a text file called 49-micronucleus.rules in /etc/udev/rules.d/ and add the following rules to it(you will need root permission).

# UDEV Rules for Micronucleus boards including the Digispark.
# This file must be placed at:
#
# /etc/udev/rules.d/49-micronucleus.rules    (preferred location)
#   or
# /lib/udev/rules.d/49-micronucleus.rules    (req'd on some broken systems)
#
# After this file is copied, physically unplug and reconnect the board.
#
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
#
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

Step 3: Add Digispark Package

  • Run the Arduino application.
  • In the Arduino application go to the “File” menu and select “Preferences”

perf.png

  • In the box labeled “Additional Boards Manager URLs” enter:
http://digistump.com/package_digistump_index.json

perf_1.png

  • Click OK
  • Go to the “Tools” menu and then the “Board” submenu - select “Boards Manager” and then from the type drop down select “Contributed”
  • Select the “Digistump AVR Boards” package and click the “Install” button.
  • With the install complete, close the “Boards Manager” window and select the Digispark from the Tools→Boards menu. Select Digispark (Default - 16.5mhz).

Step 4: Programming the BadUSB

We should first program a sketch first, here’s a simple example:

//This DigiKeyboard Script opens a cmd window and echo 'Hello World!'

#include "DigiKeyboard.h"

void setup()
{
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  DigiKeyboard.delay(200);
  DigiKeyboard.println("cmd");
  DigiKeyboard.delay(200);
  DigiKeyboard.println("echo Hello World");
}

void loop()
{
  //empty
}

Then click Upload and insert the Digispark. Wait for the script to finish uploading. When the “Micronucleus done. Thank you!” message appears, it means that the script has finished uploading and you can unplug your BadUSB.

Some Scripts You may Need:

How to Defense?

  • Egress filtering in Firewalls.
  • Physically block USB Ports.
  • Disable automatic installation of new USB devices.

More You may Wanna Know…

Digispark Pin Usage Guide

Pin NumberOutput VoltageAnalogue Port Number analogRead()PWMUSBTest LEDI2CSPI*
05V Y - 504 Hz Rev 1SDAMISO
15V Y - 504 Hz Rev 2 / 4 MISO
25V1   SCLSCK
33.6V3 Y - 1.5k Ohm to 5 V
Zener diode (3.6 V maximum in- & output)
   
43.6V2Y - 1007 HzY Zener diode (3.6 V maximum in- & output)   
53V0     

*Note that the labeling of the pins for SPI is somewhat misleading. The table above is correct, as MISO is actually DI and MOSI is DO, but for use with ISP MISO and MOSI are swapped.

Digispark Pro Pin Usage Guide

This table details the function of each pin on the Digispark Pro and any notes the are relevant.

 Pin NumberOutput VoltageADCPWM
VCCVCC5v  
SDA0 SDA5v Y
LED1 LED5v Y
SCL2 SCL5v Y
USB+3 USB+5vA3Y
USB-4 USB-5v Y
Pin 555vA5Y
GNDGND0v  
VINVIN(6-16v)   
RX6 RX5vA6 
TX7 TX5vA7 
MISO8 MISO5vA8Y
INT19 INT15vA9 
MOSI10 MOSI5vA10 
SCK11 SCK5vA11 
SS12 SS5vA12 
RSTRST   
VINVIN(6-16v)   
GNDGND0v  
VCCVCC5v  

PWM

https://digistump.com/wiki/digispark/tutorials/propwm

THESE SOFTWARES AND SCRIPTS ARE PROVIDED FOR EDUCATIONAL USE ONLY! IF YOU ENGAGE IN ANY ILLEGAL ACTIVITY WE DO NOT TAKE ANY RESPONSIBILITY FOR IT. BY USING THESE SOFTWARES AND SCRIPTS YOU AGREE WITH THESE TERMS.


© 2020-2021. All rights reserved.